vendor/marketingfactory/destisuite/src/DestiSuiteBundle/Model/DataObject/Experience.php line 13

Open in your IDE?
  1. <?php
  2. namespace DestiSuiteBundle\Model\DataObject;
  3. use Pimcore\Model\DataObject\Experience as ExperienceBase;
  4. use Pimcore\Model\DataObject;
  5. use DestiSuiteBundle\Model\Traits\WebsiteVisibilityTrait;
  6. use DestiSuiteBundle\Model\Traits\SluggableTrait;
  7. use DestiSuiteBundle\Model\Traits\PeriodTrait;
  8. use DestiSuiteBundle\Repository\ExperienceRepository;
  9. use DestiSuiteBundle\Services\Interfaces\CustomBookingServiceInterface;
  10. class Experience extends ExperienceBase
  11. {
  12.     use WebsiteVisibilityTraitSluggableTraitPeriodTrait;
  13.     
  14.     const ORDERING_PRIORITY_HIGH 10;
  15.     const ORDERING_PRIORITY_NORMAL 0;
  16.     const ORDERING_PRIORITY_LOW = -10;
  17.     
  18.     public static function getDs_bundle_type()
  19.     {
  20.         try {
  21.             $bundleType \Pimcore::getContainer()->getParameter('ds_experience_bundle')['type'];
  22.         } catch (\Exception $ex) {
  23.             $bundleType '';
  24.         }
  25.         
  26.         return $bundleType;
  27.     }
  28.     
  29.     public function hasBookingFunction()
  30.     {
  31.         try {
  32.             $booking \Pimcore::getContainer()->getParameter('ds_experience_bundle')['booking'];
  33.         } catch (\Exception $ex) {
  34.             $booking false;
  35.         }
  36.         
  37.         if(self::getDs_bundle_type() == 'feratel' && !empty($this->getFid())) {
  38.             return true;
  39.         } elseif(self::getDs_bundle_type() == 'custom') {
  40.             
  41.             // check if has booking feature in future
  42.             $bookingServiceName \Pimcore::getContainer()->getParameter('ds_experience_bundle')['booking_service'];
  43.             if (!empty($bookingServiceName)) {
  44.                 $service \Pimcore::getContainer()->get($bookingServiceName);
  45.                 if (!$service instanceof CustomBookingServiceInterface) {
  46.                     throw new \Exception('ds_experience_bundle.booking_service does not implements DestiSuiteBundle\Services\Interfaces\CustomBookingServiceInterface');
  47.                 }
  48.                 return $service->hasBookingDates($this);
  49.             }
  50.             
  51.             
  52.             return $booking;
  53.         }
  54.     }
  55.     
  56.     public function getMainCategory()
  57.     {
  58.         if (!empty($this->getCategories())) {
  59.             return $this->getCategories()[0];
  60.         }
  61.         return null;
  62.     }
  63.     
  64.     public function getMainImage()
  65.     {
  66.         if (!empty($this->getOverwriteGallery())) {
  67.             $items $this->getOverwriteGallery()->getItems();
  68.             if (!empty($items) && !empty($items[0]) && !empty($items[0]->getImage())) {
  69.                 return $items[0]->getImage();
  70.             }
  71.         }
  72.         
  73.         if (!empty($this->getGallery())) {
  74.             $items $this->getGallery()->getItems();
  75.             if (!empty($items) && !empty($items[0]) && !empty($items[0]->getImage())) {
  76.                 return $items[0]->getImage();
  77.             }
  78.         }
  79.     }
  80.     
  81.     public function isVisible($multisiteOwner null$locale null)
  82.     {
  83.         if(empty($this->isPublished())) {
  84.             return false;
  85.         }
  86.         
  87.         if(empty($this->getTitle($locale))) {
  88.             return false;
  89.         }
  90.         
  91.         if ($this->isExpired() && empty($this->getVisibleAfterExpiration())) {
  92.             return false;
  93.         }
  94.         
  95.         if ( empty($this->isVisibleInWebsite($multisiteOwner)) ) {
  96.             return false;
  97.         }
  98.         return true;
  99.     }
  100.     
  101.     public function isTopEvent()
  102.     {
  103.         if ($this->getOrderingPriority() == self::ORDERING_PRIORITY_HIGH) {
  104.             return true;
  105.         }
  106.         return false;
  107.     }
  108.     
  109.     public function getMarkerData()
  110.     {
  111.         $list = array();
  112.         if (empty($this->getLocations())) {
  113.             return $list;
  114.         }
  115.         foreach ($this->getLocations() as $operator) {
  116.             if (!empty($operator->getPosition())) {
  117.                 $list[] = array(
  118.                     'lat' => $operator->getPosition()->getLatitude(),
  119.                     'lng' => $operator->getPosition()->getLongitude(),
  120.                     'id' => $this->getId(),
  121.                     'url' => null,
  122.                 );
  123.             }
  124.         } 
  125.         
  126.         /*
  127.         if (empty($list) && !empty($this->getMeetingPoint())) {
  128.             $list[] = array(
  129.                 'lat' => $this->getMeetingPoint()->getLatitude(),
  130.                 'lng' => $this->getMeetingPoint()->getLongitude(),
  131.                 'id' => $this->getId(),
  132.                 'url' => null,
  133.             );
  134.         }
  135.         */
  136.         
  137.         return $list;
  138.     }
  139.     
  140.     public function getCorrelatedEvents($locale$multisiteOwner)
  141.     {
  142.         $correlated = array();
  143.         if (!empty($this->getCorrelated())) {
  144.             foreach ($this->getCorrelated() as $correlatedEl) {
  145.                 if($correlatedEl->isVisible($multisiteOwner)) {
  146.                     $correlated[] = $correlatedEl;
  147.                 }
  148.             }
  149.         }
  150.         
  151.         // when nothing set, fetch by same category
  152.         if (empty($correlated) && !empty($this->getCategories())) {
  153.             $filters = array(
  154.                 'categories' => $this->getCategories(),
  155.                 'excludeIds' => array($this->getId()),
  156.             );
  157.             
  158.             $correlated ExperienceRepository::getNextEntities($locale$multisiteOwner$filters6);
  159.         }
  160.         
  161.         return $correlated;
  162.     }
  163. }