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
|
|
|
|
*/
|
2012-04-12 17:24:38 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-12 17:24:38 +02:00
|
|
|
if (isset($data['description'])) {
|
|
|
|
$this->description = $data['description'];
|
2012-04-11 20:00:21 +02:00
|
|
|
}
|
2012-04-12 17:24:38 +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;
|
|
|
|
}
|
|
|
|
|
2012-04-12 17:24:38 +02:00
|
|
|
public function getDescription()
|
|
|
|
{
|
|
|
|
return $this->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isResource()
|
2012-04-11 20:00:21 +02:00
|
|
|
{
|
2012-04-12 17:24:38 +02:00
|
|
|
return $this->isResource;
|
2012-04-11 20:00:21 +02:00
|
|
|
}
|
|
|
|
}
|