/** * 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); }
/** * @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()); }