returns structure.
public getStructure ( ) : Sulu\Component\Content\Compat\StructureInterface | ||
Результат | Sulu\Component\Content\Compat\StructureInterface |
protected function setUp() { parent::setUp(); $this->contactManager = $this->prophesize(ContactManagerInterface::class); $this->accountManager = $this->prophesize(ContactManagerInterface::class); $this->node = $this->prophesize(Node::class); $this->property = $this->prophesize(PropertyInterface::class); $this->structure = $this->prophesize(StructureInterface::class); $this->structure->getLanguageCode()->willReturn($this->locale); $this->structure->getWebspaceKey()->willReturn($this->webspaceKey); $this->property->getStructure()->willReturn($this->structure->reveal()); $this->serializer = $this->prophesize(Serializer::class); }
/** * {@inheritdoc} */ public function getContentData(PropertyInterface $property) { $ids = $property->getValue(); if (!is_array($ids) || empty($ids)) { return []; } $data = []; $categoryEntities = $this->categoryManager->findByIds($ids); $categoryApiEntities = $this->categoryManager->getApiObjects($categoryEntities, $property->getStructure()->getLanguageCode()); foreach ($categoryApiEntities as $category) { $data[] = $category->toArray(); } return $data; }
/** * {@inheritdoc} */ public function getContentData(PropertyInterface $property) { $structure = $property->getStructure(); $webspaceKey = $structure->getWebspaceKey(); $locale = $structure->getLanguageCode(); $shadowLocale = null; if ($structure->getIsShadow()) { $shadowLocale = $structure->getShadowBaseLanguage(); } $refs = $property->getValue(); $ids = $this->getUuids($refs); $contentData = []; foreach ($this->loadSnippets($ids, $webspaceKey, $locale, $shadowLocale) as $snippet) { $contentData[] = $snippet['content']; } return $contentData; }
/** * {@inheritdoc. */ public function getStructure() { return $this->property->getStructure(); }
/** * {@inheritdoc} */ public function getContentData(PropertyInterface $property) { $value = $property->getValue(); $locale = $property->getStructure()->getLanguageCode(); if ($value === null || !is_array($value) || count($value) === 0) { return []; } $ids = $this->converter->convertIdsToGroupedIds($value, ['a' => [], 'c' => []]); $accounts = $this->accountManager->getByIds($ids['a'], $locale); $contacts = $this->contactManager->getByIds($ids['c'], $locale); $result = array_merge($accounts, $contacts); @usort($result, function ($a, $b) use($value) { $typeA = $a instanceof Contact ? 'c' : 'a'; $typeB = $b instanceof Contact ? 'c' : 'a'; return $this->comparator->compare($typeA . $a->getId(), $typeB . $b->getId(), $value); }); return array_map(function ($entity) { $groups = ['fullContact', 'partialAccount']; if ($entity instanceof Account) { $groups = ['fullAccount', 'partialContact']; } return $this->serializer->serialize($entity, 'array', SerializationContext::create()->setGroups($groups)->setSerializeNull(true)); }, $result); }
/** * {@inheritDoc} */ public function getContentData(PropertyInterface $property) { $data = $property->getValue(); $params = $this->getParams($property->getParams()); $types = $params['types']->getValue(); $container = new MediaSelectionContainer(isset($data['config']) ? $data['config'] : [], isset($data['displayOption']) ? $data['displayOption'] : '', isset($data['ids']) ? $data['ids'] : [], $property->getStructure()->getLanguageCode(), $types, $this->mediaManager); return $container->getData(); }
/** * {@inheritdoc} */ public function getContentData(PropertyInterface $property) { $data = $property->getValue(); $container = new InternalLinksContainer(isset($data) ? $data : [], $this->contentQueryExecutor, $this->contentQueryBuilder, array_merge($this->getDefaultParams(), $property->getParams()), $this->logger, $property->getStructure()->getWebspaceKey(), $property->getStructure()->getLanguageCode(), $this->showDrafts); return $container->getData(); }
/** * load data from container. * * @param SmartContentContainer $container * @param PropertyInterface $property * @param PropertyParameter[] $params * * @return array|\Sulu\Component\Content\Compat\StructureInterface[] */ private function loadData(SmartContentContainer $container, PropertyInterface $property, $params) { if (isset($params['max_per_page'])) { // determine current page $container->setPage($this->getCurrentPage($params['page_parameter']->getValue())); $contentData = $this->getPagedContentData($container, $container->getPage(), intval($params['max_per_page']->getValue()), $property->getStructure()->getUuid()); } else { // set default values $container->setPage(1); $container->setHasNextPage(false); $contentData = $this->getNotPagedContentData($container, $property->getStructure()->getUuid()); } return $contentData; }
/** * Returns snippets with given property value. */ private function getSnippets(PropertyInterface $property) { /** @var PageBridge $page */ $page = $property->getStructure(); $webspaceKey = $page->getWebspaceKey(); $locale = $page->getLanguageCode(); $shadowLocale = null; if ($page->getIsShadow()) { $shadowLocale = $page->getShadowBaseLanguage(); } $refs = $property->getValue(); $ids = $this->getUuids($refs); $snippetType = $this->getParameterValue($property->getParams(), 'snippetType'); $default = $this->getParameterValue($property->getParams(), 'default', false); if (empty($ids) && $snippetType && $default && $this->defaultEnabled) { $ids = [$this->defaultSnippetManager->loadIdentifier($webspaceKey, $snippetType)]; // to filter null default snippet $ids = array_filter($ids); } return $this->snippetResolver->resolve($ids, $webspaceKey, $locale, $shadowLocale); }