Server IP : 172.67.158.161 / Your IP : 3.15.150.157 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Doctrine/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Doctrine; if (!defined('ABSPATH')) exit; use MailPoetVendor\Doctrine\Common\Collections\Collection; use MailPoetVendor\Doctrine\Common\Collections\Criteria; use MailPoetVendor\Doctrine\ORM\EntityManager; use MailPoetVendor\Doctrine\ORM\EntityRepository as DoctrineEntityRepository; use MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadata; /** * @template T of object */ abstract class Repository { /** @var EntityManager */ protected $entityManager; /** @var ClassMetadata<object> */ protected $classMetadata; /** @var DoctrineEntityRepository<T> */ protected $doctrineRepository; /** @var string[] */ protected $ignoreColumnsForUpdate = [ 'created_at', ]; public function __construct( EntityManager $entityManager ) { $this->entityManager = $entityManager; $this->classMetadata = $entityManager->getClassMetadata($this->getEntityClassName()); $this->doctrineRepository = new DoctrineEntityRepository($this->entityManager, $this->classMetadata); } /** * @param array $criteria * @param array|null $orderBy * @param int|null $limit * @param int|null $offset * @return T[] */ public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) { return $this->doctrineRepository->findBy($criteria, $orderBy, $limit, $offset); } /** * @param Criteria $criteria * @return Collection<int, T> */ public function matching(Criteria $criteria) { return $this->doctrineRepository->matching($criteria); } public function countBy(array $criteria): int { return $this->doctrineRepository->count($criteria); } /** * @param array $criteria * @param array|null $orderBy * @return T|null */ public function findOneBy(array $criteria, array $orderBy = null) { return $this->doctrineRepository->findOneBy($criteria, $orderBy); } /** * @param mixed $id * @return T|null */ public function findOneById($id) { return $this->doctrineRepository->find($id); } /** * @return T[] */ public function findAll() { return $this->doctrineRepository->findAll(); } /** * @param T $entity */ public function persist($entity) { $this->entityManager->persist($entity); } public function truncate() { $tableName = $this->classMetadata->getTableName(); $connection = $this->entityManager->getConnection(); $connection->executeQuery('SET FOREIGN_KEY_CHECKS=0'); $q = "TRUNCATE $tableName"; $connection->executeStatement($q); $connection->executeQuery('SET FOREIGN_KEY_CHECKS=1'); } /** * @param T $entity */ public function remove($entity) { $this->entityManager->remove($entity); } /** * @param T $entity */ public function refresh($entity) { $this->entityManager->refresh($entity); } public function flush() { $this->entityManager->flush(); } public function getReference($id) { return $this->entityManager->getReference($this->getEntityClassName(), $id); } /** * @param T $entity */ public function detach($entity) { $this->entityManager->detach($entity); } /** * @return class-string<T> */ abstract protected function getEntityClassName(); }