-
Notifications
You must be signed in to change notification settings - Fork 86
Use 'Acl.' as plugin prefix and pluralized class name in ACL behavior #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ee89556
a85460c
87c8b2b
6a55b27
2a792d2
2c70ead
bdaf495
e506259
e82e745
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -72,15 +72,16 @@ public function __construct(Table $model, array $config = []) | |||||
| } | ||||||
| foreach ($types as $type) { | ||||||
| $alias = Inflector::pluralize($type); | ||||||
| $className = App::className($alias . 'Table', 'Model/Table'); | ||||||
| $className = App::className($alias, 'Model/Table', 'Table'); | ||||||
| if ($className == false) { | ||||||
| $className = App::className('Acl.' . $alias . 'Table', 'Model/Table'); | ||||||
| $className = App::className('Acl.' . $alias, 'Model/Table', 'Table'); | ||||||
| } | ||||||
| $config = []; | ||||||
| if (!TableRegistry::getTableLocator()->exists($alias)) { | ||||||
| $config = ['className' => $className]; | ||||||
| } | ||||||
| $model->hasMany($type, [ | ||||||
|
|
||||||
| $model->hasMany($alias, [ | ||||||
| 'targetTable' => TableRegistry::getTableLocator()->get($alias, $config), | ||||||
| ]); | ||||||
| } | ||||||
|
|
@@ -94,7 +95,7 @@ public function __construct(Table $model, array $config = []) | |||||
| * Retrieves the Aro/Aco node for this model | ||||||
| * | ||||||
| * @param string|array|Model $ref Array with 'model' and 'foreign_key', model object, or string value | ||||||
| * @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node | ||||||
| * @param string $type Pluralized! Only needed when Acl is set up as 'both', specify 'Aros' or 'Acos' to get the correct node | ||||||
| * @return \Cake\ORM\Query | ||||||
| * @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html#node | ||||||
| * @throws \Cake\Core\Exception\Exception | ||||||
|
|
@@ -113,7 +114,12 @@ public function node($ref = null, $type = null) | |||||
| throw new Exception\Exception(__d('cake_dev', 'ref parameter must be a string or an Entity')); | ||||||
| } | ||||||
|
|
||||||
| return $this->_table->{$type}->node($ref); | ||||||
| if(property_exists($this->_table, $type)){ | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
You'll need to apply the code formatting standards. You can do that with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @markstory sorry for my late response to this. I guess otherwise the diff is getting to large. What do you think?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, we can update phpcs separately. |
||||||
| return $this->_table->{$type}->node($ref); | ||||||
| }else{ | ||||||
| $type = Inflector::pluralize($type); | ||||||
| return $this->_table->{$type}->node($ref); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -131,6 +137,7 @@ public function afterSave(Event $event, Entity $entity) | |||||
| $types = [$types]; | ||||||
| } | ||||||
| foreach ($types as $type) { | ||||||
| $type = Inflector::pluralize($type); | ||||||
| $parent = $entity->parentNode(); | ||||||
| if (!empty($parent)) { | ||||||
| $parent = $this->node($parent, $type)->first(); | ||||||
|
|
@@ -171,6 +178,7 @@ public function afterDelete(Event $event, Entity $entity) | |||||
| $types = [$types]; | ||||||
| } | ||||||
| foreach ($types as $type) { | ||||||
| $type = Inflector::pluralize($type); | ||||||
| $node = $this->node($entity, $type)->toArray(); | ||||||
| if (!empty($node)) { | ||||||
| $event->getSubject()->{$type}->delete($node[0]); | ||||||
|
|
||||||
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.
This will need to be reverted in order to be merged.