-
Notifications
You must be signed in to change notification settings - Fork 111
Add delegator factory for AuthorizationServiceAwareInterface #249
Conversation
public function getServiceConfig() | ||
{ | ||
return [ | ||
'invokables' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check alignment ;)
@bakura10 good enough for merge ? |
{ | ||
public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback) | ||
{ | ||
$instanceToDecorate = call_user_func($callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$callback()
👍 |
@@ -20,6 +20,7 @@ | |||
'service_manager' => [ | |||
'invokables' => [ | |||
'ZfcRbac\Collector\RbacCollector' => 'ZfcRbac\Collector\RbacCollector', | |||
'ZfcRbac\Factory\AuthorizationServiceDelegator' => 'ZfcRbac\Factory\AuthorizationServiceDelegatorFactory', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment of "=" please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an invokable here
I don't know what to think of that. To me this seems like a misuse of the delegators. As I understand them, the delegators use is rather to decorate an existing factory, so you can reuse a third-party factory and decorate it rather than rewriting the whole factory. However, here, it is really used as a replacement of initializer. I feel a bit bad about it. @Ocramius, do you validate this as a correct usage of delegators? |
{ | ||
$instanceToDecorate = call_user_func($callback); | ||
|
||
if ($instanceToDecorate instanceof AuthorizationServiceAwareInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should actually throw an exception here, in case the service doesn't implement the expected interface.
Yes it is.
Why ? |
Add delegator factory for AuthorizationServiceAwareInterface
Another proposal 😉
Delegator factories are better than interfaces for performances.