示例#1
0
 /**
  * Returns the config of that name for the given output format.
  *
  * @param string $subject_name name of the renderer_config part
  * @param OutputFormatInterface $output_format output format the renderer name is part of
  * @param array $default_data initial values to use as renderer config; config will be merged over this
  *
  * @return ArrayConfig
  */
 public function getRendererConfig($subject_name, OutputFormatInterface $output_format, array $default_data = [])
 {
     if (!$this->output_formats || !$this->output_formats->has($output_format->getName())) {
         return new ArrayConfig($default_data);
     }
     $output_format_info = $this->output_formats->get($output_format->getName());
     if ($output_format_info && $output_format_info->has($subject_name)) {
         $settings = $output_format_info->get($subject_name);
         return new ArrayConfig(array_merge($default_data, $settings->toArray()));
     }
     return new ArrayConfig($default_data);
 }
示例#2
0
 protected function buildCacheKeyFor($subject, OutputFormatInterface $output_format, ConfigInterface $renderer_config)
 {
     // @todo this has to become way more sophisticated, maybe we could introduce an interface
     // so that objects could provide their own portion to the cache-key: ICacheKeySource.getCacheKey
     return sprintf('%s-%s-%s', $this->getSubjectName($subject), $output_format->getName(), $this->getHash($renderer_config->toArray()));
 }
示例#3
0
 /**
  * Returns whether there's a view template for the given scope and name. When an output format is
  * specified the method returns true when either an output format specific or the normal view
  * template name exists. When this method returns false the getViewTemplate will probably throw
  * an exception as there's no such view template to get.
  *
  * @param string $scope scope name of view template to check
  * @param string $name view template name
  * @param OutputFormatInterface $output_format output format
  *
  * @return boolean true if view template of that scope/name exists, false otherwise.
  */
 public function hasViewTemplate($scope, $view_template_name, OutputFormatInterface $output_format = null)
 {
     if (!$this->view_templates_container_map->hasKey($scope)) {
         return false;
     }
     $container = $this->view_templates_container_map->getItem($scope);
     // check for output format specific view template names if necessary
     if ($output_format !== null) {
         $specific_view_template_name = $view_template_name . '.' . $output_format->getName();
         return $container->getViewTemplateMap()->hasKey($specific_view_template_name) || $container->getViewTemplateMap()->hasKey($view_template_name);
     }
     return $container->getViewTemplateMap()->hasKey($view_template_name);
 }
示例#4
0
 public function __construct(OutputFormatInterface $output_format, LoggerInterface $logger)
 {
     $this->output_format = $output_format;
     $this->output_format_name = StringToolkit::asStudlyCaps($output_format->getName());
     $this->logger = $logger;
 }