This topic contains 2 replies, has 2 voices, and was last updated by golriz.nourani 9 years ago.
- Topic
Dear Sir
I have jobs(which run by oro cron) inside of some of this jobs I want to dispatch an event so :——————-
namespace \Bundle\EventDispatcherBundle;
final class SmsEvents
{const SMS_RECEIVE = ‘sms.receive’;
}—————–
namespace \Bundle\EventDispatcherBundle\Event;
use Symfony\Component\EventDispatcher\Event;
use \Bundle\SmsBundle\Entity\Sms;
use \Bundle\SmsBundle\Entity\SendSms;class SmsReceiveEvent extends Event
{
protected $sms;public function __construct(Sms $sms)
{
$this->sms = $sms;
}public function getSms()
{
return $this->sms;
}
}——————-
namespace \Bundle\EventDispatcherBundle\EventListener;use \Bundle\EventDispatcherBundle\Event\SmsReceiveEvent;
class SmsListener
{
public function onSmsReceivedAction(SmsReceiveEvent $event)
{************************************
my code
*********************************
}
}————————–
namespace \Bundle\SmsBundle\Command;use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\EventDispatcher\EventDispatcher;
use \Bundle\EventDispatcherBundle\Event\SmsReceiveEvent;
use \Bundle\EventDispatcherBundle\SmsEvents;
use \Bundle\SmsBundle\Entity\Sms;class ProcessSMSCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName(‘my:sms:process’);
}protected function execute(InputInterface $input, OutputInterface $output)
{
$dispatcher = $this->getContainer()->get(‘event_dispatcher’);
$event = new SmsReceiveEvent($sms);
$dispatcher->dispatch(SmsEvents::SMS_RECEIVE, $event);
}
}————-
service.yml of EventDispatcherBundleservices:
sms.listner:
class: \Bundle\EventDispatcherBundle\EventListener\SmsListener
tags:
– { name: sms.event_listener, event: sms.receive, method: onSmsReceivedAction }——————-
my code have not any error but the code inside of listener was not run !!!
please help me :(regards,
Golriz
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.