vendor/sonata-project/doctrine-extensions/src/Adapter/AdapterChain.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\Doctrine\Adapter;
  12. class AdapterChain implements AdapterInterface
  13. {
  14.     /**
  15.      * @var AdapterInterface[]
  16.      */
  17.     protected $adapters = [];
  18.     public function addAdapter(AdapterInterface $adapter)
  19.     {
  20.         $this->adapters[] = $adapter;
  21.     }
  22.     public function getNormalizedIdentifier($model)
  23.     {
  24.         foreach ($this->adapters as $adapter) {
  25.             $identifier $adapter->getNormalizedIdentifier($model);
  26.             if ($identifier) {
  27.                 return $identifier;
  28.             }
  29.         }
  30.     }
  31.     public function getUrlsafeIdentifier($model)
  32.     {
  33.         foreach ($this->adapters as $adapter) {
  34.             $safeIdentifier $adapter->getUrlsafeIdentifier($model);
  35.             if ($safeIdentifier) {
  36.                 return $safeIdentifier;
  37.             }
  38.         }
  39.     }
  40. }
  41. class_exists(\Sonata\CoreBundle\Model\Adapter\AdapterChain::class);