extensionHelperService = $extensionHelperService; } /** * Finds the specific rating by giving the object and row uid * * @Extbase\Validate("\WapplerSystems\BookmarksLikesRatings\Domain\Validator\RatingobjectValidator", param="ratingobject") * @param \WapplerSystems\BookmarksLikesRatings\Domain\Model\Ratingobject $ratingobject The concerned ratingobject * @Extbase\Validate("NumberRange", options={"minimum": 1}, param="ratedobjectuid") * @param int $ratedobjectuid The Uid of the rated row * @param bool $addIfNotFound Set to true if new objects should instantly be added * @return Rating * @throws IllegalObjectTypeException */ public function findMatchingObjectAndUid( Ratingobject $ratingobject, int $ratedobjectuid, $addIfNotFound = false ): Rating { /** @var \WapplerSystems\BookmarksLikesRatings\Domain\Model\Rating $foundRow */ $foundRow = $this->objectManager->get(Rating::class); $query = $this->createQuery(); $query->matching($query->logicalAnd( [ $query->equals('ratingobject', $ratingobject->getUid()), $query->equals('ratedobjectuid', $ratedobjectuid) ] ))->setLimit(1); /*$queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getSQL(), get_class($this).' SQL'); \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getParameters(), get_class($this).' SQL Parameter');*/ $queryResult = $query->execute(); if ($queryResult->count() > 0) { $foundRow = $queryResult->getFirst(); } elseif ($addIfNotFound) { $foundRow->setRatingobject($ratingobject); $foundRow->setRatedobjectuid($ratedobjectuid); $validator = $this->objectManager->get(RatingValidator::class); if (!$validator->validate($foundRow)->hasErrors()) { $this->add($foundRow); } $this->extensionHelperService->persistRepository(__CLASS__, $foundRow); $foundRow = $this->findMatchingObjectAndUid($ratingobject, $ratedobjectuid); } return $foundRow; } }