Skip to content

Commit

Permalink
[Core] Fixes Permissions entity: Get assignment specification returns…
Browse files Browse the repository at this point in the history
… "double depth"-array.
  • Loading branch information
TiSiE committed Apr 10, 2015
1 parent 221565a commit 9468239
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions module/Core/src/Core/Entity/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ class Permissions implements PermissionsInterface
*/
public function __construct($type = null)
{
if (!$type) {
$this->type = get_class($this);
}
$this->type = $type ?: get_class($this);
}

/**
Expand Down Expand Up @@ -204,10 +202,12 @@ public function grant ($resource, $permission = null, $build = true)
unset($this->assigned[$resourceId]);
} else {
if ($resource instanceOf PermissionsResourceInterface) {
$spec = null === $permission
? $resource->getPermissionsUserIds($this->type)
: array($permission => $resource->getPermissionsUserIds());

$spec = $resource->getPermissionsUserIds($this->type);
if (!is_array($spec) || !count($spec)) {
$spec = array();
} else if (is_numeric(key($spec))) {
$spec = array($permission => $spec);
}
} else {
$spec = array($permission => $resource instanceOf UserInterface ? array($resource->getId()) : array($resource));
}
Expand Down

0 comments on commit 9468239

Please sign in to comment.