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

Add delegator factory for AuthorizationServiceAwareInterface #249

Merged
merged 8 commits into from
Jun 22, 2014

Conversation

jmleroux
Copy link
Contributor

Another proposal 😉
Delegator factories are better than interfaces for performances.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.45%) when pulling c4d235b on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.45%) when pulling 5f210d7 on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling bfd366b on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling 1716390 on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling 57ce9af on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling 57ce9af on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

public function getServiceConfig()
{
return [
'invokables' => [
Copy link
Contributor

Choose a reason for hiding this comment

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

Check alignment ;)

@jmleroux jmleroux changed the title Add delegator factor for AuthorizationServiceAwareInterface Add delegator factory for AuthorizationServiceAwareInterface Jun 20, 2014
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling f77eaca on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

@jmleroux
Copy link
Contributor Author

@bakura10 good enough for merge ?

{
public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
{
$instanceToDecorate = call_user_func($callback);
Copy link
Member

Choose a reason for hiding this comment

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

$callback()

@danizord
Copy link
Member

👍

@@ -20,6 +20,7 @@
'service_manager' => [
'invokables' => [
'ZfcRbac\Collector\RbacCollector' => 'ZfcRbac\Collector\RbacCollector',
'ZfcRbac\Factory\AuthorizationServiceDelegator' => 'ZfcRbac\Factory\AuthorizationServiceDelegatorFactory',
Copy link
Member

Choose a reason for hiding this comment

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

Alignment of "=" please.

Copy link
Contributor

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

@bakura10
Copy link
Member

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) {
Copy link
Contributor

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.

@jmleroux
Copy link
Contributor Author

However, here, it is really used as a replacement of initializer.

Yes it is.

I feel a bit bad about it.

Why ?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.25%) when pulling 92c94b9 on jmleroux:delegator-factory into 8cf2a49 on ZF-Commons:master.

bakura10 added a commit that referenced this pull request Jun 22, 2014
Add delegator factory for AuthorizationServiceAwareInterface
@bakura10 bakura10 merged commit 926a57f into ZF-Commons:master Jun 22, 2014
@jmleroux jmleroux deleted the delegator-factory branch June 22, 2014 11:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants