/** * Process content object data * * @param ContentObjectRenderer $cObj The data of the content element or page * @param array $contentObjectConfiguration The configuration of Content Object * @param array $processorConfiguration The configuration of this processor * @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View) * @return array the processed data as key/value store */ public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData) { $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->factory = $this->objectManager->get(Typo3PagesFactory::class); $processedData['currentPage'] = $this->factory->createFromAssociativeArray($cObj->data); return $processedData; }
/** * Renders the view * * @return string The rendered view * @api */ public function render() { $this->contentObjectRenderer->start($this->variables['data'], 'pages'); $this->settings = $this->variables['settings']; $this->page = $this->factory->createFromAssociativeArray($this->variables['data']); $data = ['@context' => ['@vocab' => 'https://schema.org/'], '@type' => 'BlogPosting', '@id' => $this->getGlobalIdentifier(), 'dateModified' => $this->page->getLastUpdatedAt()->format('Y-m-d'), 'datePublished' => $this->page->getCreatedAt()->format('Y-m-d'), 'author' => $this->getAuthor(), 'publisher' => $this->getPublisher(), 'headline' => $this->page->getTitle(), 'description' => strip_tags($this->page->getAbstract()), 'keywords' => $this->page->getKeywords(), 'mainEntityOfPage' => ['@id' => $this->getGlobalIdentifier()]]; $teaserImage = $this->page->getTeaserImage(); if (!is_null($teaserImage)) { $data['image'] = ['@type' => 'ImageObject', 'url' => '/' . $teaserImage->getValue(), 'width' => '546', 'height' => '171']; } return json_encode($data, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); }
/** * Hydrates the given raw results * * @param array $rawResults Raw result list * * @return Page[] */ private function hydrate(array $rawResults) { $pages = []; array_walk($rawResults, function ($rawResult) use(&$pages) { $pages[] = $this->factory->createFromAssociativeArray($rawResult); }); return $pages; }