103 lines
1.9 KiB
PHP
Raw Normal View History

2012-04-11 20:00:21 +02:00
<?php
2012-04-13 11:03:05 +02:00
/*
* This file is part of the NelmioApiDocBundle.
*
* (c) Nelmio <hello@nelm.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2012-04-12 18:37:42 +02:00
namespace Nelmio\ApiDocBundle\Annotation;
2012-04-11 20:00:21 +02:00
/**
* @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'];
2012-05-23 00:33:01 +02:00
} elseif (isset($data['filters'])) {
2012-04-11 20:00:21 +02:00
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
}
2012-04-12 20:00:26 +02:00
$this->isResource = isset($data['resource']) && $data['resource'];
2012-04-11 20:00:21 +02:00
}
2012-04-12 17:48:21 +02:00
/**
2012-04-13 15:20:45 +02:00
* @return array
2012-04-12 17:48:21 +02:00
*/
2012-04-11 20:00:21 +02:00
public function getFilters()
{
return $this->filters;
}
2012-04-12 17:48:21 +02:00
/**
* @return string|null
*/
2012-04-11 20:00:21 +02:00
public function getFormType()
{
return $this->formType;
}
2012-04-12 17:48:21 +02:00
/**
* @return string|null
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
2012-04-12 17:48:21 +02:00
/**
* @return Boolean
*/
public function isResource()
2012-04-11 20:00:21 +02:00
{
return $this->isResource;
2012-04-11 20:00:21 +02:00
}
}