diff --git a/old/src/PointToolsBundle/Entity/Blogs/Tag.php b/old/src/PointToolsBundle/Entity/Blogs/Tag.php deleted file mode 100644 index d5746fc..0000000 --- a/old/src/PointToolsBundle/Entity/Blogs/Tag.php +++ /dev/null @@ -1,44 +0,0 @@ -text = $text; - } - - public function getId(): int - { - return $this->id; - } - - public function getText(): string - { - return $this->text; - } -} diff --git a/old/src/PointToolsBundle/Repository/Blogs/TagRepository.php b/old/src/PointToolsBundle/Repository/Blogs/TagRepository.php deleted file mode 100644 index 6661aeb..0000000 --- a/old/src/PointToolsBundle/Repository/Blogs/TagRepository.php +++ /dev/null @@ -1,25 +0,0 @@ -getEntityManager()->persist($entity); - } - - public function findOneByLowerText(string $text): ?Tag - { - $qb = $this->createQueryBuilder('t'); - return $qb - ->where('LOWER(t.text) = :text') - ->setParameter('text', mb_strtolower($text)) - ->getQuery()->getOneOrNullResult() - ; - } -} \ No newline at end of file diff --git a/src/Entity/Blog/Tag.php b/src/Entity/Blog/Tag.php new file mode 100644 index 0000000..2181a58 --- /dev/null +++ b/src/Entity/Blog/Tag.php @@ -0,0 +1,37 @@ +text = $text; + } + + public function getId(): ?int + { + return $this->id; + } + + public function getText(): string + { + return $this->text; + } +} diff --git a/src/Repository/Blog/TagRepository.php b/src/Repository/Blog/TagRepository.php new file mode 100644 index 0000000..42134d3 --- /dev/null +++ b/src/Repository/Blog/TagRepository.php @@ -0,0 +1,43 @@ + + * + * @method Tag|null find($id, $lockMode = null, $lockVersion = null) + * @method Tag|null findOneBy(array $criteria, array $orderBy = null) + * @method Tag[] findAll() + * @method Tag[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class TagRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Tag::class); + } + + public function save(Tag $entity, bool $flush = false): void + { + $this->getEntityManager()->persist($entity); + + if ($flush) { + $this->getEntityManager()->flush(); + } + } + + public function findOneByLowerText(string $text): ?Tag + { + $qb = $this->createQueryBuilder('t'); + return $qb + ->where('LOWER(t.text) = :text') + ->setParameter('text', \mb_strtolower($text)) + ->getQuery()->getOneOrNullResult() + ; + } +}