public function get($configurationIdentifier, $defaultValue = null)
    {
        /**
         * Checks if the value is defined in the configuration elements.
         */
        if (!array_key_exists($configurationIdentifier, $this->configurationElements)) {
            if (!is_null($defaultValue)) {
                return $defaultValue;
            }

            throw new ConfigurationParameterNotFoundException();
        }

        $valueIsCached = $this
            ->cache
            ->contains($configurationIdentifier);

        /**
         * The value is cached, so we can securely return its value.
         * We must unserialize the value if needed.
         */
        if (false !== $valueIsCached) {
            return $this
                ->cache
                ->fetch($configurationIdentifier);
        }
        list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier);

        $configurationLoaded = $this->loadConfiguration(
            $configurationNamespace,
            $configurationKey
        );

        if (!($configurationLoaded instanceof ConfigurationInterface)) {
            $configurationElement = $this->configurationElements[$configurationIdentifier];
            $configurationValue = isset($configurationElement['reference'])
                ? $this->parameterBag->get($configurationElement['reference'])
                : $configurationElement['default_value'];

            if (empty($configurationValue) && !$configurationElement['can_be_empty']) {
                $message = $configurationElement['empty_message']
                    ?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved';

                throw new Exception($message);
            }

            $configurationLoaded = $this
                ->createConfigurationInstance(
                    $configurationIdentifier,
                    $configurationNamespace,
                    $configurationKey,
                    $configurationValue
                );

            $this->flushConfiguration($configurationLoaded);
        }

        $configurationValueUnserialized = $this->flushConfigurationToCache(
            $configurationLoaded,
            $configurationIdentifier
        );

        return $configurationValueUnserialized;
    }
public function get($configurationIdentifier, $defaultValue = null)
    {
        /**
         * Checks if the value is defined in the configuration elements.
         */
        if (!array_key_exists($configurationIdentifier, $this->configurationElements)) {
            if (!is_null($defaultValue)) {
                return $defaultValue;
            }

            throw new ConfigurationParameterNotFoundException();
        }

        $valueIsCached = $this
            ->cache
            ->contains($configurationIdentifier);

        /**
         * The value is cached, so we can securely return its value.
         * We must unserialize the value if needed.
         */
        if (false !== $valueIsCached) {
            return $this
                ->cache
                ->fetch($configurationIdentifier);
        }
        list($configurationNamespace, $configurationKey) = $this->splitConfigurationKey($configurationIdentifier);

        $configurationLoaded = $this->loadConfiguration(
            $configurationNamespace,
            $configurationKey
        );

        if (!($configurationLoaded instanceof ConfigurationInterface)) {
            $configurationElement = $this->configurationElements[$configurationIdentifier];
            $configurationValue = isset($configurationElement['reference'])
                ? $this->parameterBag->get($configurationElement['reference'])
                : $configurationElement['default_value'];

            if (empty($configurationValue) && !$configurationElement['can_be_empty']) {
                $message = $configurationElement['empty_message']
                    ?: 'The configuration element "' . $configurationIdentifier . '" cannot be resolved';

                throw new Exception($message);
            }

            $configurationLoaded = $this
                ->createConfigurationInstance(
                    $configurationIdentifier,
                    $configurationNamespace,
                    $configurationKey,
                    $configurationValue
                );

            $this->flushConfiguration($configurationLoaded);
        }

        $configurationValueUnserialized = $this->flushConfigurationToCache(
            $configurationLoaded,
            $configurationIdentifier
        );

        return $configurationValueUnserialized;
    }
public function get ( $ configurationIdentifier , $ defaultValue = null ) { /**
         * Checks if the value is defined in the configuration elements.
         */ if ( ! array_key_exists ( $ configurationIdentifier , $ this -> configurationElements ) ) { if ( ! is_null ( $ defaultValue ) ) { return $ defaultValue ; } throw new ConfigurationParameterNotFoundException ( ) ; } $ valueIsCached = $ this -> cache -> contains ( $ configurationIdentifier ) ; /**
         * The value is cached, so we can securely return its value.
         * We must unserialize the value if needed.
         */ if ( false !== $ valueIsCached ) { return $ this -> cache -> fetch ( $ configurationIdentifier ) ; } list ( $ configurationNamespace , $ configurationKey ) = $ this -> splitConfigurationKey ( $ configurationIdentifier ) ; $ configurationLoaded = $ this -> loadConfiguration ( $ configurationNamespace , $ configurationKey ) ; if ( ! ( $ configurationLoaded instanceof ConfigurationInterface ) ) { $ configurationElement = $ this -> configurationElements [ $ configurationIdentifier ] ; $ configurationValue = isset ( $ configurationElement [ 'reference' ] ) ? $ this -> parameterBag -> get ( $ configurationElement [ 'reference' ] ) : $ configurationElement [ 'default_value' ] ; if ( empty ( $ configurationValue ) && ! $ configurationElement [ 'can_be_empty' ] ) { $ message = $ configurationElement [ 'empty_message' ] ? : 'The configuration element "' . $ configurationIdentifier . '" cannot be resolved' ; throw new Exception ( $ message ) ; } $ configurationLoaded = $ this -> createConfigurationInstance ( $ configurationIdentifier , $ configurationNamespace , $ configurationKey , $ configurationValue ) ; $ this -> flushConfiguration ( $ configurationLoaded ) ; } $ configurationValueUnserialized = $ this -> flushConfigurationToCache ( $ configurationLoaded , $ configurationIdentifier ) ; return $ configurationValueUnserialized ; }
Loads a parameter given the format "namespace.key".

@param string      $configurationIdentifier Configuration identifier
@param string|null $defaultValue            Default value

@return null|string|bool Configuration parameter value

@throws ConfigurationParameterNotFoundException Configuration parameter not found
@throws Exception                               Configuration cannot be resolved
Loads a parameter given the format namespace . key .