Exemplo n.º 1
0
 /**
  * Build parameter cache block
  *
  * @return string Parameter cache block
  */
 public function buildParameterCacheBlock()
 {
     $parameters = array();
     $this->parameterDefinitionChain->each(function (ParameterDefinition $parameterDefinition) use(&$parameters) {
         $parameters[$parameterDefinition->getName()] = $parameterDefinition->getValue();
     });
     $parametersExported = var_export($parameters, true);
     $cacheContent = "/**\n     * @var array\n     *\n     * parameters\n     */\n    private \$parameters = {$parametersExported};\n\n    ";
     return $cacheContent;
 }
Exemplo n.º 2
0
 /**
  * Get parameter value
  *
  * @param string $parameterName Parameter Name
  *
  * @return mixed Parameter value
  *
  * @throws DoppoNotCompiledException        Container not compiled yet
  * @throws DoppoParameterNotExistsException Parameter not found
  */
 public function getParameter($parameterName)
 {
     if (!$this->compiled) {
         throw new DoppoNotCompiledException('Container should be compiled before being used');
     }
     if (!$this->parameters->has($parameterName)) {
         throw new DoppoParameterNotExistsException(sprintf('Parameter "%s" not found', $parameterName));
     }
     return $this->parameters->get($parameterName)->getValue();
 }