updrade with rector

This commit is contained in:
2022-05-03 14:52:04 +02:00
parent d1e613ecc6
commit 6e30560cb9
135 changed files with 5609 additions and 4008 deletions

View File

@@ -1,50 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Blog;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Blog|null find($id, $lockMode = null, $lockVersion = null)
* @method Blog|null findOneBy(array $criteria, array $orderBy = null)
* @method Blog[] findAll()
* @method Blog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class BlogRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Blog::class);
}
// /**
// * @return Blog[] Returns an array of Blog objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('b')
->andWhere('b.exampleField = :val')
->setParameter('val', $value)
->orderBy('b.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Blog
{
return $this->createQueryBuilder('b')
->andWhere('b.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@@ -1,50 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Comment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Comment|null find($id, $lockMode = null, $lockVersion = null)
* @method Comment|null findOneBy(array $criteria, array $orderBy = null)
* @method Comment[] findAll()
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CommentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Comment::class);
}
// /**
// * @return Comment[] Returns an array of Comment objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->orderBy('c.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Comment
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@@ -0,0 +1,68 @@
<?php
namespace App\Repository;
use App\Entity\Pages;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Pages>
*
* @method Pages|null find($id, $lockMode = null, $lockVersion = null)
* @method Pages|null findOneBy(array $criteria, array $orderBy = null)
* @method Pages[] findAll()
* @method Pages[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PagesRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct(registry: $registry, entityClass: Pages::class);
}
public function add(Pages $entity, bool $flush = true): void
{
$this->_em->persist($entity);
if ($flush) {
$this->_em->flush();
}
}
public function remove(Pages $entity, bool $flush = true): void
{
$this->_em->remove($entity);
if ($flush) {
$this->_em->flush();
}
}
// /**
// * @return Pages[] Returns an array of Pages objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Pages
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@@ -20,8 +20,6 @@ class ProjectsRepository extends ServiceEntityRepository
parent::__construct(registry: $registry, entityClass: Projects::class);
}
/**
*/
public function add(Projects $entity, bool $flush = true): void
{
$this->_em->persist($entity);
@@ -30,8 +28,6 @@ class ProjectsRepository extends ServiceEntityRepository
}
}
/**
*/
public function remove(Projects $entity, bool $flush = true): void
{
$this->_em->remove($entity);
@@ -56,18 +52,20 @@ class ProjectsRepository extends ServiceEntityRepository
;
}
*/
public function findOneByName($value): ?Projects
/**
* @param $value
*/
public function findOneByName($value): ?Projects
{
try {
return $this->createQueryBuilder(alias: 'q')
->andWhere('q.name = :val')
->setParameter(key: 'val', value: $value)
->getQuery()
->getOneOrNullResult();
} catch(NonUniqueResultException $e) {
dd($e->getMessage());
}
try {
return $this->createQueryBuilder(alias: 'q')
->andWhere('q.name = :val')
->setParameter(key: 'val', value: $value)
->getQuery()
->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
dd($e->getMessage());
}
}
}

View File

@@ -4,8 +4,6 @@ namespace App\Repository;
use App\Entity\Quotes;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\ORMException;
use Doctrine\Persistence\ManagerRegistry;
/**
@@ -21,8 +19,6 @@ class QuotesRepository extends ServiceEntityRepository
parent::__construct(registry: $registry, entityClass: Quotes::class);
}
/**
*/
public function add(Quotes $entity, bool $flush = true): void
{
$this->_em->persist($entity);
@@ -31,8 +27,6 @@ class QuotesRepository extends ServiceEntityRepository
}
}
/**
*/
public function remove(Quotes $entity, bool $flush = true): void
{
$this->_em->remove($entity);
@@ -40,29 +34,28 @@ class QuotesRepository extends ServiceEntityRepository
$this->_em->flush();
}
}
/**
* @return null|float|int|mixed|string
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneRandom(): mixed
{
$idLimits = $this->createQueryBuilder(alias: 'q')
->select('MIN(q.id)', 'MAX(q.id)')
->getQuery()
->getOneOrNullResult();
$randomPossibleId = rand(min: $idLimits[1], max: $idLimits[2]);
return $this->createQueryBuilder(alias: 'q')
->where(predicates: 'q.id >= :random_id')
->setParameter(key: 'random_id', value: $randomPossibleId)
->setMaxResults(maxResults: 1)
->getQuery()
->getOneOrNullResult();
}
/**
* @return float|int|mixed|string|null
*
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneRandom(): mixed
{
$idLimits = $this->createQueryBuilder(alias: 'q')
->select('MIN(q.id)', 'MAX(q.id)')
->getQuery()
->getOneOrNullResult();
$randomPossibleId = rand(min: $idLimits[1], max: $idLimits[2]);
return $this->createQueryBuilder(alias: 'q')
->where(predicates: 'q.id >= :random_id')
->setParameter(key: 'random_id', value: $randomPossibleId)
->setMaxResults(maxResults: 1)
->getQuery()
->getOneOrNullResult();
}
// /**
// * @return Quotes[] Returns an array of Quotes objects
// */

View File

@@ -1,31 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\ResetPasswordRequest;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestInterface;
use SymfonyCasts\Bundle\ResetPassword\Persistence\Repository\ResetPasswordRequestRepositoryTrait;
use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface;
/**
* @method ResetPasswordRequest|null find($id, $lockMode = null, $lockVersion = null)
* @method ResetPasswordRequest|null findOneBy(array $criteria, array $orderBy = null)
* @method ResetPasswordRequest[] findAll()
* @method ResetPasswordRequest[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ResetPasswordRequestRepository extends ServiceEntityRepository implements ResetPasswordRequestRepositoryInterface
{
use ResetPasswordRequestRepositoryTrait;
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ResetPasswordRequest::class);
}
public function createResetPasswordRequest(object $user, \DateTimeInterface $expiresAt, string $selector, string $hashedToken): ResetPasswordRequestInterface
{
return new ResetPasswordRequest($user, $expiresAt, $selector, $hashedToken);
}
}

View File

@@ -1,50 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Section;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Section|null find($id, $lockMode = null, $lockVersion = null)
* @method Section|null findOneBy(array $criteria, array $orderBy = null)
* @method Section[] findAll()
* @method Section[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class SectionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Section::class);
}
// /**
// * @return Section[] Returns an array of Section objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->orderBy('s.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Section
{
return $this->createQueryBuilder('s')
->andWhere('s.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@@ -5,10 +5,10 @@ namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use function get_class;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use function get_class;
/**
* @method User|null find($id, $lockMode = null, $lockVersion = null)
@@ -23,8 +23,6 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
parent::__construct(registry: $registry, entityClass: User::class);
}
/**
*/
public function add(User $entity, bool $flush = true): void
{
$this->_em->persist(entity: $entity);
@@ -33,8 +31,6 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
}
}
/**
*/
public function remove(User $entity, bool $flush = true): void
{
$this->_em->remove(entity: $entity);