本文整理汇总了PHP中Symfony\Component\Config\ConfigCache::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigCache::getPath方法的具体用法?PHP ConfigCache::getPath怎么用?PHP ConfigCache::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Config\ConfigCache
的用法示例。
在下文中一共展示了ConfigCache::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerBundles
/**
* Get the list of all "autoregistered" bundles
*
* @return array List ob bundle objects
*/
public function registerBundles(array $blackList = [])
{
if (!empty($blackList)) {
$blackList = array_flip($blackList);
$blackList = array_change_key_case($blackList, CASE_LOWER);
}
// clear state of CumulativeResourceManager
CumulativeResourceManager::getInstance()->clear();
$bundles = [];
if (!$this->getCacheDir()) {
foreach ($this->collectBundles($blackList) as $class => $params) {
$bundles[] = $params['kernel'] ? new $class($this) : new $class();
}
} else {
$file = $this->getCacheDir() . '/bundles.php';
$cache = new ConfigCache($file, $this->debug);
if (!$cache->isFresh($file)) {
$bundles = $this->collectBundles($blackList);
$dumper = new PhpBundlesDumper($bundles);
$metaData = [];
foreach ($bundles as $bundle) {
$metaData[] = new FileResource($bundle['file']);
}
$metaData[] = new FileResource($this->rootDir . '/../composer.lock');
//a composer update might add bundles
$metaData[] = new DirectoryResource($this->rootDir . '/../src/', '/.*Bundle.php$/');
//all bundle.php files
$cache->write($dumper->dump(), $metaData);
}
// require instead of require_once used to correctly handle sub-requests
$bundles = (require $cache instanceof ConfigCacheInterface ? $cache->getPath() : $cache);
}
return $bundles;
}
示例2: load
/**
* Loads document proxy class into cache.
*
* @param \ReflectionClass $reflectionClass
*
* @return string Proxy document path.
*/
public function load(\ReflectionClass $reflectionClass)
{
$cacheBundleDir = $this->getCacheDir($reflectionClass->getName());
$cache = new ConfigCache($cacheBundleDir . DIRECTORY_SEPARATOR . md5(strtolower($reflectionClass->getShortName())) . '.php', $this->debug);
if (!$cache->isFresh()) {
$code = ProxyFactory::generate($reflectionClass);
$cache->write($code, [new FileResource($reflectionClass->getFileName())]);
}
return $cache->getPath();
}
示例3: create
/**
* Returns a new created container instance.
*
* @param string $environment
* @param bool $debug
*
* @return ContainerInterface
*/
public function create($environment, $debug = false)
{
$cachedContainerClassName = ucfirst($environment) . ($debug ? 'Debug' : '') . 'Container';
$cache = new ConfigCache($this->cacheDir . '/' . $cachedContainerClassName . '.php', $debug);
if (!$cache->isFresh()) {
$container = new ContainerBuilder(new ParameterBag(['environment' => $environment, 'debug' => $debug]));
$container->addObjectResource($this);
foreach ($this->loaders as $loader) {
(new ClosureLoader($container))->load($loader);
}
$container->compile();
$dumper = new PhpDumper($container);
$content = $dumper->dump(['class' => stristr(basename($cache->getPath()), '.', true)]);
$cache->write($debug ? $content : self::stripComments($content), $container->getResources());
if ($debug) {
self::dumpForDebug(preg_replace('/\\.php/', '.xml', $cache->getPath()), $container);
}
}
require_once $cache->getPath();
return new $cachedContainerClassName();
}
示例4: getPageControllers
public function getPageControllers()
{
if ($this->pageControllers === null) {
$cache = new ConfigCache($this->cacheFile, $this->debug);
if ($cache->isFresh()) {
$this->pageControllers = unserialize(require $cache->getPath());
} else {
$this->loadPageControllers();
$cache->write(sprintf('<?php return %s;', var_export(serialize($this->pageControllers), true)));
}
}
return $this->pageControllers;
}
示例5: getWsdlFile
public function getWsdlFile($endpoint = null)
{
$file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$cache = new ConfigCache($file, $this->options['debug']);
if (!$cache->isFresh()) {
$definition = $this->getServiceDefinition();
if ($endpoint) {
$definition->setOption('location', $endpoint);
}
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
$cache->write($dumper->dump());
}
return $cache->getPath();
}
示例6: getConfigData
/**
* Get the config data.
*
* @return ConfigData
*/
public function getConfigData()
{
if ($this->configData === null) {
$configCache = new ConfigCache(sprintf('%s/config.php', $this->cacheDir), $this->debug);
if ($configCache->isFresh()) {
$this->configData = unserialize(require $configCache->getPath());
} else {
$this->configData = new ConfigData();
$this->loader->loadStyleData($this->configData);
$configCache->write(sprintf('<?php return %s;', var_export(serialize($this->configData), true)));
}
}
return $this->configData;
}
示例7: loadContainer
function loadContainer()
{
$config = loadConfig();
$containerCachePath = CACHE_PATH . 'appContainerCache.php';
$containerCache = new ConfigCache($containerCachePath, true);
if (!$containerCache->isFresh()) {
$di = new SymfonyCert();
$container = $di->createContainerFromYamlConfig($config);
$container->compile();
$dumper = new PhpDumper($container);
$dump = $dumper->dump(['class' => 'AppServiceContainer']);
$containerCache->write($dump, $container->getResources());
}
require_once $containerCache->getPath();
$container = new \AppServiceContainer();
return $container;
}
示例8: getFieldDescriptorForClass
/**
* {@inheritdoc}
*/
public function getFieldDescriptorForClass($className, $options = [], $type = null)
{
$cacheKey = md5(json_encode($options));
$cache = new ConfigCache(sprintf('%s/%s-%s-%s.php', $this->cachePath, str_replace('\\', '-', $className), str_replace('\\', '-', $type), $cacheKey), $this->debug);
if ($cache->isFresh()) {
return require $cache->getPath();
}
$metadata = $this->metadataProvider->getMetadataForClass($className);
$fieldDescriptors = [];
/** @var PropertyMetadata $propertyMetadata */
foreach ($metadata->propertyMetadata as $propertyMetadata) {
/** @var GeneralPropertyMetadata $generalMetadata */
$generalMetadata = $propertyMetadata->get(GeneralPropertyMetadata::class);
if (!$propertyMetadata->has(DoctrinePropertyMetadata::class)) {
$fieldDescriptor = $this->getGeneralFieldDescriptor($generalMetadata, $options);
if (!$type || is_a($fieldDescriptor, $type)) {
$fieldDescriptors[$generalMetadata->getName()] = $fieldDescriptor;
}
continue;
}
/** @var DoctrinePropertyMetadata $doctrineMetadata */
$doctrineMetadata = $propertyMetadata->get(DoctrinePropertyMetadata::class);
$fieldDescriptor = null;
if ($doctrineMetadata->getType() instanceof ConcatenationTypeMetadata) {
$fieldDescriptor = $this->getConcatenationFieldDescriptor($generalMetadata, $doctrineMetadata->getType(), $options);
} elseif ($doctrineMetadata->getType() instanceof GroupConcatTypeMetadata) {
$fieldDescriptor = $this->getGroupConcatenationFieldDescriptor($generalMetadata, $doctrineMetadata->getType(), $options);
} elseif ($doctrineMetadata->getType() instanceof IdentityTypeMetadata) {
$fieldDescriptor = $this->getIdentityFieldDescriptor($generalMetadata, $doctrineMetadata->getType(), $options);
} elseif ($doctrineMetadata->getType() instanceof SingleTypeMetadata) {
$fieldDescriptor = $this->getFieldDescriptor($generalMetadata, $doctrineMetadata->getType()->getField(), $options);
} elseif ($doctrineMetadata->getType() instanceof CountTypeMetadata) {
$fieldDescriptor = $this->getCountFieldDescriptor($generalMetadata, $doctrineMetadata->getType()->getField());
} elseif ($doctrineMetadata->getType() instanceof CaseTypeMetadata) {
$fieldDescriptor = $this->getCaseFieldDescriptor($generalMetadata, $doctrineMetadata->getType(), $options);
}
if (null !== $fieldDescriptor && (!$type || is_a($fieldDescriptor, $type))) {
$fieldDescriptor->setMetadata($propertyMetadata);
$fieldDescriptors[$generalMetadata->getName()] = $fieldDescriptor;
}
}
$cache->write('<?php return unserialize(' . var_export(serialize($fieldDescriptors), true) . ');');
return $fieldDescriptors;
}
示例9: getGenerator
/**
* Gets the UrlGenerator instance associated with this Router.
*
* @return UrlGeneratorInterface A UrlGeneratorInterface instance
*/
public function getGenerator()
{
if (null !== $this->generator) {
return $this->generator;
}
if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
$this->generator = new $this->options['generator_class']($this->siteRepository, $this->currentSiteManager, $this->getRouteCollection(), $this->context, $this->requestStack, $this->nodeManager, $this->logger);
} else {
$class = $this->options['generator_cache_class'];
$cache = new ConfigCache($this->options['cache_dir'] . '/' . $class . '.php', $this->options['debug']);
if (!$cache->isFresh()) {
$dumper = $this->getGeneratorDumperInstance();
$options = array('class' => $class, 'base_class' => $this->options['generator_base_class']);
$cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
}
require_once $cache->getPath();
$this->generator = new $class($this->context, $this->requestStack, $this->nodeManager, $this->logger);
}
if ($this->generator instanceof ConfigurableRequirementsInterface) {
$this->generator->setStrictRequirements($this->options['strict_requirements']);
}
return $this->generator;
}
示例10: loadConfig
/**
* @return array
* @throws \Symfony\Component\Config\Exception\FileLoaderLoadException
*/
function loadConfig()
{
$configCachePath = __DIR__ . '/cache/appConfigCache.php';
$configCache = new ConfigCache($configCachePath, true);
$configBag = new ConfigBag(['configs' => []]);
if (!$configCache->isFresh()) {
$locator = new FileLocator([__DIR__ . '/config']);
$yamlLoader = new YamlConfigLoader($configBag, $locator);
$loaderResolver = new LoaderResolver([$yamlLoader]);
$delegatingLoader = new DelegatingLoader($loaderResolver);
$delegatingLoader->load('config.yml');
$delegatingLoader->load('config_extra.yml');
$resources = [new FileResource($locator->locate('config.yml', null, true)), new FileResource($locator->locate('config_extra.yml', null, true))];
$processor = new Processor();
$configuration = new AppConfiguration();
$processedConfig = $processor->processConfiguration($configuration, $configBag->get('configs'));
$configCache->write(json_encode($processedConfig), $resources);
} else {
$path = $configCache->getPath();
$processedConfig = json_decode(file_get_contents($path), true);
}
return $processedConfig;
}
示例11: dumpContainer
/**
* Dumps the service container to PHP code in the cache.
*
* @param ConfigCache $cache The config cache
* @param ContainerBuilder $container The service container
* @param string $class The name of the class to generate
* @param string $baseClass The name of the container's base class
*/
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
// cache the container
$dumper = new PhpDumper($container);
if (class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\PhpDumper\\ProxyDumper')) {
$dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
}
$content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
if (!$this->debug) {
$content = static::stripComments($content);
}
$cache->write($content, $container->getResources());
}
示例12: get_container
/**
* Build and return a new Container respecting the current configuration
*
* @return \phpbb_cache_container|ContainerBuilder
*/
public function get_container()
{
$container_filename = $this->get_container_filename();
$config_cache = new ConfigCache($container_filename, defined('DEBUG'));
if ($this->use_cache && $config_cache->isFresh()) {
require $config_cache->getPath();
$this->container = new \phpbb_cache_container();
} else {
$this->container_extensions = array(new extension\core($this->get_config_path()));
if ($this->use_extensions) {
$this->load_extensions();
}
// Inject the config
if ($this->config_php_file) {
$this->container_extensions[] = new extension\config($this->config_php_file);
}
$this->container = $this->create_container($this->container_extensions);
// Easy collections through tags
$this->container->addCompilerPass(new pass\collection_pass());
// Event listeners "phpBB style"
$this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
// Event listeners "Symfony style"
$this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
$filesystem = new filesystem();
$loader = new YamlFileLoader($this->container, new FileLocator($filesystem->realpath($this->get_config_path())));
$loader->load($this->container->getParameter('core.environment') . '/config.yml');
$this->inject_custom_parameters();
if ($this->compile_container) {
$this->container->compile();
if ($this->use_cache) {
$this->dump_container($config_cache);
}
}
}
if ($this->compile_container && $this->config_php_file) {
$this->container->set('config.php', $this->config_php_file);
}
return $this->container;
}
示例13: getWebspaceCollection
/**
* Returns all the webspaces managed by this specific instance.
*
* @return WebspaceCollection
*/
public function getWebspaceCollection()
{
if ($this->webspaceCollection === null) {
$class = $this->options['cache_class'];
$cache = new ConfigCache($this->options['cache_dir'] . '/' . $class . '.php', $this->options['debug']);
if (!$cache->isFresh()) {
$webspaceCollectionBuilder = new WebspaceCollectionBuilder($this->loader, $this->urlReplacer, $this->options['config_dir']);
$webspaceCollection = $webspaceCollectionBuilder->build();
$dumper = new PhpWebspaceCollectionDumper($webspaceCollection);
$cache->write($dumper->dump(['cache_class' => $class, 'base_class' => $this->options['base_class']]), $webspaceCollection->getResources());
}
require_once $cache->getPath();
$this->webspaceCollection = new $class();
}
return $this->webspaceCollection;
}
示例14: getMatcher
/**
* {@inheritDoc}
*
* Override default method to filter the RouteCollection BEFORE building the UrlMatcher
*/
public function getMatcher()
{
if (null !== $this->matcher) {
return $this->matcher;
}
if (null === $this->options['cache_dir'] || null === $this->options['matcher_cache_class']) {
return $this->matcher = new $this->options['matcher_class']($this->getCleanRouteCollection(), $this->context);
}
$class = $this->options['matcher_cache_class'];
$cache = new ConfigCache($this->options['cache_dir'] . '/' . $class . '.php', $this->options['debug']);
if (!$cache->isFresh()) {
$routeCollection = $this->getCleanRouteCollection();
$dumper = new $this->options['matcher_dumper_class']($routeCollection);
$options = ['class' => $class, 'base_class' => $this->options['matcher_base_class']];
$cache->write($dumper->dump($options), $routeCollection->getResources());
}
require_once $cache->getPath();
return $this->matcher = new $class($this->context);
}
示例15: loadContainer
private function loadContainer(ContainerConfiguration $config, ConfigCache $dump) : ContainerInterface
{
require_once $dump->getPath();
$className = '\\' . $config->getClassName();
return new $className();
}