コード例 #1
0
 protected function getTemplateParameters()
 {
     $params = parent::getTemplateParameters();
     $params['html_attributes'] = $this->getOption('html_attributes', []);
     $params['field_name'] = $this->getOption('field_name', 'Missing "field_name" setting.');
     if ($this->hasOption('expression')) {
         $payload = [];
         foreach ($this->payload as $key => $val) {
             $payload[$key] = $val;
         }
         $params['field_value'] = $this->expression_service->evaluate($this->getOption('expression'), $payload);
     } else {
         $params['field_value'] = $this->getOption('field_value', 'Missing "field_value" or "expression" setting.');
     }
     if ($this->hasPayload('activity')) {
         $activity = $this->getPayload('activity')->toArray();
         $params['activity'] = $activity;
         $params['rendered_activity'] = $this->renderer_service->renderSubject($activity, $this->output_format, $this->config, [], $this->settings);
     }
     if ($this->hasPayload('resource')) {
         $params['resource'] = $this->getPayload('resource')->toArray();
     }
     $params['css'] = (string) $this->getOption('css', '');
     return $params;
 }
コード例 #2
0
 protected function getTemplateParameters()
 {
     $entity = $this->getPayload('subject');
     $group_parts = (array) $this->getOption('group_parts', []);
     $parent_attribute = $entity->getType()->getParentAttribute();
     $params = parent::getTemplateParameters();
     $params['has_parent_attribute'] = $parent_attribute !== null;
     $params['grouped_base_path'] = ArrayToolkit::flattenToArrayPath($group_parts);
     $params['resource'] = $entity->toArray();
     $params['entity_type'] = $entity->getType()->getPrefix();
     $params['is_embed_template'] = $this->getOption('is_embed_template', false);
     $params['is_new'] = !$entity->hasValue('identifier');
     // when entity is part of a list (embed or reference)
     $params['add_item_to_parent_list_allowed'] = $this->getOption('add_item_to_parent_list_allowed', true);
     // custom title+decription per-embedded-item in an EntityList attribute
     if (!$entity->getType()->isRoot()) {
         $params['embed_item_title'] = $this->getOption('entity_title', 'entity_title');
         $params['embed_item_description'] = $this->getOption('entity_description', 'entity_description');
     }
     $params = array_replace_recursive($this->lookupViewTemplate(), $params);
     $params['rendered_fields'] = $this->getRenderedFields($entity, $params['view_template']);
     if ($entity instanceof ProjectionInterface && $entity->getWorkflowState()) {
         $params['rendered_resource_activities'] = $this->getResourceActivities($entity);
     }
     return $params;
 }
コード例 #3
0
 /**
  * Default translation domain for activity maps follows this fallback sequence:
  *  - 'view_scope' option
  *  - application translation domain
  *
  * To override with a custom value pass to the renderer the 'translation_domain' option
  */
 protected function getDefaultTranslationDomain()
 {
     $view_scope = $this->getOption('view_scope');
     if (empty($view_scope)) {
         $translation_domain_prefix = parent::getDefaultTranslationDomain();
     } else {
         // convention on view_scope value: the first 3 parts = vendor.package.resource_type
         $view_scope_parts = explode('.', $view_scope);
         $translation_domain_prefix = implode('.', array_slice($view_scope_parts, 0, 3));
     }
     $translation_domain = sprintf('%s.%s', $translation_domain_prefix, self::STATIC_TRANSLATION_PATH);
     return $translation_domain;
 }
コード例 #4
0
 protected function getTemplateParameters()
 {
     $params = parent::getTemplateParameters();
     $resource_collection = $this->getPayload('subject');
     $scope = $this->getOption('view_scope', 'default.collection');
     $default_data = ['view_scope' => $scope];
     $rendered_resources = [];
     foreach ($resource_collection as $resource) {
         $renderer_config = $this->view_config_service->getRendererConfig($scope, $this->output_format, $resource, $default_data);
         $rendered_resources[] = $this->renderer_service->renderSubject($resource, $this->output_format, $renderer_config, [], $this->settings);
     }
     $params['rendered_resources'] = $rendered_resources;
     $view_template_name = $this->getOption('view_template_name', 'default.collection');
     if (!$this->hasOption('view_template_name')) {
         $view_template_name = $this->name_resolver->resolve($resource_collection);
     }
     $params['header_fields'] = $this->getOption('header_fields', []);
     if (!$this->hasOption('header_fields')) {
         /*
          * Header fields are not necessary in all cases, but are used if a table like display is used.
          * The header may be given as renderer config or render settings or they will be taken from a
          * specific header_fields view template or the view template for the first resource of the list.
          *
          * This flexibility is necessary to support cases of a table with header fields and different
          * resource types in the actual resource collection (like a search returning docs of different types).
          */
         $hfvtn = $view_template_name . '.header_fields';
         if ($this->view_template_service->hasViewTemplate($scope, $hfvtn, $this->output_format)) {
             $view_template = $this->view_template_service->getViewTemplate($scope, $hfvtn, $this->output_format);
             $params['header_fields'] = $view_template->extractAllFields();
         } elseif (!$resource_collection->isEmpty() && !$resource_collection->containsMultipleTypes()) {
             $resource = $resource_collection->getFirst();
             $vtn = $this->name_resolver->resolve($resource);
             if ($this->view_template_service->hasViewTemplate($scope, $vtn, $this->output_format)) {
                 $view_template = $this->view_template_service->getViewTemplate($scope, $vtn, $this->output_format);
                 $params['header_fields'] = $view_template->extractAllFields();
             }
         } else {
             /*
              * when resource_collection is not empty and contains multiple types we could throw an exception
              * to force devs to specify header_fields when the twig template uses them?
              */
             $params['header_fields'] = [];
         }
     }
     return $params;
 }
コード例 #5
0
 protected function getDefaultTranslationDomain()
 {
     return sprintf('%s.pagination', parent::getDefaultTranslationDomain());
 }
コード例 #6
0
 protected function getDefaultTranslationKeys()
 {
     $default_translation_keys = parent::getDefaultTranslationKeys();
     // will be available as "translations.input_help" in the twig template while the actual
     // translation key lookup will be for "field_name.input_help" in the "…fields" translation_domain
     $field_translation_keys = ['input_help', 'input_hint', 'input_focus_hint', 'placeholder', 'title'];
     return array_replace($default_translation_keys, $field_translation_keys);
 }
コード例 #7
0
 protected function getDefaultTranslationDomain()
 {
     return sprintf('%s.%s', parent::getDefaultTranslationDomain(), self::STATIC_TRANSLATION_PATH);
 }