public function getByProjectionType(ProjectionTypeInterface $projection_type) { $query_service_key = sprintf('%s::query_service', $projection_type->getVariantPrefix()); return $this->getItem($query_service_key); }
protected function getDbalComponentByProjection(ProjectionTypeInterface $projection_type, $projection_name, $component) { $component_key = sprintf('%s::projection.%s::view_store::%s', $projection_type->getPrefix(), $projection_name, $component); switch ($component) { case 'finder': return $this->getFinder($component_key); break; case 'reader': return $this->getStorageReader($component_key); break; case 'writer': return $this->getStorageWriter($component_key); break; } throw new RuntimeError(sprintf('Invalid dbal component given: %s. Supported components are: "finder", "reader" and "writer".', $component)); }
/** * Creates a ViewTemplate instance with one tab, one panel, one row, one list, one group and as many * fields as the resource type has attributes. To only include specific attributes as fields set * them in the attribute_names method argument. * * @param string $view_template_name name of the created view template * @param ProjectionTypeInterface $resource_type * @param array $attribute_names list of attributes to include as view template fields; if empty all * attributes will be included as fields * * @return ViewTemplateInterface instance with all or specified attributes as fields * * @throws RuntimeError in case of an empty view template name */ public function createViewTemplate($view_template_name, ProjectionTypeInterface $resource_type, array $attribute_names = []) { if (empty($view_template_name)) { throw new RuntimeError('A view template name must be specified.'); } $field_list = new FieldList(); foreach ($resource_type->getAttributes() as $attribute_name => $attribute) { if (empty($attribute_names)) { $field_list->addItem(new Field($attribute_name)); } elseif (in_array($attribute_name, $attribute_names)) { $field_list->addItem(new Field($attribute_name)); } } $group_list = new GroupList(); $group_list->addItem(new Group('group-content', $field_list)); $cell_list = new CellList(); $cell_list->addItem(new Cell($group_list)); $row_list = new RowList(); $row_list->addItem(new Row($cell_list)); $panel_list = new PanelList(); $panel_list->addItem(new Panel('panel-content', $row_list)); $tab_list = new TabList(); $tab_list->addItem(new Tab('tab-content', $panel_list)); $view_template = new ViewTemplate($view_template_name, $tab_list); return $view_template; }
protected function getDataAccessComponent(ProjectionTypeInterface $projection_type, $component = 'reader') { $default_component_name = sprintf('%s::view_store::%s', $projection_type->getVariantPrefix(), $component); $custom_component_option = $projection_type->getPrefix() . '.' . $component; switch ($component) { case 'finder': return $this->data_access_service->getFinder($this->config->get($custom_component_option, $default_component_name)); break; case 'reader': return $this->data_access_service->getStorageReader($this->config->get($custom_component_option, $default_component_name)); break; case 'writer': return $this->data_access_service->getStorageWriter($this->config->get($custom_component_option, $default_component_name)); break; } throw new RuntimeError('Invalid data access component name given: ' . $component); }