/** * @expectedException \Solution10\Collection\Exception\Search * @expectedExceptionCode \Solution10\Collection\Exception\Search::BAD_CALLBACK_RETURN */ public function testSearchBadCallbackReturn() { $c = new Collection(array('apple', 'orange', 'banana')); $c->search('monkey', function ($term, $item) { // No return type! }); }
/** * Builds up the permissions for a user by looping through, * taking on the highest precedence of each tier. * * @param UserRepresentation $user ID of the user to build for * @return void * @throws Exception\User */ protected function buildPermissionsForUser(UserRepresentation $user) { // Make use of Collection to do some clever sorting: $all_packages = $this->packagesForUser($user); $sorted_packages = new Collection($all_packages); $sorted_packages->sortByMember('precedence'); $permissions = array(); foreach ($sorted_packages as $package) { /* @var $package Package */ foreach ($package->definedPermissions() as $name => $rule) { $permissions[$name] = $rule; } } // And now process any overrides that this user has: $overrides = $this->storage->authFetchOverridesForUser($this->name(), $user); foreach ($overrides as $permission => $new_value) { if (array_key_exists($permission, $permissions)) { $permissions[$permission] = $new_value; } } $this->permissions_cache[$user->id()] = $permissions; }
public function current() { $item = parent::current(); return $this->buildInstance($this->iter_current_pos, $item); }