Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add controller's implemented interfaces to its shared event manager default identifiers #6615

Closed

Conversation

SwissEngine
Copy link

Apparently, from the shared manager, it is not possible to attach a callback to a controller (dispatch event) from an interface id it implements.

I simply added the list of the implemented classes to the identifiers. This adds the possibility to do this:

// Module.php - this was never triggered
$eventManager->getSharedManager()->attach(LambdaControllerInterface::class, 'dispatch', [
    $this, 'myCallback'
]);

// MyController.php
class MyController extends AbstractActionController implements LambdaControllerInterface
{
}

I am not an expert on the event managers, waiting for some feedback before adding some tests.

@SwissEngine SwissEngine changed the title Add controller's implemented interfaces to event manager identifiers Add controller's implemented interfaces to its shared event manager default identifiers Aug 30, 2014
@Ocramius
Copy link
Member

@SwissEngine can you please rebase this? There's an unrelated commit in it. Additionally, tests required.

));
);

$instanceof = class_implements($this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May just if ($instanceOf = class_implements($this)) { instead

@tca3 tca3 force-pushed the controllers-identifiers branch from 0861e31 to e63d5e1 Compare October 11, 2014 10:14
@SwissEngine
Copy link
Author

@Ocramius rebased and changed, will write tests today

namespace ZendTest\Mvc\Controller\TestAsset;

interface SampleInterface
{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end with

{
}

and a new line at end of file

@Ocramius Ocramius self-assigned this Nov 22, 2014
@Ocramius Ocramius added this to the 2.4.0 milestone Nov 22, 2014
@Ocramius
Copy link
Member

Related to #6553

@Ocramius
Copy link
Member

@SwissEngine this was manually merged into develop at 1757e06, thanks!

@Ocramius Ocramius closed this Nov 22, 2014
Ocramius added a commit that referenced this pull request Nov 22, 2014
…greatly depending on interface/class inheritance
Ocramius added a commit that referenced this pull request Nov 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants