post

@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since  0.8.0

@Template
@ParamConverter("journal", class="Phospr\CoreBundle\Entity\Journal")

@param  Request $request
@param  Journal $journal
429018
public function postAction(Request $request, Journal $journal)
    {
        $em = $this->get('doctrine')->getManager();

        $account = $em
            ->getRepository('PhosprCoreBundle:Account')
            ->findOneBy(array('path' => $request->get('path')))
        ;

        $journal->post();

        $em->persist($journal);
        $em->flush();

        return $this->redirect($this->generateUrl(
            'phospr_account_show', array('path' => $account->getPath())
        ));
    }
1300386
public function postAction(Request $request)
    {
        try {
            $shipping = $this->getManager()->save(
                $request->request->all(),
                $this->getLocaleManager()->retrieveLocale($this->getUser(), $request->get('locale')),
                $this->getUser()->getId()
            );

            $view = $this->view($shipping, 200);
        } catch (ShippingDependencyNotFoundException $exc) {
            $exception = new EntityNotFoundException($exc->getEntityName(), $exc->getId());
            $view = $this->view($exception->toArray(), 400);
        } catch (MissingShippingAttributeException $exc) {
            $exception = new MissingArgumentException(self::$shippingEntityName, $exc->getAttribute());
            $view = $this->view($exception->toArray(), 400);
        }

        return $this->handleView($view);
    }
1134654
public function archiveMonthlyAction($year, $month, Request $request = null)
    {
        $action = $this->container->get(MonthlyPostArchiveAction::class);

        return $action($this->resolveRequest($request), $year, $month);
    }
1085649
public function publishAction(Request $request, $id)
    {
        $this->init($request);
        /* @var Node $node */
        $node = $this->em->getRepository('KunstmaanNodeBundle:Node')->find($id);

        $nodeTranslation = $node->getNodeTranslation($this->locale, true);
        $request = $this->get('request_stack')->getCurrentRequest();
        $this->nodePublisher->chooseHowToPublish($request, $nodeTranslation, $this->translator);

        return $this->redirect($this->generateUrl('KunstmaanNodeBundle_nodes_edit', array('id' => $node->getId())));
    }
777556
public function showAction(Request $request, Account $account)
    {
        $this->get('white_october_breadcrumbs')
            ->addItem('Home',
                $this->get('router')->generate('_homepage')
            )
            ->addItem('Accounts',
                $this->get('router')->generate('phospr_account')
            )
        ;

        $treePath = $this->get('phospr.account_handler')
            ->getTreePath($account)
        ;

        foreach ($treePath as $node) {
            if ($node->getLvl()) {
                $this->get('white_october_breadcrumbs')
                    ->addItem($node->getName(),
                        $this->get('router')->generate('phospr_account_show', array(
                            'path' => $node->getPath()
                    )))
                ;
            }
        }

        $calculatedBalance = 0;

        foreach ($account->getPostings() as $posting) {
            $calculatedBalance += $posting->getAmount();

            $posting->setCalculatedBalance($calculatedBalance);
        }

        $journal = $this->get('phospr.journal_handler')->createJournal();

        $form = $this->createForm(new SimpleJournalType(), $journal);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->get('doctrine')->getManager();

            $amount  = $form->getData()->getCreditAmount();
            $amount -= $form->getData()->getDebitAmount();

            $ph = $this->get('phospr.posting_handler');

            $form->getData()->addPosting($ph->createPosting($account, $amount));
            $form->getData()->addPosting($ph->createPosting(
                $form->getData()->getOffsetAccount(),
                -1*$amount
            ));

            $em->persist($form->getData());
            $em->flush();

            return $this->redirect($this->generateUrl(
                'phospr_account_show', array('path' => $account->getPath())
            ));
        }

        return array(
            'account' => $account,
            'form'    => $form->createView(),
        );
    }
