/** * {@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; }
/** * * @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; }
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); }
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); }
/** * @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); }
/** * 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())); }
/** * 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())); }
/** * 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(); }