예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getMessage()
 {
     if (!$this->pusher) {
         throw new LogicException('You must set a basket before calling getMessage');
     }
     if (!$this->basket) {
         throw new LogicException('You must set a basket before calling getMessage');
     }
     return $this->app->trans('You just received a push containing %quantity% documents from %user%', ['%quantity%' => count($this->basket->getElements()), '%user%' => $this->pusher->getDisplayName()]) . "\n" . $this->message;
 }
예제 #2
0
 /**
  *
  * @param  Basket        $Basket
  * @return set_selection
  */
 public function load_basket(Basket $Basket)
 {
     foreach ($Basket->getElements() as $basket_element) {
         $this->add_element($basket_element->getRecord($this->app));
     }
     return $this;
 }
예제 #3
0
 public function reorder(Request $request, Basket $basket)
 {
     $ret = ['success' => false, 'message' => $this->app->trans('An error occured')];
     try {
         $order = $request->request->get('element');
         foreach ($basket->getElements() as $basketElement) {
             if (isset($order[$basketElement->getId()])) {
                 $basketElement->setOrd($order[$basketElement->getId()]);
                 $this->getEntityManager()->merge($basketElement);
             }
         }
         $this->getEntityManager()->flush();
         $ret = ['success' => true, 'message' => $this->app->trans('Basket updated')];
     } catch (\Exception $e) {
     }
     return $this->app->json($ret);
 }
예제 #4
0
 public function reorder(Application $app, BasketEntity $basket)
 {
     $ret = ['success' => false, 'message' => $app->trans('An error occured')];
     try {
         $order = $app['request']->request->get('element');
         /* @var $basket BasketEntity */
         foreach ($basket->getElements() as $basketElement) {
             if (isset($order[$basketElement->getId()])) {
                 $basketElement->setOrd($order[$basketElement->getId()]);
                 $app['EM']->merge($basketElement);
             }
         }
         $app['EM']->flush();
         $ret = ['success' => true, 'message' => $app->trans('Basket updated')];
     } catch (\Exception $e) {
     }
     return $app->json($ret);
 }
예제 #5
0
 /**
  * @param Basket $basket
  * @throws Exception
  */
 private function assertAtLeastOneElementAgreed(Basket $basket)
 {
     foreach ($basket->getElements() as $element) {
         if (null !== $element->getUserValidationDatas($this->getAuthenticatedUser())->getAgreement()) {
             return;
         }
     }
     $message = $this->app->trans('You have to give your feedback at least on one document to send a report');
     throw new Exception($message);
 }
예제 #6
0
파일: V1.php 프로젝트: nlegoff/Phraseanet
 /**
  * Retrieve elements of one basket
  *
  * @param  Basket $Basket
  *
  * @return type
  */
 private function list_basket_content(Application $app, Basket $Basket)
 {
     return array_map(function (BasketElement $element) use($app) {
         return $this->list_basket_element($app, $element);
     }, iterator_to_array($Basket->getElements()));
 }
예제 #7
0
 /**
  * Retrieve elements of one basket
  *
  * @param Request $request
  * @param Basket $basket
  * @return array
  */
 private function listBasketContent(Request $request, Basket $basket)
 {
     return array_map(function (BasketElement $element) use($request) {
         return $this->listBasketElement($request, $element);
     }, iterator_to_array($basket->getElements()));
 }
예제 #8
0
 /**
  * Retrieve elements of one basket
  *
  * @param  Basket $Basket
  * @return type
  */
 protected function list_basket_content(Basket $Basket)
 {
     $ret = [];
     foreach ($Basket->getElements() as $basket_element) {
         $ret[] = $this->list_basket_element($basket_element);
     }
     return $ret;
 }
 /**
  * {@inheritDoc}
  */
 public function getElements()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getElements', array());
     return parent::getElements();
 }