Search code examples
phpsymfonypimcore

The controller for URI {url} is not callable


currently I am learning Pimcore which is made with Symfony (and I am a Laravel guy :3 ) So I have his error:

The controller for URI "/article/1132/This%20is%20my%20first%20post%20in%20Pimcore" is not callable:
 Expected method "blogarticleAction" on class "AppBundle\Controller\DefaultController".

I am trying to get an object (of blogpost) based on its ID and then to display that blogpost to the user.

I have made that controller with blogarticleAction method:

<?php

namespace AppBundle\Controller;

use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Pimcore\Model\DataObject;

class MyContentController extends FrontendController
{
    public function defaultAction(Request $request)
    {
        //$this->view->blogpostList = new DataObject\Blogpost\Listing();
        $list = new DataObject\Blogpost\Listing();

        $paginator = new \Zend\Paginator\Paginator($list);
        $paginator->setCurrentPageNumber( $request->get('page') );
        $paginator->setItemCountPerPage(3);
        $this->view->paginator  = $paginator;
    }

    public function blogarticleAction(Request $request)
    {
        $this->view->blogarticle = DataObject\Blogpost::getById($this->getParameter('id'));
    }
}

Also, here is my static route from the Pimcore admin panel: https://prnt.sc/w96ya3

Links seem to be formed correctly: https://prnt.sc/w96zvn

but when I click on that link to go to a single blogpost I get this: https://prnt.sc/w970kg


Solution

  • The error states that the method should exist on DefaultController and not on MyContentController. In the screenshot of your static route, you have used the DefaultController only.