I'm using latest (dev-master) sonata admin and I want to create my own createAction() method for sonata admin. I have to do that, because I want to save some user information, while adding to database.
My custom controller is - S\CoreBundle\Controller\NewsAdminConroller.php
<?php
namespace S\CoreBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\Security\Core\SecurityContextInterface;
class NewsAdminController extends Controller
{
/**
* Set the system user ID
*/
private function updateFields($object)
{
//some code - this is my own method
}
public function createAction(Request $request = null)
{
//code for create ... it's almost the same as default code.
}
}
Default CRUD - Sonata\AdminBundle\Controller\CRUDController.php:
class CRUDController extends Controller
{
public function createAction(Request $request = null)
{
//...
}
}
Both createAction() methods have exactly the same arguments, name ...
And it throw's me an error:
PHP Strict Standards: Declaration of S\CoreBundle\Controller\NewsAdminController::createAction() should be compatible with Sonata\AdminBundle\Controller\CRUDController::createAction(Symfony\Component\HttpFoundation\Request $request = NULL) in /home/mark/dev/project/src/S/CoreBundle/Controller/NewsAdminController.php on line 129
use
statement for the Request - it is likely PHP is assuming it is from the same namespace as yourCRUDController
and so the declaration of your function is incompatible with the Sonata one. – madebydavid