Acl assertions enhancement #5628

Merged
merged 6 commits into from Mar 4, 2014

Conversation

Projects
None yet
5 participants
Contributor

gauthier commented Dec 18, 2013

AssertionAggregate allows aggregating multiple assertion to be associated with one ACL rule. This has been done without modifying a single file of existing code.

AssertionManager is a simple Plugin Manager allowing to declare Acl asseertions as services. It can be used by AssertionAggregate to add assertions by passing their service name. It could also by used by the Acl component itself, and should be declared as a default service, so that it could rely on Config service to get intialized, but those features would need to alter existing code and I didn't want to do that at this time.

Maks3w and others added some commits Dec 16, 2013

added AssertionAggregate and AssertionManager
AssertionAggregate allows aggregating multiple assertion to be associated with one ACL rule. This has been done without modifying a single file of existing code.

AssertionManager is a simple Plugin Manager allowing to declare Acl asseertions as services. It can be used by AssertionAggregate to add assertions by passing their service name. It could also by used by the Acl component itself, and should be declared as a default service, so that it could rely on Config service to get intialized, but those features would need to alter existing code and I didn't want to do that at this time.
+ * @param AssertionInterface|string $assertion
+ * if string, must match a AssertionManager declared service (checked later)
+ *
+ * @return \Zend\Permissions\Acl\Assertion\AssertionAggregate
+ /**
+ * Empties assertions stack
+ *
+ * @return \Zend\Permissions\Acl\Assertion\AssertionAggregate
+ *
+ * @param AssertionManager $manager
+ *
+ * @return \Zend\Permissions\Acl\Assertion\AssertionAggregate
+ * indicates how assertion chain result should interpreted (either 'all' or 'at_least_one')
+ * @throws Exception
+ *
+ * @return \Zend\Permissions\Acl\Assertion\AssertionAggregate
+ public function validatePlugin($plugin)
+ {
+ if (! $plugin instanceof AssertionInterface) {
+ throw new InvalidArgumentException(sprintf('Plugin of type %s is invalid; must implement Zend\Permissions\Acl\Assertion\AssertionInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin))));
@samsonasik

samsonasik Dec 18, 2013

Contributor

I think it should be multiline

@gauthier

gauthier Dec 18, 2013

Contributor

the code has been reformated using php-cs-fixer with level psr2... since it's checked using this tool, I guess it's ok like this :)

by the way, the travis built passed

@danizord

danizord Dec 18, 2013

Contributor

PSR 2:

The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit.
Lines SHOULD NOT be longer than 80 characters; lines longer than that SHOULD be split into multiple subsequent lines of no more than 80 characters each.

+ *
+ * @param mixed $plugin
+ * @throws Zend\PErmissions\Acl\Exception\InvalidElementException
+ * @return void
+ * Checks that the element is an instance of AssertionInterface
+ *
+ * @param mixed $plugin
+ * @throws Zend\PErmissions\Acl\Exception\InvalidElementException
@samsonasik

samsonasik Dec 18, 2013

Contributor

@throws InvalidArgumentException , not InvalidElementException

+ *
+ * @var
+ *
+ */
@weierophinney

weierophinney Mar 3, 2014

Owner

Either remove the docblock, or make it useful. :)

@gauthier

gauthier Mar 3, 2014

Contributor

humm... looks like this was a "temporary" comment to ease Code Insight or something like this - sorry :) I just removed it.

@weierophinney weierophinney added this to the 2.3.0 milestone Mar 3, 2014

Owner

weierophinney commented Mar 3, 2014

Looks great!

weierophinney added a commit that referenced this pull request Mar 4, 2014

weierophinney added a commit that referenced this pull request Mar 4, 2014

[#5628] CS fixes
- trailing whitespace

weierophinney added a commit that referenced this pull request Mar 4, 2014

@weierophinney weierophinney merged commit 17c3127 into zendframework:develop Mar 4, 2014

1 check failed

default The Travis CI build could not complete due to an error
Details

@weierophinney weierophinney self-assigned this Mar 4, 2014

@arekkas arekkas referenced this pull request in ZF-Commons/zfc-rbac Apr 6, 2014

Open

AssertionAggregate? #217

weierophinney added a commit to zendframework/zend-permissions-acl that referenced this pull request May 15, 2015

Merge pull request zendframework/zendframework#5628 from gauthier/acl…
…_assertions_enhancement

Acl assertions enhancement

weierophinney added a commit to zendframework/zend-permissions-acl that referenced this pull request May 15, 2015

weierophinney added a commit to zendframework/zend-permissions-acl that referenced this pull request May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment