| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace DERHANSEN\SfEventMgt\Domain\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * For the full copyright and license information, please read the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * LICENSE.txt file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use DERHANSEN\SfEventMgt\Service\CategoryService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use TYPO3\CMS\Core\Utility\MathUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * The repository for Events | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @author Torben Hansen <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class EventRepository extends \TYPO3\CMS\Extbase\Persistence\Repository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * Set default sorting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected $defaultOrderings = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'startdate' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * Disable the use of storage records, because the StoragePage can be set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * in the plugin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function initializeObject() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->defaultQuerySettings = $this->objectManager->get(Typo3QuerySettings::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->defaultQuerySettings->setRespectStoragePage(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * Returns the objects of this repository matching the given demand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface QueryResultInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function findDemanded(EventDemand $eventDemand) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $constraints = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $query = $this->createQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $query->getQuerySettings()->setIgnoreEnableFields($eventDemand->getIgnoreEnableFields()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->setStoragePageConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->setDisplayModeConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->setCategoryConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->setLocationConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->setLocationCityConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->setLocationCountryConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->setSpeakerConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->setOrganisatorConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->setStartEndDateConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->setSearchConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->setTopEventConstraint($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->setYearMonthDayRestriction($query, $eventDemand, $constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         /** @var Dispatcher $signalSlotDispatcher */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $signalSlotDispatcher = $this->objectManager->get(Dispatcher::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $signalSlotDispatcher->dispatch( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             __CLASS__, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             __FUNCTION__ . 'ModifyQueryConstraints', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             [&$constraints, $query, $eventDemand, $this] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->setOrderingsFromDemand($query, $eventDemand); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         if (count($constraints) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             $query->matching($query->logicalAnd($constraints)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->setQueryLimitFromDemand($query, $eventDemand); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         return $query->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * Returns the event with the given UID and also respects the hidden state | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @param int $uid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @return object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     public function findByUidIncludeHidden(int $uid) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $query = $this->createQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $query->getQuerySettings()->setIgnoreEnableFields(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $query->matching($query->equals('uid', $uid)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         return $query->execute()->getFirst(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * Sets a query limit to the given query for the given demand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     protected function setQueryLimitFromDemand($query, EventDemand $eventDemand) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         if ($eventDemand->getQueryLimit() != null && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             MathUtility::canBeInterpretedAsInteger($eventDemand->getQueryLimit()) && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             (int)$eventDemand->getQueryLimit() > 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             $query->setLimit((int)$eventDemand->getQueryLimit()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * Sets the ordering to the given query for the given demand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |     protected function setOrderingsFromDemand($query, EventDemand $eventDemand) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $orderings = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         $orderFieldAllowed = GeneralUtility::trimExplode(',', $eventDemand->getOrderFieldAllowed(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         if ($eventDemand->getOrderField() != '' && $eventDemand->getOrderDirection() != '' && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             !empty($orderFieldAllowed) && in_array($eventDemand->getOrderField(), $orderFieldAllowed, true)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $orderings[$eventDemand->getOrderField()] = ((strtolower($eventDemand->getOrderDirection()) == 'desc') ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                 \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                 \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $query->setOrderings($orderings); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * Sets the storagePage constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     protected function setStoragePageConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         if ($eventDemand->getStoragePage() !== null && $eventDemand->getStoragePage() !== '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             $pidList = GeneralUtility::intExplode(',', $eventDemand->getStoragePage(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             $constraints[] = $query->in('pid', $pidList); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * Sets the displayMode constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     protected function setDisplayModeConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         switch ($eventDemand->getDisplayMode()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             case 'future': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 $constraints[] = $query->greaterThan('startdate', $eventDemand->getCurrentDateTime()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             case 'current_future': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |                 $constraints[] = $query->logicalOr([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |                     $query->greaterThan('startdate', $eventDemand->getCurrentDateTime()), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |                     $query->logicalAnd([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |                         $query->greaterThanOrEqual('enddate', $eventDemand->getCurrentDateTime()), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |                         $query->lessThanOrEqual('startdate', $eventDemand->getCurrentDateTime()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |                     ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                 ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             case 'past': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |                 $constraints[] = $query->lessThanOrEqual('enddate', $eventDemand->getCurrentDateTime()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * Sets the category constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     protected function setCategoryConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         // If no category constraint is set, categories should not be respected in the query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         if ($eventDemand->getCategoryConjunction() === '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         if ($eventDemand->getCategory() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             $categoryConstraints = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             if ($eventDemand->getIncludeSubcategories()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |                 $categoryList = CategoryService::getCategoryListWithChilds($eventDemand->getCategory()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 $categories = GeneralUtility::intExplode(',', $categoryList, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                 $categories = GeneralUtility::intExplode(',', $eventDemand->getCategory(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             foreach ($categories as $category) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                 $categoryConstraints[] = $query->contains('category', $category); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             if (count($categoryConstraints) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                 $constraints[] = $this->getCategoryConstraint($query, $eventDemand, $categoryConstraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |      * Returns the category constraint depending on the category conjunction configured in eventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * @param array $categoryConstraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     public function getCategoryConstraint($query, $eventDemand, $categoryConstraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         switch (strtolower($eventDemand->getCategoryConjunction())) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             case 'and': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                 $constraint = $query->logicalAnd($categoryConstraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             case 'notor': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |                 $constraint = $query->logicalNot($query->logicalOr($categoryConstraints)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             case 'notand': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |                 $constraint = $query->logicalNot($query->logicalAnd($categoryConstraints)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             case 'or': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |                 $constraint = $query->logicalOr($categoryConstraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         return $constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |      * Sets the location constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |     protected function setLocationConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         if ($eventDemand->getLocation() !== null && $eventDemand->getLocation() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             $constraints[] = $query->equals('location', $eventDemand->getLocation()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      * Sets the location.city constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |     protected function setLocationCityConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         if ($eventDemand->getLocationCity() !== null && $eventDemand->getLocationCity() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |             $constraints[] = $query->equals('location.city', $eventDemand->getLocationCity()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * Sets the location.country constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |     protected function setLocationCountryConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         if ($eventDemand->getLocationCountry() !== null && $eventDemand->getLocationCountry() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |             $constraints[] = $query->equals('location.country', $eventDemand->getLocationCountry()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |      * Sets the speaker constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |     protected function setSpeakerConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         if ($eventDemand->getSpeaker() !== null && $eventDemand->getSpeaker() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             $constraints[] = $query->contains('speaker', $eventDemand->getSpeaker()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * Sets the organisator constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     protected function setOrganisatorConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         if ($eventDemand->getOrganisator() !== null && $eventDemand->getOrganisator() != '') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |             $constraints[] = $query->equals('organisator', $eventDemand->getOrganisator()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * Sets the start- and enddate constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |      * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 341 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |     protected function setStartEndDateConstraint($query, $eventDemand, &$constraints) | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |         if ($eventDemand->getSearchDemand() && $eventDemand->getSearchDemand()->getStartDate() !== null && | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |             $eventDemand->getSearchDemand()->getEndDate() !== null | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |         ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |             /* StartDate and EndDate  - Search for events between two given dates */ | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |             $begin = $eventDemand->getSearchDemand()->getStartDate(); | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |             $end = $eventDemand->getSearchDemand()->getEndDate(); | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |             $constraints[] = $query->logicalOr([ | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |                 $query->between('startdate', $begin, $end), | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |                 $query->between('enddate', $begin, $end), | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |                 $query->logicalAnd([ | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |                     $query->greaterThanOrEqual('enddate', $begin), | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |                     $query->lessThanOrEqual('startdate', $begin) | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |                 ]) | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |             ]); | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |         } elseif ($eventDemand->getSearchDemand() && $eventDemand->getSearchDemand()->getStartDate() !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |             /* StartDate - Search for events beginning at a given date */ | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |             $constraints[] = $query->greaterThanOrEqual('startdate', $eventDemand->getSearchDemand()->getStartDate()); | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |         } elseif ($eventDemand->getSearchDemand() && $eventDemand->getSearchDemand()->getEndDate() !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |             /* EndDate - Search for events ending on a given date */ | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |             $constraints[] = $query->lessThanOrEqual('enddate', $eventDemand->getSearchDemand()->getEndDate()); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |      * Sets the search constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |     protected function setSearchConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         if ($eventDemand->getSearchDemand() && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             $eventDemand->getSearchDemand()->getSearch() !== null && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |             $eventDemand->getSearchDemand()->getSearch() !== '' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |             $searchFields = GeneralUtility::trimExplode(',', $eventDemand->getSearchDemand()->getFields(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |             $searchConstraints = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |             if (count($searchFields) === 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |                 throw new \UnexpectedValueException('No search fields defined', 1318497755); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             $searchSubject = $eventDemand->getSearchDemand()->getSearch(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |             foreach ($searchFields as $field) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |                 if (!empty($searchSubject)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |                     $searchConstraints[] = $query->like($field, '%' . addcslashes($searchSubject, '_%') . '%'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |             if (count($searchConstraints)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                 $constraints[] = $query->logicalOr($searchConstraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |      * Sets the topEvent constraint to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query Query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand EventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |      * @param array $constraints Constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |     protected function setTopEventConstraint($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |         if ($eventDemand->getTopEventRestriction() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |             $constraints[] = $query->equals('topEvent', (bool)($eventDemand->getTopEventRestriction() - 1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |      * Sets the restriction for year, year/month or year/month/day to the given constraints array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |      * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |      * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $eventDemand | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |      * @param array $constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |     protected function setYearMonthDayRestriction($query, $eventDemand, &$constraints) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         if ($eventDemand->getYear() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |             if ($eventDemand->getMonth() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                 if ($eventDemand->getDay() > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                     $begin = mktime(0, 0, 0, $eventDemand->getMonth(), $eventDemand->getDay(), $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                     $end = mktime(23, 59, 59, $eventDemand->getMonth(), $eventDemand->getDay(), $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                     $begin = mktime(0, 0, 0, $eventDemand->getMonth(), 1, $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                     $end = mktime(23, 59, 59, ($eventDemand->getMonth() + 1), 0, $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                 $begin = mktime(0, 0, 0, 1, 1, $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                 $end = mktime(23, 59, 59, 12, 31, $eventDemand->getYear()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |             $constraints[] = $query->logicalOr([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |                 $query->between('startdate', $begin, $end), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |                 $query->between('enddate', $begin, $end), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                 $query->logicalAnd([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |                     $query->greaterThanOrEqual('enddate', $begin), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |                     $query->lessThanOrEqual('startdate', $begin) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                 ]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 452 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 453 |  |  |  |