- <?php
- /**
-  * Created by Elements.at New Media Solutions GmbH
-  *
-  */
- namespace Elements\Bundle\TicketShopFrameworkBundle\Service;
- use Elements\Bundle\TicketShopFrameworkBundle\Model\DataObject\SiteConfigInterface;
- use Pimcore\Http\Request\Resolver\DocumentResolver;
- use Pimcore\Model\DataObject;
- class SiteConfigService
- {
-     private $documentResolver;
-     /**
-      * @var string
-      */
-     protected $defaultPath;
-     public function __construct(DocumentResolver $documentResolver, $defaultPath = null)
-     {
-         $this->documentResolver = $documentResolver;
-         $this->defaultPath = $defaultPath;
-     }
-     public function getSiteConfig(): ?SiteConfigInterface
-     {
-         $document = null;
-         try {
-             $document = $this->documentResolver->getDocument();
-         } catch (\Exception $e) {
-         }
-         if ($document && $document->getProperty('siteConfig') instanceof SiteConfigInterface) {
-             return $this->documentResolver->getDocument()->getProperty('siteConfig');
-         } else {
-             $obj =  DataObject::getByPath($this->defaultPath);
-             if ($obj instanceof SiteConfigInterface) {
-                 return $obj;
-             }
-             return null;
-         }
-     }
- }
-