530652
public function postNavigation(Request $request, Page $page)
    {
        $this->authorize('editNavBasic', $page);

        if (Gate::allows('editNavAdvanced', $page)) {
            $parent = Page::find($request->input('parent_id'));

            if ($parent) {
                $page->setParent($parent);
            }
        }

        $page
            ->setVisibleInNav($request->has('visible_in_nav'))
            ->setVisibleInCmsNav($request->has('visible_in_nav_cms'));

        PageFacade::save($page);
    }
396084
public function publishAction(Request $request)
    {
        $tid = $request->get('tid');
        $teaserId = $request->get('teaser_id', null);
        $version = $request->get('version', null);
        $language = $request->get('language');
        $comment = $request->get('comment', '');

        //$fileUsage = new Makeweb_Elements_Element_FileUsage(MWF_Registry::getContainer()->dbPool);

        if (!$teaserId) {
            $treeManager = $this->get('phlexible_tree.tree_manager');
            $tree = $treeManager->getByNodeId($tid);
            $node = $tree->get($tid);

            $tree->publish($node, $version, $language, $this->getUser()->getId(), $comment);

            #$eid = $node->getEid();
            //$fileUsage->update($node->getEid());

            $data = [];

            #$elementVersionManager = Makeweb_Elements_Element_Version_Manager::getInstance();
            #$elementVersion = $elementVersionManager->get($node->getEid(), $version);

            $data['status'] = $tree->isAsync($node, $language) ? 'async' : ($tree->isPublished($node, $language) ? 'online' : null);
            $data['instance'] = ($tree->isInstance($node) ? ($tree->isInstanceMaster($node) ? 'master' : 'slave') : false);
            #$data['icon'] = $elementVersion->getIconUrl($node->getIconParams($language));

            $response = new ResultResponse(true, 'TID "'.$tid.'" published.', $data);
        } else {
            $teaserManager = $this->get('phlexible_teaser.teaser_manager');
            $teaser = $teaserManager->find($teaserId);

            $eid = $teaserManager->publishTeaser($teaser, $version, $language, $this->getUser()->getId(), $comment);

            //$fileUsage->update($eid);

            $response = new ResultResponse(true, "Teaser ID $teaserId published.");
        }

        return $response;
    }
1108249
public function setRequest(Request $request)
    {
        $this->request = $request;
        $this->context->registerInstance($request);
    }
253556
public function addJournal(\HarvestCloud\CoreBundle\Entity\Journal $journal)
    {
        $this->journals[] = $journal;

        return $this;
    }
361533
public function postChildren(Request $request, Page $page)
    {
        $this->authorize('editChildrenBasic', $page);

        $post = $request->input();

        $page->setChildTemplateId($request->input('children_template_id'));

        if (Gate::allows('editChildrenAdvanced', $page)) {
            $page
                ->setChildrenUrlPrefix($request->input('children_url_prefix'))
                ->setChildrenVisibleInNav($request->has('children_visible_in_nav'))
                ->setChildrenVisibleInNavCms($request->has('children_visible_in_nav_cms'))
                ->setGrandchildTemplateId($request->input('grandchild_template_id'));
        }

        if (isset($post['children_ordering_policy']) && isset($post['children_ordering_direction'])) {
            $page->setChildOrderingPolicy($post['children_ordering_policy'], $post['children_ordering_direction']);
        }

        PageFacade::save($page);
    }
429496
public function send(Request $request)
    {
        $response   = new PutSchemaResponse();
        $rpbPutReq  = $this->createRpbMessage($request);

        $this->client->send($rpbPutReq, RiakMessageCodes::YOKOZUNA_SCHEMA_PUT_REQ, RiakMessageCodes::PUT_RESP);

        return $response;
    }
