@@ -47,6 +47,9 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $property |
|
| 52 | + */ |
|
| 50 | 53 | public function addResolvable($property) { |
| 51 | 54 | $this->_resolvedProperties[$property] = null; |
| 52 | 55 | } |
@@ -63,6 +66,10 @@ discard block |
||
| 63 | 66 | } |
| 64 | 67 | } |
| 65 | 68 | |
| 69 | + /** |
|
| 70 | + * @param string $property |
|
| 71 | + * @param \Closure $resolver |
|
| 72 | + */ |
|
| 66 | 73 | public function resolveRelation($property, $resolver) { |
| 67 | 74 | if($property !== null && $this->$property !== null) { |
| 68 | 75 | $result = $resolver($this->$property); |
@@ -64,32 +64,32 @@ |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function resolveRelation($property, $resolver) { |
| 67 | - if($property !== null && $this->$property !== null) { |
|
| 67 | + if ($property !== null && $this->$property !== null) { |
|
| 68 | 68 | $result = $resolver($this->$property); |
| 69 | 69 | } else { |
| 70 | 70 | $result = null; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if($result instanceof RelationalObject || $result === null) { |
|
| 73 | + if ($result instanceof RelationalObject || $result === null) { |
|
| 74 | 74 | $this->_resolvedProperties[$property] = $result; |
| 75 | 75 | } else { |
| 76 | 76 | throw new \Exception('resolver must return an instance of RelationalObject'); |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function __call($methodName, $args){ |
|
| 81 | - $attr = lcfirst( substr($methodName, 7) ); |
|
| 82 | - if(strpos($methodName, 'resolve') === 0 && array_key_exists($attr, $this->_resolvedProperties)) { |
|
| 83 | - if($this->_resolvedProperties[$attr] !== null) { |
|
| 80 | + public function __call($methodName, $args) { |
|
| 81 | + $attr = lcfirst(substr($methodName, 7)); |
|
| 82 | + if (strpos($methodName, 'resolve') === 0 && array_key_exists($attr, $this->_resolvedProperties)) { |
|
| 83 | + if ($this->_resolvedProperties[$attr] !== null) { |
|
| 84 | 84 | return $this->_resolvedProperties[$attr]; |
| 85 | 85 | } else { |
| 86 | 86 | return $this->getter($attr, $args); |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $attr = lcfirst( substr($methodName, 3) ); |
|
| 91 | - if(strpos($methodName, 'set') === 0 && array_key_exists($attr, $this->_resolvedProperties)) { |
|
| 92 | - if(!is_scalar($args[0])) { |
|
| 90 | + $attr = lcfirst(substr($methodName, 3)); |
|
| 91 | + if (strpos($methodName, 'set') === 0 && array_key_exists($attr, $this->_resolvedProperties)) { |
|
| 92 | + if (!is_scalar($args[0])) { |
|
| 93 | 93 | $args[0] = $args[0]['primaryKey']; |
| 94 | 94 | parent::setter($attr, $args); |
| 95 | 95 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | 57 | public function searchUser($search) { |
| 58 | - if($search==='%') { |
|
| 58 | + if ($search === '%') { |
|
| 59 | 59 | $search = ''; |
| 60 | 60 | } |
| 61 | 61 | $limit = 5; |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | $groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups']); |
| 63 | 63 | $complete = array_merge($userBoards, $groupBoards); |
| 64 | 64 | $result = []; |
| 65 | - foreach($complete as &$item) { |
|
| 66 | - if(!array_key_exists($item->getId(), $result)) { |
|
| 65 | + foreach ($complete as &$item) { |
|
| 66 | + if (!array_key_exists($item->getId(), $result)) { |
|
| 67 | 67 | $item = $this->mapOwner($item); |
| 68 | - if($item->getAcl() !== null) { |
|
| 68 | + if ($item->getAcl() !== null) { |
|
| 69 | 69 | foreach ($item->getAcl() as &$acl) { |
| 70 | 70 | $acl = $this->mapAcl($acl); |
| 71 | 71 | } |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | $board = $this->boardMapper->find($boardId, true, true); |
| 82 | 82 | $board = $this->mapOwner($board); |
| 83 | 83 | foreach ($board->getAcl() as &$acl) { |
| 84 | - if($acl !== null) { |
|
| 84 | + if ($acl !== null) { |
|
| 85 | 85 | $this->mapAcl($acl); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | return $board; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private function mapAcl(Acl &$acl) { |
|
| 91 | + private function mapAcl(Acl & $acl) { |
|
| 92 | 92 | $userManager = $this->userManager; |
| 93 | 93 | $groupManager = $this->groupManager; |
| 94 | 94 | $acl->resolveRelation('participant', function($value) use (&$acl, &$userManager, &$groupManager) { |
| 95 | - if($acl->getType() === Acl::PERMISSION_TYPE_USER) { |
|
| 95 | + if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { |
|
| 96 | 96 | return new User($userManager->get($acl->getParticipant($value))); |
| 97 | 97 | } |
| 98 | - if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { |
|
| 98 | + if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { |
|
| 99 | 99 | return new Group($groupManager->get($acl->getParticipant($value))); |
| 100 | 100 | } |
| 101 | 101 | }); |