/** * @covers Imbo\Model\Groups::getGroups * @covers Imbo\Model\Groups::setGroups */ public function testSetAndGetGroups() { $this->assertSame([], $this->model->getGroups()); $this->assertSame($this->model, $this->model->setGroups(['group' => [], 'group2' => []])); $this->assertSame(['group' => [], 'group2' => []], $this->model->getGroups()); }
/** * {@inheritdoc} */ public function formatGroups(Model\Groups $model) { $data = $model->getGroups(); $entries = ''; foreach ($data as $group) { $resources = array_map(array($this, 'formatValue'), $group['resources']); $entries .= '<group>'; $entries .= ' <name>' . $this->formatValue($group['name']) . '</name>'; $entries .= ' <resources>'; $entries .= ' <resource>' . implode($resources, '</resource><resource>') . '</resource>'; $entries .= ' </resources>'; $entries .= '</group>'; } return <<<GROUPS <?xml version="1.0" encoding="UTF-8"?> <imbo> <search> <hits>{$model->getHits()}</hits> <page>{$model->getPage()}</page> <limit>{$model->getLimit()}</limit> <count>{$model->getCount()}</count> </search> <groups>{$entries}</groups> </imbo> GROUPS; }
/** * {@inheritdoc} */ public function formatGroups(Model\Groups $model) { return $this->encode(['search' => ['hits' => $model->getHits(), 'page' => $model->getPage(), 'limit' => $model->getLimit(), 'count' => $model->getCount()], 'groups' => $model->getGroups()]); }