<?php
/*
* GtmGaEEc42: GTM版 Google Analytics eコマース/拡張eコマース対応プラグイン
* Copyright (C) 2017-2022 Freischtide Inc. All Rights Reserved.
* http://freischtide.tumblr.com/
*
* License: see LICENSE.txt
*/
namespace Plugin\GtmGaEEc42\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry as RegistryInterface;
use Plugin\GtmGaEEc42\Entity\GtmGaEEc;
/**
* plg_gtmgaeec_plugin テーブルのリポジトリクラス
*/
class GtmGaEEcRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, GtmGaEEc::class);
}
/**
* @param \Plugin\GtmGaEEc42\Entity\GtmGaEEc $gtmGaEEc
* @param array $custom_referrer_keys
* @param array $custom_referrer_values
* @return bool
*/
public function save(\Plugin\GtmGaEEc42\Entity\GtmGaEEc $gtmGaEEc, $custom_referrer_keys, $custom_referrer_values, $tag_version)
{
$gtmGaEEc->setTagVersion($tag_version);
$gtmGaEEc->setCustomReferrers($custom_referrer_keys, $custom_referrer_values);
$em = $this->getEntityManager();
$em->getConnection()->beginTransaction();
try {
$em->persist($gtmGaEEc);
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
return false;
}
return true;
}
/**
* @param int $id
*
* @return null|GtmGaEEc
*/
public function get($id = 1)
{
return $this->find($id);
}
}