Author: Christer Edvartsen (cogo@starzinger.net)
Inheritance: implements Imbo\Model\ModelInterface
示例#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
文件: XML.php 项目: imbo/imbo
    /**
     * {@inheritdoc}
     */
    public function formatGroup(Model\Group $model)
    {
        $entries = '';
        foreach ($model->getResources() as $resource) {
            $entries .= '<resource>' . $this->formatValue($resource) . '</resource>';
        }
        return <<<GROUP
<?xml version="1.0" encoding="UTF-8"?>
<imbo>
  <name>{$model->getName()}</name>
  <resources>{$entries}</resources>
</imbo>
GROUP;
    }
示例#3
0
文件: GroupTest.php 项目: imbo/imbo
 /**
  * @covers Imbo\Model\Group::getData
  */
 public function testGetData()
 {
     $this->model->setName('name')->setResources(['image.get', 'image.head']);
     $this->assertSame(['name' => 'name', 'resources' => ['image.get', 'image.head']], $this->model->getData());
 }
示例#4
0
文件: JSON.php 项目: imbo/imbo
 /**
  * {@inheritdoc}
  */
 public function formatGroup(Model\Group $model)
 {
     return $this->encode(['name' => $model->getName(), 'resources' => $model->getResources()]);
 }