Thanks, I'll keep it in mind. if you just advice for my another email about
properties/flag between listeners and subscribers I will be just fine.
Thanks,


On Thu, Aug 13, 2015 at 8:38 PM, Marco Pivetta <[email protected]> wrote:

> There is some confusion in your thought process, I fear.
>
> Simply consider removing the listeners on the entity itself (as well as
> the entity listeners) and use just a subscriber. You can pass all the
> dependencies you need to the subscriber constructor.
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
> On 13 August 2015 at 15:36, Nima Sadjadi <[email protected]> wrote:
>
>>
>> Please read my previous email first, I did read the manual again and if I
>> understood this time correctly, subscriber inherits listener and not vice
>> versa so:
>>
>> class SomeEntityListener
>> {
>>    public function prePersistHandler(Something $something,
>> LifecycleEventArgs $eventArgs)
>>     {
>>           // do something
>>     }
>> }
>>
>> class MailerSubscriber {
>>
>>    // constructor goes here to fire emailer.
>>
>>     public function prePersistHandler()
>>     {
>>         // do emailing
>>     }
>>
>>     public function getSubscribedEvents()
>>     {
>>         return array(SomeListener::prePersistHandler.
>> SomeListener::postPersistHandler, etc....);
>>     }
>>
>> }
>>
>> this way, first the job of listener will be done then the emailer job of
>> subscriber? am I correct?
>>
>>
>>
>> On Thu, Aug 13, 2015 at 6:54 PM, Nima Sadjadi <[email protected]> wrote:
>>
>>>
>>> Hi,
>>>
>>> Thanks for trying to help, I did look at the manual. If I create an
>>> emailer service as an EventSubcriber, then:
>>>
>>> $eventManager = new EventManager();
>>> $eventManager->addEventSubscriber(new MailerSubscriber($params));
>>> $entityManager = EntityManager::create($dbOpts, $config, $eventManager);
>>>
>>> Then in my entity listener class, all methods of MailerSubscriber()
>>> class will be available as $eventArgs->someMethodsOfMailerSubscriber() ? or
>>> there is a particular method to get MailerSubscriber instance or methods
>>> insider an entity listener class?
>>>
>>> in entity class I use:
>>> $metadata->addEntityListener('prePersist', 'SomeEntityListener',
>>> 'prePersistHandler');
>>>
>>> then in listener class:
>>>
>>> class SomeEntityListener
>>> {
>>>    public function prePersistHandler(Something $something,
>>> LifecycleEventArgs $eventArgs)
>>>     {
>>>           $blah = $eventArgs->someMethodsOfMailerSubscriber() ??
>>>     }
>>> }
>>>
>>> or what to do? I am confused. please clarify.
>>>
>>>
>>> On Thu, Aug 13, 2015 at 5:42 PM, Marco Pivetta <[email protected]>
>>> wrote:
>>>
>>>> You'd pass it to an event subscriber, not to an event listener. An
>>>> event subscriber can be built as a service, and can have dependencies.
>>>>
>>>> See http://doctrine-orm.readthedocs.org/en/latest/reference/events.html
>>>>
>>>> Marco Pivetta
>>>>
>>>> http://twitter.com/Ocramius
>>>>
>>>> http://ocramius.github.com/
>>>>
>>>> On 13 August 2015 at 14:10, Nima Sadjadi <[email protected]> wrote:
>>>>
>>>>> Is it possible or not possible?
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "doctrine-user" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "doctrine-user" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to