/**
  * Instantiates the class object
  *
  * @return NgSymfonyToolsApiContentConverter
  */
 public static function instance()
 {
     if (self::$instance === null) {
         $serviceContainer = ezpKernel::instance()->getServiceContainer();
         self::$instance = new self($serviceContainer->get('ezpublish.api.repository'));
     }
     return self::$instance;
 }
コード例 #2
0
 /**
  * Executes the template operator
  *
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param mixed $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  * @param mixed $placement
  */
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 {
     if (!is_string($namedParameters['name']) && empty($namedParameters['name'])) {
         $tpl->error($operatorName, "{$operatorName} parameter 'name' must be a non empty string.", $placement);
         return;
     }
     $templateName = $namedParameters['name'];
     if ($namedParameters['parameters'] !== null && !is_array($namedParameters['parameters'])) {
         $tpl->error($operatorName, "{$operatorName} parameter 'parameters' must be a hash array.", $placement);
         return;
     }
     $templateParameters = $namedParameters['parameters'] !== null ? $namedParameters['parameters'] : array();
     $apiContentConverter = NgSymfonyToolsApiContentConverter::instance();
     foreach ($templateParameters as $parameterName => $parameterValue) {
         $templateParameters[$parameterName] = $apiContentConverter->convert($parameterValue);
     }
     $serviceContainer = ezpKernel::instance()->getServiceContainer();
     $templatingEngine = $serviceContainer->get('templating');
     $operatorValue = $templatingEngine->render($templateName, $templateParameters);
 }
コード例 #3
0
 /**
  * Executes the template operator
  *
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param mixed $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  * @param mixed $placement
  */
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 {
     if (!is_string($namedParameters['controller']) || empty($namedParameters['controller'])) {
         $tpl->error($operatorName, "{$operatorName} parameter 'controller' must be a non empty string.", $placement);
         return;
     }
     $controller = $namedParameters['controller'];
     if ($namedParameters['attributes'] !== null && !is_array($namedParameters['attributes'])) {
         $tpl->error($operatorName, "{$operatorName} parameter 'attributes' must be a hash array.", $placement);
         return;
     }
     $attributes = $namedParameters['attributes'] !== null ? $namedParameters['attributes'] : array();
     if ($namedParameters['query'] !== null && !is_array($namedParameters['query'])) {
         $tpl->error($operatorName, "{$operatorName} parameter 'query' must be a hash array.", $placement);
         return;
     }
     $query = $namedParameters['query'] !== null ? $namedParameters['query'] : array();
     $apiContentConverter = NgSymfonyToolsApiContentConverter::instance();
     foreach ($attributes as $attributeName => $attributeValue) {
         $attributes[$attributeName] = $apiContentConverter->convert($attributeValue);
     }
     $operatorValue = self::getController($controller, $attributes, $query);
 }