Hi,

how is it possible to dispatch just one Event object e.g. LowDepositEvent() instead of putting it to EventArgs.

Thanks.

Hi, I don't think I understand.

Hi,

that's what I have right now:

$this->eventManager->dispatchEvent(
    EventsLocator::DEPOSIT_RUNNING_LOW,
    new EventArgsList(
        array(
            new LowDepositEvent($serviceDeposit, $this->logger)
        )
    )
);

That's what I want to do

$this->eventManager->dispatchEvent(
    EventsLocator::DEPOSIT_RUNNING_LOW,
    new LowDepositEvent($serviceDeposit, $this->logger)
);

N.B: I would like to dispatch event inside PaymentSubscriber, but if I pass EventManager through constructor, DIC will shut with “Circular reference detected for services: eventManager, paymentSubscriber.” Is there any workaround e.g. Kdyby/Events could pass eventManager as second parameter after EventArgsList?

Thanks for any help.

That's not possible due to compatibility reasons. There always has to be an Arguments objects.

Or you can do this

$this->eventManager
    ->createEvent(EventsLocator::DEPOSIT_RUNNING_LOW)
    ->dispatch(new LowDepositEvent($serviceDeposit, $this->logger));

The EventArgsList is literary list of arguments, so there so no “other arguments”

$this->eventManager->dispatchEvent(
    EventsLocator::DEPOSIT_RUNNING_LOW,
    new EventArgsList(
        array(
            new LowDepositEvent($serviceDeposit, $this->logger),
            $this->eventManager
        )
    )
);

this will be invoked as

function depositRunningLow(LowDepositEvent $event, EventManager $evm)
{
    // ...
}

FYI, you might wanna rather implement custom EventArgs that extend Kdyby\Events\EventArgs, instead of creating such “event” classes.

$this->eventManager->dispatchEvent(
    EventsLocator::DEPOSIT_RUNNING_LOW,
    new LowDepositEventArgs($serviceDeposit, $this->logger)
}

this will be invoked as

function depositRunningLow(LowDepositEventArgs $args)
{
    // ...
}
  • Comments:

  • Thanks for reply. It makes sense.

    by Stanislav Bazik at 7.8.2014 10:02

You must first log in to participate in this discussion