Newscoop\GimmeBundle\Controller\ArticlesController::patchArticleAction PHP Méthode

patchArticleAction() public méthode

Additional form aparameters: fields: array with article type fields and ther values. article[fields][lead] = 'new lead'
public patchArticleAction ( Request $request, $number, $language )
$request Symfony\Component\HttpFoundation\Request
    public function patchArticleAction(Request $request, $number, $language)
    {
        $em = $this->container->get('em');
        $user = $this->container->get('user')->getCurrentUser();
        if (!$user->hasPermission('AddArticle')) {
            throw new AccessDeniedException('You do not have the right to add articles.');
        }
        $article = $em->getRepository('Newscoop\\Entity\\Article')->getArticle($number, $request->get('language'))->getOneOrNullResult();
        if (!$article) {
            throw new NotFoundHttpException('Article was not found');
        }
        $form = $this->createForm(new ArticleType($article->getData(null)), array(), array('method' => $request->getMethod()));
        $form->handleRequest($request);
        if ($form->isValid()) {
            $articleService = $this->container->get('newscoop_newscoop.article_service');
            $attributes = $form->getData();
            $article = $articleService->updateArticle($article, $attributes);
            $this->postAddUpdate($article);
            return new FOSView\View($article, 200, array('X-Location' => $this->generateUrl('newscoop_gimme_articles_getarticle', array('number' => $article->getId()), true)));
        } else {
            // TODO add support for global for errors handler
        }
        return new FOSView\View($form, 400);
    }