vendor/friendsofsymfony/oauth-server-bundle/Entity/ClientManager.php line 38

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the FOSOAuthServerBundle package.
  5.  *
  6.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace FOS\OAuthServerBundle\Entity;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Doctrine\ORM\EntityRepository;
  14. use FOS\OAuthServerBundle\Model\ClientInterface;
  15. use FOS\OAuthServerBundle\Model\ClientManager as BaseClientManager;
  16. class ClientManager extends BaseClientManager
  17. {
  18.     /**
  19.      * @var EntityManagerInterface
  20.      */
  21.     protected $em;
  22.     /**
  23.      * @var EntityRepository
  24.      */
  25.     protected $repository;
  26.     /**
  27.      * @var string
  28.      */
  29.     protected $class;
  30.     public function __construct(EntityManagerInterface $em$class)
  31.     {
  32.         // NOTE: bug in Doctrine, hinting EntityRepository|ObjectRepository when only EntityRepository is expected
  33.         /** @var EntityRepository $repository */
  34.         $repository $em->getRepository($class);
  35.         $this->em $em;
  36.         $this->repository $repository;
  37.         $this->class $class;
  38.     }
  39.     /**
  40.      * {@inheritdoc}
  41.      */
  42.     public function getClass()
  43.     {
  44.         return $this->class;
  45.     }
  46.     /**
  47.      * {@inheritdoc}
  48.      */
  49.     public function findClientBy(array $criteria)
  50.     {
  51.         return $this->repository->findOneBy($criteria);
  52.     }
  53.     /**
  54.      * {@inheritdoc}
  55.      */
  56.     public function updateClient(ClientInterface $client)
  57.     {
  58.         $this->em->persist($client);
  59.         $this->em->flush();
  60.     }
  61.     /**
  62.      * {@inheritdoc}
  63.      */
  64.     public function deleteClient(ClientInterface $client)
  65.     {
  66.         $this->em->remove($client);
  67.         $this->em->flush();
  68.     }
  69. }