vendor/pimcore/pimcore/lib/Analytics/Google/Config/ConfigProvider.php line 51

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Enterprise License (PEL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  14.  */
  15. namespace Pimcore\Analytics\Google\Config;
  16. use Pimcore\Config\Config as ConfigObject;
  17. class ConfigProvider
  18. {
  19.     /**
  20.      * @var Config
  21.      */
  22.     private $config;
  23.     /**
  24.      * @var ConfigObject|null
  25.      */
  26.     private $configObject;
  27.     /**
  28.      * @param ConfigObject|null $configObject
  29.      */
  30.     public function __construct(ConfigObject $configObject null)
  31.     {
  32.         $this->configObject $configObject;
  33.     }
  34.     public function getConfig(): Config
  35.     {
  36.         if (null === $this->config) {
  37.             $this->config = new Config($this->getConfigObject());
  38.         }
  39.         return $this->config;
  40.     }
  41.     private function getConfigObject(): ConfigObject
  42.     {
  43.         if (null === $this->configObject) {
  44.             $this->configObject $this->loadDefaultConfigObject();
  45.         }
  46.         return $this->configObject;
  47.     }
  48.     protected function loadDefaultConfigObject(): ConfigObject
  49.     {
  50.         $reportConfig = \Pimcore\Config::getReportConfig();
  51.         $config $reportConfig->analytics;
  52.         if (!$config instanceof ConfigObject) {
  53.             $config = new ConfigObject([]);
  54.         }
  55.         return $config;
  56.     }
  57. }