/** * @covers Imbo\Model\Groups::setLimit * @covers Imbo\Model\Groups::getLimit */ public function testCanSetAndGetLimit() { $this->assertNull($this->model->getLimit()); $this->assertSame($this->model, $this->model->setLimit(10)); $this->assertSame(10, $this->model->getLimit()); }
/** * Load groups from the configured access control adapter * * @param EventInterface $event An event instance */ public function loadGroups(EventInterface $event) { $query = new GroupQuery(); $params = $event->getRequest()->query; if ($params->has('page')) { $query->page($params->get('page')); } if ($params->has('limit')) { $query->limit($params->get('limit')); } $response = $event->getResponse(); $aclAdapter = $event->getAccessControl(); // Create the model and set some pagination values $model = new GroupsModel(); $model->setLimit($query->limit())->setPage($query->page()); $groups = $aclAdapter->getGroups($query, $model); $modelGroups = []; foreach ($groups as $groupName => $resources) { $modelGroups[] = ['name' => $groupName, 'resources' => $resources]; } $model->setGroups($modelGroups); $response->setModel($model); }