Newscoop\GimmeBundle\Controller\AuthorsController::setArticleAuthorsOrderAction PHP Méthode

setArticleAuthorsOrderAction() public méthode

New order must be send with form in this format order={authorId}-{authorType},{authorId}-{authorType},{authorId}-{authorType},{authorId}-{authorType} example: order=7-1,8-1,5-2,4-2 All article author-author type pair must be send.
public setArticleAuthorsOrderAction ( Request $request, $number, $language )
$request Symfony\Component\HttpFoundation\Request
    public function setArticleAuthorsOrderAction(Request $request, $number, $language)
    {
        $em = $this->container->get('em');
        $authorService = $this->get('author');
        $articleAuthors = $em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($number, $language)->getResult();
        $order = explode(',', $request->get('order'));
        if (count($order) != count($articleAuthors)) {
            throw new InvalidParametersException("Number of sorted article authors must be this same as number of authors");
        }
        $authorService->reorderAuthors($em, $articleAuthors, $order);
    }