public function findNextVotingByPanelAndCurrentVoting(\Visol\EasyvoteEducation\Domain\Model\Panel $panel, \Visol\EasyvoteEducation\Domain\Model\Voting $currentVoting)
 {
     $query = $this->createQuery();
     $query->matching($query->logicalAnd($query->greaterThan('sorting', $currentVoting->getSorting()), $query->equals('panel', $panel), $query->equals('isVisible', TRUE)));
     $query->setOrderings(array('sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING, 'uid' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING));
     return $query->execute()->getFirst();
 }
 /**
  * @test
  */
 public function removeVotingOptionFromObjectStorageHoldingVotingOptions()
 {
     $votingOption = new \Visol\EasyvoteEducation\Domain\Model\VotingOption();
     $votingOptionsObjectStorageMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array('detach'), array(), '', FALSE);
     $votingOptionsObjectStorageMock->expects($this->once())->method('detach')->with($this->equalTo($votingOption));
     $this->inject($this->subject, 'votingOptions', $votingOptionsObjectStorageMock);
     $this->subject->removeVotingOption($votingOption);
 }
 /**
  * Duplicate a voting
  *
  * @unused Currently not used and maintained
  * @param Voting $voting
  * @return string
  */
 public function duplicateAction(Voting $voting)
 {
     if ($this->isCurrentUserOwnerOfPanel($voting->getPanel())) {
         /** @var \Visol\EasyvoteEducation\Domain\Model\Panel $duplicateVoting */
         $duplicateVoting = $this->cloneService->copy($voting);
         $copyOfText = LocalizationUtility::translate('voting.actions.duplicate.copyOf', $this->request->getControllerExtensionName());
         $duplicateVoting->setTitle($copyOfText . ' ' . $voting->getTitle());
         $this->votingRepository->add($duplicateVoting);
         $voting->getPanel()->addVoting($duplicateVoting);
         $this->persistenceManager->persistAll();
         return json_encode(array('reloadVotings' => $voting->getPanel()->getUid()));
     } else {
         // Error: Non-owner tries to duplicate a Voting
         $reason = LocalizationUtility::translate('ajax.status.403', 'easyvote_education');
         $reason .= '<br />VotingController/duplicateAction';
         return json_encode(array('status' => 403, 'reason' => $reason));
     }
 }
 /**
  * Sort a voting option
  *
  * @param \Visol\EasyvoteEducation\Domain\Model\Voting $voting
  * @param array $sorting
  * @return string
  */
 public function sortAction(\Visol\EasyvoteEducation\Domain\Model\Voting $voting, $sorting)
 {
     if ($this->isCurrentUserOwnerOfPanel($voting->getPanel())) {
         $votingOptions = $this->votingOptionRepository->findByVoting($voting);
         foreach ($votingOptions as $votingOption) {
             /** @var $votingOption \Visol\EasyvoteEducation\Domain\Model\VotingOption */
             $votingOption->setSorting((int) $sorting[$votingOption->getUid()]);
             $this->votingOptionRepository->update($votingOption);
         }
         $this->persistenceManager->persistAll();
         return json_encode(array('status' => 200));
     } else {
         // Error: Non-owner tries to sort a voting option
         $reason = LocalizationUtility::translate('ajax.status.403', 'easyvote_education');
         $reason .= '<br />VotingOptionController/sortAction';
         return json_encode(array('status' => 403, 'reason' => $reason));
     }
 }