/**
  * Method for creating an instance of Comment using data taken from the comment form
  *
  * @param int $pageID
  * @param array $data
  * @param Content $content
  *
  * @return Comment
  */
 public function buildFromForm($pageID, array $data, Content $content)
 {
     $this->_validateData($data);
     $this->_contentValidator->validate($content);
     $comment = new Comment();
     $comment->setPageID($pageID);
     $comment->setName($data[self::NAME]);
     $comment->setEmail($data[self::EMAIL]);
     if (!empty($data[self::WEBSITE])) {
         $comment->setWebsite($data[self::WEBSITE]);
     }
     $comment->setContent($data[self::COMMENT]);
     $comment->setIpAddress($this->_request->getClientIp());
     if ($this->_user instanceof User) {
         $comment->setUserID($this->_user->id);
     }
     $this->_setStatus($comment, $content);
     return $comment;
 }
Example #2
0
 /**
  * Constructor. This is run before any modules are loaded, so we can
  * initialise the web request as a service here.
  *
  * The master request is instantiated and set on the service container,
  * along with the current request context.
  *
  * @param ContainerInterface $container The service container
  */
 public function __construct(ContainerInterface $container)
 {
     $this->_services = $container;
     $this->_services['http.request.master'] = function () {
         return \Message\Cog\HTTP\Request::createFromGlobals();
     };
     $this->_services['request'] = function ($c) {
         return $c['http.request.master'];
     };
     $this->_services['http.fragment_handler']->setRequest($this->_services['request']);
     $this->_services['http.request.context'] = $this->_services->factory(function ($c) {
         $context = new \Message\Cog\Routing\RequestContext();
         $context->fromRequest(isset($c['request']) ? $c['request'] : $c['http.request.master']);
         return $context;
     });
 }
Example #3
0
 public function testGetAllowedContentTypes()
 {
     $types = array('application/json', 'text/html');
     $request = new Request(array(), array(), array('_allowedContentTypes' => $types));
     $this->assertEquals($types, $request->getAllowedContentTypes());
 }
 protected function _getToken()
 {
     return $this->_request->get(self::STRIPE_TOKEN);
 }
 public function removeVoucher(Request $request, $type)
 {
     $this->setType($type);
     $form = $this->createForm($this->get('voucher.form.epos.remove'));
     $order = $this->get('epos.sale');
     $form->handleRequest();
     if ($form->isValid()) {
         $voucherID = $form->getData()['id'];
         $this->removeVoucherPayment($voucherID);
     }
     $view = $this->forward('Message:Mothership:Voucher::Controller:Epos#tenderVoucher');
     if ('json' === $request->getFormat($request->getAllowedContentTypes()[0])) {
         return new JsonResponse(['self' => $view->getContent(), 'tenderAmount' => $this->_getTotalVoucherPayment()]);
     }
     return $view;
 }