app/Plugin/GtmGaEEc42/Repository/GtmGaEEcRepository.php line 56

Open in your IDE?
  1. <?php
  2. /*
  3.  * GtmGaEEc42: GTM版 Google Analytics eコマース/拡張eコマース対応プラグイン
  4.  * Copyright (C) 2017-2022 Freischtide Inc. All Rights Reserved.
  5.  * http://freischtide.tumblr.com/
  6.  *
  7.  * License: see LICENSE.txt
  8.  */
  9. namespace Plugin\GtmGaEEc42\Repository;
  10. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  11. use Doctrine\Persistence\ManagerRegistry as RegistryInterface;
  12. use Plugin\GtmGaEEc42\Entity\GtmGaEEc;
  13. /**
  14.  * plg_gtmgaeec_plugin テーブルのリポジトリクラス
  15.  */
  16. class GtmGaEEcRepository extends ServiceEntityRepository
  17. {
  18.     public function __construct(RegistryInterface $registry)
  19.     {
  20.         parent::__construct($registryGtmGaEEc::class);
  21.     }
  22.     /**
  23.      * @param  \Plugin\GtmGaEEc42\Entity\GtmGaEEc $gtmGaEEc
  24.      * @param  array $custom_referrer_keys
  25.      * @param  array $custom_referrer_values
  26.      * @return bool
  27.      */
  28.     public function save(\Plugin\GtmGaEEc42\Entity\GtmGaEEc $gtmGaEEc$custom_referrer_keys$custom_referrer_values$tag_version)
  29.     {
  30.         $gtmGaEEc->setTagVersion($tag_version);
  31.         $gtmGaEEc->setCustomReferrers($custom_referrer_keys$custom_referrer_values);
  32.         $em $this->getEntityManager();
  33.         $em->getConnection()->beginTransaction();
  34.         try {
  35.             $em->persist($gtmGaEEc);
  36.             $em->flush();
  37.             $em->getConnection()->commit();
  38.         } catch (\Exception $e) {
  39.             $em->getConnection()->rollback();
  40.             return false;
  41.         }
  42.         return true;
  43.     }
  44.     /**
  45.      * @param int $id
  46.      *
  47.      * @return null|GtmGaEEc
  48.      */
  49.     public function get($id 1)
  50.     {
  51.         return $this->find($id);
  52.     }
  53. }