8000 [RFC] [Config] Use a Factory for ConfigCache instances by mpdude · Pull Request #7781 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC] [Config] Use a Factory for ConfigCache instances #7781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CS/convention fixes
  • Loading branch information
mpdude committed Nov 24, 2013
commit aaf541ec673841edd0c0b7b5f18f542fb1f1212d
37 changes: 21 additions & 16 deletions src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
< 10000 td class="blob-num blob-num-addition empty-cell">
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class Translator extends BaseTranslator
'debug' => false,
);
protected $loaderIds;
protected $configCacheFactory;

/**
* @var ConfigCacheFactoryInterface|null
*/
private $configCacheFactory;

/**
* Constructor.
Expand Down Expand Up @@ -73,21 +77,6 @@ public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFa
$this->configCacheFactory = $configCacheFactory;
}

/**
* Provides the ConfigCache factory implementation, falling back to a
* default implementation if necessary.
*
* @return ConfigCacheFactoryInterface $configCacheFactory
*/
private function getConfigCacheFactory()
{
if (!$this->configCacheFactory) {
$this->configCacheFactory = new DefaultConfigCacheFactory($this->options['debug']);
}

return $this->configCacheFactory;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -182,4 +171,20 @@ protected function initialize()
}
}
}

/**
* Provides the ConfigCache factory implementation, falling back to a
* default implementation if necessary.
*
* @return ConfigCacheFactoryInterface $configCacheFactory
*/
private function getConfigCacheFactory()
{
if (!$this->configCacheFactory) {
$this->configCacheFactory = new DefaultConfigCacheFactory($this->options['debug']);
}

return $this->configCacheFactory;
}

}
6 changes: 5 additions & 1 deletion src/Symfony/Component/Config/DefaultConfigCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public function __construct($debug)
public function cache($file, $callback)
{
$cache = new ConfigCache($file, $this->debug);
if (!$cache->isFresh()) call_user_func($callback, $cache);

if (!$cache->isFresh()) {
call_user_func($callback, $cache);
}

return $cache;
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Router implements RouterInterface, RequestMatcherInterface
/**
* @var ConfigCacheFactoryInterface|null
*/
protected $configCacheFactory;
private $configCacheFactory;

/**
* Constructor.
Expand Down Expand Up @@ -351,7 +351,7 @@ public function getMatcherDumperInstance()
*
* @return ConfigCacheFactoryInterface $configCacheFactory
*/
protected function getConfigCacheFactory()
private function getConfigCacheFactory()
{
if (null === $this->configCacheFactory) {
$this->configCacheFactory = new DefaultConfigCacheFactory($this->options['debug']);
Expand Down
0