255916
public function publishAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $em->getFilters()->disable('draft');

        $owner        = $request->request->get('owner');
        $ownerId      = (int) $request->request->get('ownerId');

        /** @var BlockManager $manager */
        $manager  = $this->get('opifer.content.block_manager');
        /** @var BlockProviderInterface $provider */
        $provider = $this->get('opifer.content.block_provider_pool')->getProvider($owner);
        $response = new JsonResponse;

        $object = $provider->getBlockOwner($ownerId);
        $object->setUpdatedAt(new \DateTime());

        try {
            $manager->publish($object->getBlocks());

            $response->setStatusCode(200);
            $response->setData(['state' => 'published']);
        } catch (\Exception $e) {
            $response->setStatusCode(500);
            $response->setData(['error' => $e->getMessage() . $e->getTraceAsString()]);
        }

        $em->flush($object);

        return $response;
    }
488850
public function post()
    {
        // Create Vendor Journal
        $vendorJournal = new InvoiceJournal($this);
        $vendorJournal->debit($this->getVendor()->getAccountsReceivableAccount(), $this->getAmount());
        $vendorJournal->credit($this->getVendor()->getSalesAccount(), $this->getAmount());

        // Add Vendor Journal to Invoice
        $this->addJournal($vendorJournal);

        // Create Customer Journal
        $customerJournal = new InvoiceJournal($this);
        $customerJournal->debit($this->getCustomer()->getAccountsPayableAccount(), $this->getAmount());
        $customerJournal->credit($this->getCustomer()->getPurchasesAccount(), $this->getAmount());

        // Add Customer Journal to Invoice
        $this->addJournal($customerJournal);

        parent::post();
    }
1082912
public function supports(Request $request)
    {
        $post = json_decode($request->getContent(), true);

        return !empty($post[self::TOKEN_FIELD]);
    }
845841
protected function doPost(Request $request)
    {
        $accountManager = $this->getAccountManager();
        $account = $this->get('sulu_contact.account_factory')->createEntity();
        $account->setName($request->get('name'));
        $account->setCorporation($request->get('corporation'));

        if (null !== $request->get('uid')) {
            $account->setUid($request->get('uid'));
        }

        if (null !== $request->get('note')) {
            $account->setNote($request->get('note'));
        }

        $logo = $request->get('logo', []);
        if ($logo && array_key_exists('id', $logo)) {
            $accountManager->setLogo($account, $request->get('logo')['id']);
        }

        $this->setParent($request->get('parent'), $account);

        $accountManager->processCategories($account, $request->get('categories', []));

        $account->setCreator($this->getUser());
        $account->setChanger($this->getUser());

        // Add urls, phones, emails, tags, bankAccounts, notes, addresses,..
        $accountManager->addNewContactRelations($account, $request->request->all());

        return $account;
    }
812485
protected function newPostAction(Request $request)
    {
        $entityManager = $this->get('doctrine.orm.entity_manager');
        $page = $this->getNewPage();

        $form = $this->get('form.factory')->create($this->getNewPageType(), $page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $page = $this->get('victoire_page.page_helper')->setPosition($page);
            $page->setAuthor($this->getUser());
            $entityManager->persist($page);
            $entityManager->flush();

            // If the $page is a BusinessEntity (eg. an Article), compute it's url
            if (null !== $this->get('victoire_core.helper.business_entity_helper')->findByEntityInstance($page)) {
                $page = $this
                    ->get('victoire_business_page.business_page_builder')
                    ->generateEntityPageFromTemplate($page->getTemplate(), $page, $entityManager);
            }

            $this->congrat($this->get('translator')->trans('victoire_page.create.success', [], 'victoire'));

            return $this->getViewReferenceRedirect($request, $page);
        }

        return [
            'success' => false,
            'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->get('templating')->render(
                $this->getBaseTemplatePath().':new.html.twig',
                ['form' => $form->createView()]
            ),
        ];
    }
66680
public function postRequestAsync( Request $request ) {
		$promise = $this->getClient()->requestAsync(
			'POST',
			$this->apiUrl,
			$this->getClientRequestOptions( $request, $this->getPostRequestEncoding( $request ) )
		);

		return $promise->then( function ( ResponseInterface $response ) {
			return call_user_func( [ $this, 'decodeResponse' ], $response );
		} );
	}