Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/ConfigResolver.php b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/ConfigResolver.php
- index 9b1e713e7..ff3443e41 100644
- --- a/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/ConfigResolver.php
- +++ b/eZ/Bundle/EzPublishCoreBundle/DependencyInjection/Configuration/ConfigResolver.php
- @@ -14,6 +14,7 @@ use eZ\Publish\Core\MVC\Symfony\SiteAccess\SiteAccessAware;
- use eZ\Publish\Core\MVC\Exception\ParameterNotFoundException;
- use Symfony\Component\DependencyInjection\ContainerAwareInterface;
- use Symfony\Component\DependencyInjection\ContainerAwareTrait;
- +use Symfony\Component\DependencyInjection\ContainerBuilder;
- /**
- * This class will help you get settings for a specific scope.
- @@ -165,6 +166,10 @@ class ConfigResolver implements VersatileScopeInterface, SiteAccessAware, Contai
- */
- public function getParameter($paramName, $namespace = null, $scope = null)
- {
- + if (!$this->container instanceof ContainerBuilder && $this->siteAccess->matchingType === 'uninitialized') {
- + $this->triggerEarlyUseError($paramName);
- + }
- +
- $namespace = $namespace ?: $this->defaultNamespace;
- $scope = $scope ?: $this->getDefaultScope();
- $triedScopes = array();
- @@ -214,6 +219,43 @@ class ConfigResolver implements VersatileScopeInterface, SiteAccessAware, Contai
- }
- }
- + private function triggerEarlyUseError($paramName)
- + {
- + // Try to extract service name of service asking for this parameter
- + $service = '??';
- + foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 9) as $t) {
- + if (!isset($t['function']) || $t['function'] === 'getParameter' || $t['function'] === __FUNCTION__) {
- + continue;
- + }
- +
- + // We can only really reverse engineer traditional service name, namspace is stripped from autowired / class name based services
- + if (strpos($t['function'], 'get') === 0 && strpos($t['function'], 'Service') === strlen($t['function']) -7) {
- + $serviceName = strtolower(preg_replace('/\B([A-Z])/', '_$1', str_replace('_', '.', substr($t['function'], 3, -7))));
- + if ($this->container->has($serviceName)) {
- + $service = $serviceName;
- + } else {
- + $service = '->' . $t['function'] . '()';
- + }
- + break;
- + }
- + }
- +
- + // Error breaks loading of services, & commands that depend on them
- + // Also this is so early in request warning/deprecated/logger does not show up anywhere
- + /*@trigger_error(
- + sprintf(
- + 'ConfigResolver was used by "%s" to read "%s" parameter before SiteAccess was loaded. This should be avoided, '
- + . (PHP_SAPI == 'cli' ? 'make sure your commands are lazy loaded, ' : '')
- + . 'if nothing else helps make sure the service is marked as lazy.',
- + $service,
- + $paramName
- + );
- + E_USER_ERROR
- + );*/
- +
- + echo "Parameter '$paramName' was loaded by '$service' service\n";
- + }
- +
- /**
- * Changes the default namespace to look parameter into.
- *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement