eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver::getParameter PHP Метод

getParameter() публичный Метод

Returns value for $paramName, in $namespace.
public getParameter ( string $paramName, string $namespace = null, string $scope = null ) : mixed
$paramName string The parameter name, without $prefix and the current scope (i.e. siteaccess name).
$namespace string Namespace for the parameter name. If null, the default namespace will be used.
$scope string The scope you need $paramName value for. It's typically the siteaccess name. If null, the current siteaccess name will be used.
Результат mixed
    public function getParameter($paramName, $namespace = null, $scope = null)
    {
        $namespace = $namespace ?: $this->defaultNamespace;
        $scope = $scope ?: $this->defaultScope;
        $triedScopes = array();
        // Global scope
        $globalScopeParamName = "{$namespace}." . self::SCOPE_GLOBAL . ".{$paramName}";
        if ($this->container->hasParameter($globalScopeParamName)) {
            return $this->container->getParameter($globalScopeParamName);
        }
        $triedScopes[] = self::SCOPE_GLOBAL;
        unset($globalScopeParamName);
        // Relative scope, siteaccess wise
        $relativeScopeParamName = "{$namespace}.{$scope}.{$paramName}";
        if ($this->container->hasParameter($relativeScopeParamName)) {
            return $this->container->getParameter($relativeScopeParamName);
        }
        $triedScopes[] = $this->defaultScope;
        unset($relativeScopeParamName);
        // Relative scope, siteaccess group wise
        if (isset($this->groupsBySiteAccess[$scope])) {
            foreach ($this->groupsBySiteAccess[$scope] as $groupName) {
                $relativeScopeParamName = "{$namespace}.{$groupName}.{$paramName}";
                if ($this->container->hasParameter($relativeScopeParamName)) {
                    return $this->container->getParameter($relativeScopeParamName);
                }
            }
        }
        // Default scope
        $defaultScopeParamName = "{$namespace}." . self::SCOPE_DEFAULT . ".{$paramName}";
        if ($this->container->hasParameter($defaultScopeParamName)) {
            return $this->container->getParameter($defaultScopeParamName);
        }
        $triedScopes[] = $this->defaultNamespace;
        unset($defaultScopeParamName);
        // Undefined parameter
        switch ($this->undefinedStrategy) {
            case self::UNDEFINED_STRATEGY_NULL:
                return null;
            case self::UNDEFINED_STRATEGY_EXCEPTION:
            default:
                throw new ParameterNotFoundException($paramName, $namespace, $triedScopes);
        }
    }

Usage Example

 /**
  * Method for parsing ezimage field.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  *
  * @return string
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidVariationException
  * @throws \eZ\Publish\Core\MVC\Exception\SourceImageNotFoundException
  */
 public function ezimage(Field $field, Content $content)
 {
     if (!isset($field->value->id)) {
         return '';
     }
     $variations = $this->configResolver->getParameter('image_variations');
     $variation = 'original';
     $requestedVariation = $this->request->getCurrentRequest()->get('image');
     if (null !== $requestedVariation || in_array($requestedVariation, array_keys($variations))) {
         $variation = $requestedVariation;
     }
     try {
         return $this->imageVariationService->getVariation($field, $content->versionInfo, $variation)->uri;
     } catch (SourceImageNotFoundException $exception) {
         return '';
     }
 }
All Usage Examples Of eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver::getParameter