/**
  * @param \Bjr\BjrLend\Domain\Model\Article $article
  * @param $args
  */
 protected function bookArticle(\Bjr\BjrLend\Domain\Model\Article $article, $args)
 {
     if (!empty($args['issueStartDay']) && !empty($args['issueEndDay'])) {
         //we add on each 6 hours so we have no problems with calculation the booked calendar.
         //Because of summertime we hava otherwise a gap of 1 hour at the weekend the time is changed from summer to winter
         //$issue = array(($args['issueStartDay']+(5*60*60)), ($args['issueEndDay']+(5*60*60)));
         $issue = array($args['issueStartDay'], $args['issueEndDay']);
     } else {
         //fehlerfall
         throw new Exception("Keine IssueStartDay!");
     }
     //$article = $this->articleRepository->findByUid(4);
     $basketItem = \Bjr\BjrLend\Domain\Model\BasketItem::getItemFromArticle($article);
     $basketItem->setDurationOfIssue($issue);
     /* @var $basket \Bjr\BjrLend\Domain\Model\Basket */
     $basketRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Bjr\\BjrLend\\Domain\\Repository\\BasketRepository');
     $basket = $basketRepository->getBasket();
     $basket->addItem($basketItem);
     // in Session speichern
     $basket->storeInSession();
     //Flashmessage
     // eigene Message setzten, "OK" setzt hier den grauen Ausgabekasten im BE
     $this->controllerContext->getFlashMessageQueue()->enqueue($this->objectManager->get('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'Der Artikel wurde dem Warenkorb hinzugefĆ¼gt.', 'Meldung', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, false));
     return $basket;
 }
Example #2
0
 /**
  * @param $sessionData
  * @return \Bjr\BjrLend\Domain\Model\Basket
  * called after sessionData for a basket are fetched
  */
 public static function sessionDataToBasket($sessionData)
 {
     /* @var \Bjr\BjrLend\Domain\Model\Basket */
     $basket = GeneralUtility::makeInstance('Bjr\\BjrLend\\Domain\\Model\\Basket');
     $basket->initializeObject();
     foreach ($sessionData as $entry) {
         $articleRepository = GeneralUtility::makeInstance('Bjr\\BjrLend\\Domain\\Repository\\ArticleRepository');
         $article = $articleRepository->findByUid($entry['uid']);
         /* @var $basketItem \Bjr\BjrLend\Domain\Model\BasketItem */
         $basketItem = \Bjr\BjrLend\Domain\Model\BasketItem::getItemFromArticle($article);
         $issueDuration = array($entry['issueStart'], $entry['issueEnd']);
         $basketItem->setDurationOfIssue($issueDuration);
         $basket->addItem($basketItem);
     }
     return $basket;
 }