logger->log(LogLevel::DEBUG, 'setRichSnippetConfig Entry point', $settings); $this->richSnippetConfig['tablename'] = $settings['ratetable']; $this->richSnippetConfig['richSnippetFields'] = $settings['richSnippetFields']; if (is_array($this->richSnippetConfig['richSnippetFields'])) { $this->logger->log( LogLevel::DEBUG, 'setRichSnippetConfig Exit point', $this->richSnippetConfig['richSnippetFields'] ); return true; } $this->logger->log(LogLevel::DEBUG, 'setRichSnippetConfig Exit point'); return false; } /** * @return string|false */ public function getRichSnippetConfig() { return GeneralUtility::makeInstance(\WapplerSystems\BookmarksLikesRatings\Service\JsonService::class) ->encodeToJson($this->richSnippetConfig); } /** * @return string */ public function getSchema(): string { return $this->schema; } /** * @param string|null $schema * @throws \WapplerSystems\BookmarksLikesRatings\Exception\InvalidAggregateRatingSchemaTypeException if parameter is invalid */ public function setSchema(?string $schema): void { if (!empty($schema)) { if (in_array($schema, self::VALID_AGGREGATE_RATING_SCHEMA_TYPES, true)) { $this->schema = $schema; } else { throw new \WapplerSystems\BookmarksLikesRatings\Exception\InvalidAggregateRatingSchemaTypeException( LocalizationUtility::translate( 'error.richSnippetConfiguration.AggregateRatingPropertySchema', 'ThRating' ), 1521487362 ); } } } /** * @return string */ public function getAnchor(): string { return $this->anchor; } /** * @param string $anchor */ public function setAnchor(string $anchor): void { $this->anchor = $anchor; } /** * @param string|null $name */ public function setName(?string $name): void { $this->name = $name; } /** * @return string|null */ public function getName(): ?string { return $this->name; } /** * @return string|null */ public function getDescription(): ?string { return $this->description; } /** * @param string|null $description */ public function setDescription(?string $description): void { $this->description = $description; } /** * @param int $uid * @return RichSnippetService *@throws \WapplerSystems\BookmarksLikesRatings\Exception\InvalidAggregateRatingSchemaTypeException */ public function getRichSnippetObject(int $uid): self { $this->logger->log(LogLevel::DEBUG, 'getRichSnippetObject Entry point'); $this->setSchema($this->richSnippetConfig['richSnippetFields']['aggregateRatingSchemaType']); if (empty($this->richSnippetConfig['richSnippetFields']['name'])) { $this->logger->log(LogLevel::INFO, 'No name field defined - skipping database access'); unset($this->name, $this->description); throw new \TYPO3\CMS\Core\Exception(); } else { /** @var QueryBuilder $queryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($this->richSnippetConfig['tablename']); //fetch whole row from database /** @var array $row */ $row = $queryBuilder ->select('*') ->from($this->richSnippetConfig['tablename']) ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid))) ->execute() ->fetch(); $this->logger->log(LogLevel::DEBUG, 'Data fetched', $row); $this->setName($row[$this->richSnippetConfig['richSnippetFields']['name']]); $contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); $this->setDescription($row[$this->richSnippetConfig['richSnippetFields']['description']]); //$this->setDescription($contentObjectRenderer->cObjGetSingle('TEXT', $this->richSnippetConfig['richSnippetFields']['description'])); //$this->setDescription($contentObjectRenderer->render($this->richSnippetConfig['richSnippetFields']['description'])); } $this->logger->log(LogLevel::DEBUG, 'getRichSnippetObject Exit point', (array)$this); return $this; } }