当前位置: 首页>>代码示例>>PHP>>正文


PHP FileCacheFactory::get方法代码示例

本文整理汇总了PHP中Drupal\Component\FileCache\FileCacheFactory::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCacheFactory::get方法的具体用法?PHP FileCacheFactory::get怎么用?PHP FileCacheFactory::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Component\FileCache\FileCacheFactory的用法示例。


在下文中一共展示了FileCacheFactory::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findAll

 /**
  * {@inheritdoc}
  */
 public function findAll()
 {
     $all = array();
     $files = $this->findFiles();
     $file_cache = FileCacheFactory::get('yaml_discovery:' . $this->fileCacheKeySuffix);
     // Try to load from the file cache first.
     foreach ($file_cache->getMultiple(array_keys($files)) as $file => $data) {
         $all[$files[$file]][$this->getIdentifier($file, $data)] = $data;
         unset($files[$file]);
     }
     // If there are files left that were not returned from the cache, load and
     // parse them now. This list was flipped above and is keyed by filename.
     if ($files) {
         foreach ($files as $file => $provider) {
             // If a file is empty or its contents are commented out, return an empty
             // array instead of NULL for type consistency.
             try {
                 $data = Yaml::decode(file_get_contents($file)) ?: [];
             } catch (InvalidDataTypeException $e) {
                 throw new DiscoveryException("The {$file} contains invalid YAML", 0, $e);
             }
             $data[static::FILE_KEY] = $file;
             $all[$provider][$this->getIdentifier($file, $data)] = $data;
             $file_cache->set($file, $data);
         }
     }
     return $all;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:31,代码来源:YamlDirectoryDiscovery.php

示例2: array

 /**
  * Constructs a new instance.
  *
  * @param string[] $plugin_namespaces
  *   (optional) An array of namespace that may contain plugin implementations.
  *   Defaults to an empty array.
  * @param string $plugin_definition_annotation_name
  *   (optional) The name of the annotation that contains the plugin definition.
  *   Defaults to 'Drupal\Component\Annotation\Plugin'.
  * @param string[] $annotation_namespaces
  *   (optional) Additional namespaces to be scanned for annotation classes.
  */
 function __construct($plugin_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin', array $annotation_namespaces = [])
 {
     $this->pluginNamespaces = $plugin_namespaces;
     $this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
     $this->annotationNamespaces = $annotation_namespaces;
     $file_cache_suffix = str_replace('\\', '_', $plugin_definition_annotation_name);
     $file_cache_suffix .= ':' . hash('crc32b', serialize($annotation_namespaces));
     $this->fileCache = FileCacheFactory::get('annotation_discovery:' . $file_cache_suffix);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:21,代码来源:AnnotatedClassDiscovery.php

示例3: __construct

 /**
  * Constructs a new FileStorage.
  *
  * @param string $directory
  *   A directory path to use for reading and writing of configuration files.
  * @param string $collection
  *   (optional) The collection to store configuration in. Defaults to the
  *   default collection.
  */
 public function __construct($directory, $collection = StorageInterface::DEFAULT_COLLECTION)
 {
     $this->directory = $directory;
     $this->collection = $collection;
     // Use a NULL File Cache backend by default. This will ensure only the
     // internal statc caching of FileCache is used and thus avoids blowing up
     // the APCu cache.
     $this->fileCache = FileCacheFactory::get('config', ['cache_backend_class' => NULL]);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:FileStorage.php

示例4: findAll

 /**
  * {@inheritdoc}
  */
 public function findAll()
 {
     $all = array();
     $files = $this->findFiles();
     $provider_by_files = array_flip($files);
     $file_cache = FileCacheFactory::get('yaml_discovery:' . $this->name);
     // Try to load from the file cache first.
     foreach ($file_cache->getMultiple($files) as $file => $data) {
         $all[$provider_by_files[$file]] = $data;
         unset($provider_by_files[$file]);
     }
     // If there are files left that were not returned from the cache, load and
     // parse them now. This list was flipped above and is keyed by filename.
     if ($provider_by_files) {
         foreach ($provider_by_files as $file => $provider) {
             // If a file is empty or its contents are commented out, return an empty
             // array instead of NULL for type consistency.
             $all[$provider] = Yaml::decode(file_get_contents($file)) ?: [];
             $file_cache->set($file, $all[$provider]);
         }
     }
     return $all;
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:26,代码来源:YamlDiscovery.php

示例5: setContainerParameter

 /**
  * Changes parameters in the services.yml file.
  *
  * @param $name
  *   The name of the parameter.
  * @param $value
  *   The value of the parameter.
  */
 protected function setContainerParameter($name, $value)
 {
     $filename = $this->siteDirectory . '/services.yml';
     chmod($filename, 0666);
     $services = Yaml::decode(file_get_contents($filename));
     $services['parameters'][$name] = $value;
     file_put_contents($filename, Yaml::encode($services));
     // Ensure that the cache is deleted for the yaml file loader.
     $file_cache = FileCacheFactory::get('container_yaml_loader');
     $file_cache->delete($filename);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:19,代码来源:WebTestBase.php

示例6: __construct

 /**
  * Constructs a new ExtensionDiscovery object.
  *
  * @param string $root
  *   The app root.
  * @param bool $use_file_cache
  *   Whether file cache should be used.
  * @param string[] $profile_directories
  *   The available profile directories
  * @param string $site_path
  *   The path to the site.
  */
 public function __construct($root, $use_file_cache = TRUE, $profile_directories = NULL, $site_path = NULL)
 {
     $this->root = $root;
     $this->fileCache = $use_file_cache ? FileCacheFactory::get('extension_discovery') : NULL;
     $this->profileDirectories = $profile_directories;
     $this->sitePath = $site_path;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:19,代码来源:ExtensionDiscovery.php

示例7: __construct

 /**
  * Constructs a new ExtensionDiscovery object.
  *
  * @param string $root
  *   The app root.
  */
 public function __construct($root)
 {
     $this->root = $root;
     $this->fileCache = FileCacheFactory::get('extension_discovery');
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:11,代码来源:ExtensionDiscovery.php

示例8: __construct

 public function __construct(ContainerBuilder $container)
 {
     $this->container = $container;
     $this->fileCache = FileCacheFactory::get('container_yaml_loader');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:5,代码来源:YamlFileLoader.php

示例9: testGetNoPrefix

 /**
  * @covers ::get
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Required prefix configuration is missing
  */
 public function testGetNoPrefix()
 {
     FileCacheFactory::setPrefix(NULL);
     FileCacheFactory::get('test_foo_settings', []);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:11,代码来源:FileCacheFactoryTest.php

示例10: testGetConfigurationOverrides

 /**
  * @covers ::get
  *
  * @dataProvider configurationDataProvider
  */
 public function testGetConfigurationOverrides($configuration, $arguments, $class)
 {
     FileCacheFactory::setConfiguration($configuration);
     $file_cache = FileCacheFactory::get('test_foo_settings', $arguments);
     $this->assertInstanceOf($class, $file_cache);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:11,代码来源:FileCacheFactoryTest.php


注:本文中的Drupal\Component\FileCache\FileCacheFactory::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。