setResources() public method

Set the group resources
public setResources ( array $resources = [] ) : self
$resources array
return self
示例#1
0
文件: Group.php 项目: imbo/imbo
 /**
  * Get the resources associated with a specific group
  *
  * @param EventInterface $event The current event
  */
 public function getGroup(EventInterface $event)
 {
     $route = $event->getRequest()->getRoute();
     $groupName = $route->get('group');
     $adapter = $event->getAccessControl();
     if (!$adapter->groupExists($groupName)) {
         throw new ResourceException('Resource group not found', 404);
     }
     $resources = $adapter->getGroup($groupName);
     $model = new GroupModel();
     $model->setName($groupName);
     $model->setResources($resources);
     $response = $event->getResponse();
     $response->setModel($model);
 }
示例#2
0
文件: GroupTest.php 项目: imbo/imbo
 /**
  * @covers Imbo\Model\Group::getResources
  * @covers Imbo\Model\Group::setResources
  */
 public function testSetAndGetResources()
 {
     $this->assertSame([], $this->model->getResources());
     $this->assertSame($this->model, $this->model->setResources(['image.get', 'image.head']));
     $this->assertSame(['image.get', 'image.head'], $this->model->getResources());
 }