本文整理汇总了PHP中TYPO3\Flow\Cache\Frontend\VariableFrontend::has方法的典型用法代码示例。如果您正苦于以下问题:PHP VariableFrontend::has方法的具体用法?PHP VariableFrontend::has怎么用?PHP VariableFrontend::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Cache\Frontend\VariableFrontend
的用法示例。
在下文中一共展示了VariableFrontend::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCachedJson
/**
* Return the json array for a given locale, sourceCatalog, xliffPath and package.
* The json will be cached.
*
* @param Locale $locale The locale
* @return Result
* @throws Exception
*/
public function getCachedJson(Locale $locale)
{
$cacheIdentifier = md5($locale);
if ($this->xliffToJsonTranslationsCache->has($cacheIdentifier)) {
$json = $this->xliffToJsonTranslationsCache->get($cacheIdentifier);
} else {
$labels = [];
$localeChain = $this->localizationService->getLocaleChain($locale);
foreach ($this->packagesRegisteredForAutoInclusion as $packageKey => $sourcesToBeIncluded) {
if (!is_array($sourcesToBeIncluded)) {
continue;
}
$translationBasePath = Files::concatenatePaths([$this->packageManager->getPackage($packageKey)->getResourcesPath(), $this->xliffBasePath]);
// We merge labels in the chain from the worst choice to best choice
foreach (array_reverse($localeChain) as $allowedLocale) {
$localeSourcePath = Files::getNormalizedPath(Files::concatenatePaths([$translationBasePath, $allowedLocale]));
foreach ($sourcesToBeIncluded as $sourceName) {
foreach (glob($localeSourcePath . $sourceName . '.xlf') as $xliffPathAndFilename) {
$xliffPathInfo = pathinfo($xliffPathAndFilename);
$sourceName = str_replace($localeSourcePath, '', $xliffPathInfo['dirname'] . '/' . $xliffPathInfo['filename']);
$labels = Arrays::arrayMergeRecursiveOverrule($labels, $this->parseXliffToArray($xliffPathAndFilename, $packageKey, $sourceName));
}
}
}
}
$json = json_encode($labels);
$this->xliffToJsonTranslationsCache->set($cacheIdentifier, $json);
}
return $json;
}
示例2: initializeObject
/**
* Lifecycle method, called after all dependencies have been injected.
* Here, the typeConverter array gets initialized.
*
* @return void
* @throws Exception\DuplicateTypeConverterException
*/
public function initializeObject()
{
if ($this->cache->has('typeConverterMap')) {
$this->typeConverters = $this->cache->get('typeConverterMap');
return;
}
$this->typeConverters = $this->prepareTypeConverterMap();
$this->cache->set('typeConverterMap', $this->typeConverters);
}
示例3: initializeObject
/**
* Initializes the locale service
*
* @return void
*/
public function initializeObject()
{
$this->configuration = new Configuration($this->settings['defaultLocale']);
$this->configuration->setFallbackRule($this->settings['fallbackRule']);
if ($this->cache->has('availableLocales')) {
$this->localeCollection = $this->cache->get('availableLocales');
} else {
$this->generateAvailableLocalesCollectionByScanningFilesystem();
$this->cache->set('availableLocales', $this->localeCollection);
}
}
示例4: cacheGetMergedTypoScriptObjectTree
/**
* @Flow\Around("setting(TYPO3.Neos.typoScript.enableObjectTreeCache) && method(TYPO3\Neos\Domain\Service\TypoScriptService->getMergedTypoScriptObjectTree())")
* @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
* @return mixed
*/
public function cacheGetMergedTypoScriptObjectTree(JoinPointInterface $joinPoint)
{
$currentSiteNode = $joinPoint->getMethodArgument('startNode');
$cacheIdentifier = str_replace('.', '_', $currentSiteNode->getContext()->getCurrentSite()->getSiteResourcesPackageKey());
if ($this->typoScriptCache->has($cacheIdentifier)) {
$typoScriptObjectTree = $this->typoScriptCache->get($cacheIdentifier);
} else {
$typoScriptObjectTree = $joinPoint->getAdviceChain()->proceed($joinPoint);
$this->typoScriptCache->set($cacheIdentifier, $typoScriptObjectTree);
}
return $typoScriptObjectTree;
}
示例5: getSession
/**
* Returns the specified session. If no session with the given identifier exists,
* NULL is returned.
*
* @param string $sessionIdentifier The session identifier
* @return \TYPO3\Flow\Session\Session
* @api
*/
public function getSession($sessionIdentifier)
{
if ($this->currentSession !== NULL && $this->currentSession->isStarted() && $this->currentSession->getId() === $sessionIdentifier) {
return $this->currentSession;
}
if (isset($this->remoteSessions[$sessionIdentifier])) {
return $this->remoteSessions[$sessionIdentifier];
}
if ($this->metaDataCache->has($sessionIdentifier)) {
$sessionInfo = $this->metaDataCache->get($sessionIdentifier);
$this->remoteSessions[$sessionIdentifier] = new Session($sessionIdentifier, $sessionInfo['storageIdentifier'], $sessionInfo['lastActivityTimestamp'], $sessionInfo['tags']);
return $this->remoteSessions[$sessionIdentifier];
}
}
示例6: initializeValue
/**
* @param string $value
* @throws Exception
* @throws \TYPO3\Flow\Resource\Exception
* @throws \TYPO3\Flow\Utility\Exception
*/
protected function initializeValue($value)
{
if (!is_array($value)) {
throw new Exception('Value must be an array, with source URI (sourceUri) and filename (filename)', 1425981082);
}
if (!isset($value['sourceUri'])) {
throw new Exception('Missing source URI', 1425981083);
}
$sourceUri = trim($value['sourceUri']);
if (!isset($value['filename'])) {
throw new Exception('Missing filename URI', 1425981084);
}
$filename = trim($value['filename']);
$overrideFilename = isset($value['overrideFilename']) ? trim($value['overrideFilename']) : $filename;
if (!isset($this->options['downloadDirectory'])) {
throw new Exception('Missing download directory data type option', 1425981085);
}
Files::createDirectoryRecursively($this->options['downloadDirectory']);
$temporaryFileAndPathname = trim($this->options['downloadDirectory'] . $filename);
$this->download($sourceUri, $temporaryFileAndPathname);
$sha1Hash = sha1_file($temporaryFileAndPathname);
# Try to add file extenstion if missing
if (!$this->downloadCache->has($sha1Hash)) {
$fileExtension = pathinfo($temporaryFileAndPathname, PATHINFO_EXTENSION);
if (trim($fileExtension) === '') {
$mimeTypeGuesser = new MimeTypeGuesser();
$mimeType = $mimeTypeGuesser->guess($temporaryFileAndPathname);
$this->logger->log(sprintf('Try to guess mime type for "%s" (%s), result: %s', $sourceUri, $filename, $mimeType), LOG_DEBUG);
$fileExtension = MediaTypes::getFilenameExtensionFromMediaType($mimeType);
if ($fileExtension !== '') {
$oldTemporaryDestination = $temporaryFileAndPathname;
$temporaryDestination = $temporaryFileAndPathname . '.' . $fileExtension;
copy($oldTemporaryDestination, $temporaryDestination);
$this->logger->log(sprintf('Rename "%s" to "%s"', $oldTemporaryDestination, $temporaryDestination), LOG_DEBUG);
}
}
}
$resource = $this->resourceManager->getResourceBySha1($sha1Hash);
if ($resource === NULL) {
$resource = $this->resourceManager->importResource($temporaryFileAndPathname);
if ($filename !== $overrideFilename) {
$resource->setFilename($overrideFilename);
}
}
$this->temporaryFileAndPathname = $temporaryFileAndPathname;
$this->downloadCache->set($sha1Hash, ['sha1Hash' => $sha1Hash, 'filename' => $filename, 'sourceUri' => $sourceUri, 'temporaryFileAndPathname' => $temporaryFileAndPathname]);
$this->value = $resource;
}
示例7: getResponseFromCache
/**
* @Flow\Around("setting(Ttree.Embedly.logApiRequest) && within(Ttree\Embedly\Embedly) && method(public .*->(oembed|preview|objectify|extract|services)())")
* @param JoinPointInterface $joinPoint The current join point
* @return mixed
*/
public function getResponseFromCache(JoinPointInterface $joinPoint)
{
$proxy = $joinPoint->getProxy();
$key = ObjectAccess::getProperty($proxy, 'key');
$params = $joinPoint->getMethodArgument('params');
$cacheKey = md5($joinPoint->getClassName() . $joinPoint->getMethodName() . $key . json_encode($params));
if ($this->responseCache->has($cacheKey)) {
$this->systemLogger->log(sprintf(' cache hit Embedly::%s', $joinPoint->getMethodName()), LOG_DEBUG);
return $this->responseCache->get($cacheKey);
} else {
$this->systemLogger->log(sprintf(' cache miss Embedly::%s', $joinPoint->getMethodName()), LOG_DEBUG);
}
$response = $joinPoint->getAdviceChain()->proceed($joinPoint);
$this->responseCache->set($cacheKey, $response);
return $response;
}
示例8: savePolicyCache
/**
* Save the found matches to the cache.
*
* @return void
*/
public function savePolicyCache()
{
$tags = array('TYPO3_Flow_Aop');
if (!$this->methodPermissionCache->has('methodPermission')) {
$this->methodPermissionCache->set('methodPermission', $this->methodPermissions, $tags);
}
}
示例9: initializeObject
/**
* Constructs the reader, loading parsed data from cache if available.
*
* @return void
*/
public function initializeObject()
{
if ($this->cache->has('parsedFormats') && $this->cache->has('parsedFormatsIndices') && $this->cache->has('localizedLiterals')) {
$this->parsedFormats = $this->cache->get('parsedFormats');
$this->parsedFormatsIndices = $this->cache->get('parsedFormatsIndices');
$this->localizedLiterals = $this->cache->get('localizedLiterals');
}
}
示例10: initializeObject
/**
* When it's called, XML file is parsed (using parser set in $xmlParser)
* or cache is loaded, if available.
*
* @return void
*/
public function initializeObject()
{
if ($this->cache->has(md5($this->sourcePath))) {
$this->xmlParsedData = $this->cache->get(md5($this->sourcePath));
} else {
$this->xmlParsedData = $this->xmlParser->getParsedData($this->sourcePath);
$this->cache->set(md5($this->sourcePath), $this->xmlParsedData);
}
}
示例11: savePolicyCache
/**
* Save the found matches to the cache.
*
* @return void
*/
public function savePolicyCache()
{
$tags = array('TYPO3_Flow_Aop');
if (!$this->cache->has('acls')) {
$this->cache->set('acls', $this->acls, $tags);
}
if (!$this->cache->has('entityResourcesConstraints')) {
$this->cache->set('entityResourcesConstraints', $this->entityResourcesConstraints);
}
}
示例12: initializeObject
/**
* When it's called, CLDR file is parsed or cache is loaded, if available.
*
* @return void
*/
public function initializeObject()
{
if ($this->cache->has($this->cacheKey)) {
$this->parsedData = $this->cache->get($this->cacheKey);
} else {
$this->parsedData = $this->parseFiles($this->sourcePaths);
$this->parsedData = $this->resolveAliases($this->parsedData, '');
$this->cache->set($this->cacheKey, $this->parsedData);
}
}
示例13: initializeObject
/**
* Constructs the reader, loading parsed data from cache if available.
*
* @return void
*/
public function initializeObject()
{
if ($this->cache->has('rulesets') && $this->cache->has('rulesetsIndices')) {
$this->rulesets = $this->cache->get('rulesets');
$this->rulesetsIndices = $this->cache->get('rulesetsIndices');
} else {
$this->generateRulesets();
$this->cache->set('rulesets', $this->rulesets);
$this->cache->set('rulesetsIndices', $this->rulesetsIndices);
}
}
示例14: build
/**
* Builds proxy class code which weaves advices into the respective target classes.
*
* The object configurations provided by the Compiler are searched for possible aspect
* annotations. If an aspect class is found, the pointcut expressions are parsed and
* a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
* Finally all advices are woven into their target classes by generating proxy classes.
*
* In general, the command typo3.flow:core:compile is responsible for compilation
* and calls this method to do so.
*
* In order to distinguish between an emerged / changed possible target class and
* a class which has been matched previously but just didn't have to be proxied,
* the latter are kept track of by an "unproxiedClass-*" cache entry.
*
* @return void
*/
public function build()
{
$allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
$possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
$actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation(Flow\Aspect::class);
sort($possibleTargetClassNames);
sort($actualAspectClassNames);
$this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
$rebuildEverything = false;
if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === false) {
$rebuildEverything = true;
$this->systemLogger->log('Aspects have been modified, therefore rebuilding all target classes.', LOG_INFO);
$this->objectConfigurationCache->set('allAspectClassesUpToDate', true);
}
$possibleTargetClassNameIndex = new ClassNameIndex();
$possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
$targetClassNameCandidates = new ClassNameIndex();
foreach ($this->aspectContainers as $aspectContainer) {
$targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
}
$targetClassNameCandidates->sort();
$treatedSubClasses = new ClassNameIndex();
foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
$isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
$hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
if ($rebuildEverything === true || $hasCacheEntry === false) {
$proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
if ($proxyBuildResult === false) {
// In case the proxy was not build because there was nothing adviced,
// it might be an advice in the parent and so we need to try to treat this class.
$treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($targetClassName, $treatedSubClasses);
}
$treatedSubClasses = $this->proxySubClassesOfClassToEnsureAdvices($targetClassName, $targetClassNameCandidates, $treatedSubClasses);
if ($proxyBuildResult !== false) {
if ($isUnproxied) {
$this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
}
$this->systemLogger->log(sprintf('Built AOP proxy for class "%s".', $targetClassName), LOG_DEBUG);
} else {
$this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), true);
}
}
}
}
示例15: shutdownObject
/**
* Shuts down this session
*
* This method must not be called manually – it is invoked by Flow's object
* management.
*
* @return void
*/
public function shutdownObject()
{
if ($this->started === true && $this->remote === false) {
if ($this->metaDataCache->has($this->sessionIdentifier)) {
// Security context can't be injected and must be retrieved manually
// because it relies on this very session object:
$securityContext = $this->objectManager->get(\TYPO3\Flow\Security\Context::class);
if ($securityContext->isInitialized()) {
$this->storeAuthenticatedAccountsInfo($securityContext->getAuthenticationTokens());
}
$this->putData('TYPO3_Flow_Object_ObjectManager', $this->objectManager->getSessionInstances());
$this->writeSessionMetaDataCacheEntry();
}
$this->started = false;
$decimals = strlen(strrchr($this->garbageCollectionProbability, '.')) - 1;
$factor = $decimals > -1 ? $decimals * 10 : 1;
if (rand(0, 100 * $factor) <= $this->garbageCollectionProbability * $factor) {
$this->collectGarbage();
}
}
$this->request = null;
}