74 lines
1.4 KiB
PHP
Raw Normal View History

2012-04-11 20:00:21 +02:00
<?php
namespace Nelmio\ApiBundle\Annotation;
/**
* @Annotation
*/
class ApiDoc
{
/**
* @var array
*/
private $filters = array();
/**
* @var string
*/
private $formType = null;
/**
* @var string
*/
private $description = null;
/**
* @var Boolean
*/
private $isResource = false;
2012-04-11 20:00:21 +02:00
public function __construct(array $data)
{
if (isset($data['formType'])) {
$this->formType = $data['formType'];
} else if (isset($data['filters'])) {
foreach ($data['filters'] as $filter) {
if (!isset($filter['name'])) {
throw new \InvalidArgumentException('A "filter" element has to contain a "name" attribute');
}
$name = $filter['name'];
unset($filter['name']);
$this->filters[$name] = $filter;
}
}
if (isset($data['description'])) {
$this->description = $data['description'];
2012-04-11 20:00:21 +02:00
}
$this->isResource = isset($data['resource']);
2012-04-11 20:00:21 +02:00
}
public function getFilters()
{
return $this->filters;
}
public function getFormType()
{
return $this->formType;
}
public function getDescription()
{
return $this->description;
}
public function isResource()
2012-04-11 20:00:21 +02:00
{
return $this->isResource;
2012-04-11 20:00:21 +02:00
}
}