Skip to content

Commit

Permalink
Merge pull request #57 from Runroom/hotfix/doctrine
Browse files Browse the repository at this point in the history
Avoid using Join::WITH
  • Loading branch information
jordisala1991 committed Nov 24, 2023
2 parents 75aae87 + 9f22364 commit 5530fcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/BasicEntities/Entity/BookTranslation.php
Expand Up @@ -27,14 +27,6 @@ class BookTranslation implements TranslationInterface
{
use TranslationTrait;

/**
* @var string|null
*
* This property is needed to do the Join::WITH on the BookRepository
*/
#[ORM\Column(type: Types::STRING, length: 5)]
protected $locale;

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
Expand Down
6 changes: 3 additions & 3 deletions src/BasicEntities/Repository/BookRepository.php
Expand Up @@ -14,7 +14,6 @@
namespace Runroom\SamplesBundle\BasicEntities\Repository;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\Persistence\ManagerRegistry;
use Runroom\SamplesBundle\BasicEntities\Entity\Book;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -41,8 +40,9 @@ public function findBySlug(string $slug): Book
$request = $this->requestStack->getCurrentRequest() ?? new Request();

$query = $this->createQueryBuilder('book')
->leftJoin('book.translations', 'translations', Join::WITH, 'translations.locale = :locale')
->where('translations.slug = :slug')
->leftJoin('book.translations', 'translations')
->where('translations.locale = :locale')
->andWhere('translations.slug = :slug')
->andWhere('book.publish = true')
->setParameter('slug', $slug)
->setParameter('locale', $request->getLocale())
Expand Down

0 comments on commit 5530fcf

Please sign in to comment.