app/Plugin/VariationSwatches42/Repository/ClassConfigRepository.php line 22

Open in your IDE?
  1. <?php
  2. namespace Plugin\VariationSwatches42\Repository;
  3. use Eccube\Repository\AbstractRepository;
  4. use Plugin\VariationSwatches42\Entity\VariationSwatchClassConfig;
  5. use Doctrine\Persistence\ManagerRegistry;
  6. class ClassConfigRepository extends AbstractRepository
  7. {
  8.     /**
  9.      * @param  ManagerRegistry  $registry
  10.      */
  11.     public function __construct(ManagerRegistry $registry)
  12.     {
  13.         parent::__construct($registryVariationSwatchClassConfig::class);
  14.     }
  15.     /**
  16.      * @return VariationSwatchClassConfig[] indexed by class_name_id
  17.      */
  18.     public function findAllIndexed()
  19.     {
  20.         $list $this->createQueryBuilder('c')
  21.             ->leftJoin('c.className''cn')
  22.             ->addSelect('cn')
  23.             ->getQuery()->getResult();
  24.         $indexed = [];
  25.         foreach ($list as $cfg) {
  26.             $indexed[$cfg->getClassName()->getId()] = $cfg;
  27.         }
  28.         return $indexed;
  29.     }
  30. }