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; }
protected function getTemplateParameters() { $params = parent::getTemplateParameters(); $activity = $this->getPayload('subject'); $params['activity'] = $activity->toArray(); $activity_name = $activity->getName(); if (empty($params['activity']['label'])) { $params['activity']['label'] = sprintf('%s.label', $activity_name); } if (empty($params['activity']['description'])) { $params['activity']['description'] = sprintf('%s.description', $activity_name); } // translate label/description of workflow event transition per resource state $params['activity_label'] = $this->_($params['activity']['label']); $params['activity_description'] = $this->_($params['activity']['description']); if ($this->hasPayload('resource')) { $workflow_state = $this->getPayload('resource')->getWorkflowState(); $translation_key = $workflow_state . '.' . $params['activity']['label']; $translation = $this->_($translation_key); if ($translation !== $translation_key) { $params['activity_label'] = $translation; } $translation_key = $workflow_state . '.' . $params['activity']['description']; $translation = $this->_($translation_key); if ($translation !== $translation_key) { $params['activity_description'] = $translation; } } $params['link'] = $this->getLinkFor($activity); if ($activity->getVerb() === 'write' && $this->hasPayload('resource')) { $revision = $this->getPayload('resource')->getRevision(); $params['form_parameters'] = ['revision' => $revision]; } return $params; }
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; }
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; }
protected function getTemplateParameters() { $params = parent::getTemplateParameters(); $attribute_name = $this->attribute->getName(); $attribute_path = $this->attribute->getPath(); $field_name = $this->getOption('field_name', $attribute_name); $params['field_id'] = 'randomId-' . rand(); // @todo still random but nicer ids? $params['field_name'] = $field_name; $params['grouped_field_name'] = $this->getGroupedInputFieldName(); $params['grouped_base_path'] = $this->getGroupedInputFieldName(); $params['attribute_name'] = $attribute_name; $params['attribute_path'] = $attribute_path; $params['attribute_value'] = $this->determineAttributeValue($attribute_name); $params['attribute_value_is_null_value'] = is_null($params['attribute_value']); $params['is_embedded'] = $this->getOption('is_within_embed_template', false); return $params; }
protected function getTemplateParameters() { $params = parent::getTemplateParameters(); $pagination = $this->getPayload('subject'); $params = array_merge($params, $pagination->toArray()); $current_page_url = $this->url_generator->generateUrl(null); $current_url_parameters = ArrayToolkit::getUrlQueryInRequestFormat($current_page_url); unset($current_url_parameters['offset']); // offset is not needed when page is used (see validator) $url_parameters = (array) $this->getOption('url_parameters', []); $url_parameters = array_merge($current_url_parameters, $url_parameters); // we add all query parameters of the current URL as hidden GET form inputs to not lose any state on submit $params['url_parameters'] = $url_parameters; $params['current_page_url'] = $this->url_generator->generateUrl(null, $url_parameters); $params['first_page_url'] = $this->url_generator->generateUrl(null, array_merge($url_parameters, ['offset' => 0])); $params['last_page_url'] = $this->url_generator->generateUrl(null, array_merge($url_parameters, ['offset' => $pagination->getLastPageOffset()])); $params['next_page_url'] = $this->url_generator->generateUrl(null, array_merge($url_parameters, ['offset' => $pagination->getNextPageOffset()])); $params['prev_page_url'] = $this->url_generator->generateUrl(null, array_merge($url_parameters, ['offset' => $pagination->getPrevPageOffset()])); $params['number_of_pages'] = $pagination->getNumberOfPages(); return $params; }
protected function getTemplateParameters() { $params = parent::getTemplateParameters(); $params['navigation_data'] = $this->prepareNavigationData($this->getPayload('subject')); return $params; }