Injecting SecurityContext into a Listener prePersist or preUpdate in Symfony2 to get User in a createdBy or updatedBy Causes Circular Reference Error

I had similar problems and the only workaround was to pass the whole container in the constructor (arguments: [‘@service_container’]). use Doctrine\ORM\Event\LifecycleEventArgs; use Symfony\Component\DependencyInjection\ContainerInterface; class MyListener { protected $container; public function __construct(ContainerInterface $container) { $this->container = $container; } // … public function prePersist(LifeCycleEventArgs $args) { $securityContext = $this->container->get(‘security.context’); // … } }

pass array of conditions to doctrine expr()->orx() method

I hope so, then I found this : $conditions = array(‘e.type = x’, ‘e.type = Y’, ‘e.type = N’); $orX = $qb->expr()->orX(); foreach ($conditions as $condition) { $orX->add($condition); } $qb->add(‘where’, $orX); Using @meze suggestion, you can simplify the code and replace the foreach statement with: $orX->addMultiple($conditions);

PHP Mocking Final Class

Since you mentioned you don’t want to use any other framework, you are only leaving yourself one option: uopz uopz is a black magic extension of the runkit-and-scary-stuff genre, intended to help with QA infrastructure. uopz_flags is a function that can modify the flags of functions, methods and classes. <?php final class Test {} /** … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)