The problem:
Any time I try to access the application I get this error:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to PL\\OrderBundle\\Entity\\OrderHasComment::__construct() must implement interface Symfony\\Component\\Security\\Core\\SecurityContextInterface, none given, called in /var/www/html/apps/portal_de_logistica/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php on line 416 and defined in /var/www/html/apps/portal_de_logistica/src/PL/OrderBundle/Entity/OrderHasComment.php line 48
What I'm doing wrong?
PL\\OrderBundle\\Entity\\OrderHasComment
's constructor asks for a mandatory argument but don't you provide it when you create a new instance of the object.
You're creating a new OrderHasComment (whatever that is) like this:
$object = new OrderHasComment() // <- missing argument
Remove that - it won't be needed anymore once your listener calls something like setContext(...)
and it's not needed to create the object ... so it shouldn't be mandatory anyways.
// remove the mandatory argument or provide a default (i.e. $context = null)
public function __construct(ContextInterface $context) /
{
// ...
... should become:
public function __construct()
{
This solves the issue that's responsible for the exception.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.