vendor/elements/ticket-shop-framework-bundle/src/Service/SiteConfigService.php line 40

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace Elements\Bundle\TicketShopFrameworkBundle\Service;
  7. use Elements\Bundle\TicketShopFrameworkBundle\Model\DataObject\SiteConfigInterface;
  8. use Pimcore\Http\Request\Resolver\DocumentResolver;
  9. use Pimcore\Model\DataObject;
  10. class SiteConfigService
  11. {
  12.     private $documentResolver;
  13.     /**
  14.      * @var string
  15.      */
  16.     protected $defaultPath;
  17.     public function __construct(DocumentResolver $documentResolver$defaultPath null)
  18.     {
  19.         $this->documentResolver $documentResolver;
  20.         $this->defaultPath $defaultPath;
  21.     }
  22.     public function getSiteConfig(): ?SiteConfigInterface
  23.     {
  24.         $document null;
  25.         try {
  26.             $document $this->documentResolver->getDocument();
  27.         } catch (\Exception $e) {
  28.         }
  29.         if ($document && $document->getProperty('siteConfig') instanceof SiteConfigInterface) {
  30.             return $this->documentResolver->getDocument()->getProperty('siteConfig');
  31.         } else {
  32.             $obj =  DataObject::getByPath($this->defaultPath);
  33.             if ($obj instanceof SiteConfigInterface) {
  34.                 return $obj;
  35.             }
  36.             return null;
  37.         }
  38.     }
  39. }