Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Annotation/Controller/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* @Annotation
* @Target("CLASS")
* @Target({"CLASS", "METHOD"})
*/
final class Tag
{
Expand All @@ -24,8 +24,9 @@ final class Tag
*/
public function __construct(array $values)
{
if (!isset($values['name'])) {
throw new AnnotationException('Name is required at @Tag');
if (isset($values['value']) && !isset($values['name'])) {
$values['name'] = $values['value'];
unset($values['value']);
}

$this->name = $values['name'];
Expand Down
7 changes: 7 additions & 0 deletions src/DI/Loader/DoctrineAnnotationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ protected function parseControllerMethodsAnnotations(Controller $controller, Cla
continue;
}

// Parse @Tag ==============================
if (get_class($annotation) == Tag::class) {
/** @var Tag $annotation */
$schemaMethod->addTag($annotation->getName());
continue;
}

// Parse @Id ===============================
if (get_class($annotation) === Id::class) {
/** @var Id $annotation */
Expand Down
33 changes: 32 additions & 1 deletion src/Schema/Builder/Controller/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ final class Method
/** @var string[] */
private $methods = [];

/** @var string[] */
private $tags = [];

/** @var string[] */
private $arguments = [];

Expand Down Expand Up @@ -129,7 +132,7 @@ public function addMethod($method)
}

/**
* @param string|string[] $methods
* @param string[] $methods
* @return void
*/
public function addMethods(array $methods)
Expand All @@ -139,6 +142,34 @@ public function addMethods(array $methods)
}
}

/**
* @return string[]
*/
public function getTags()
{
return $this->tags;
}

/**
* @param string $tag
* @return void
*/
public function addTag($tag)
{
$this->tags[] = $tag;
}

/**
* @param string[] $tags
* @return void
*/
public function addTags(array $tags)
{
foreach ($tags as $tag) {
$this->addTag($tag);
}
}

/**
* @param string $name
* @param string $type
Expand Down
14 changes: 7 additions & 7 deletions src/Schema/EndpointParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
final class EndpointParameter
{

const TYPE_SCALAR = 1;
const TYPE_STRING = 2;
const TYPE_INTEGER = 3;
const TYPE_FLOAT = 4;
const TYPE_BOOLEAN = 5;
const TYPE_DATETIME = 6;
const TYPE_OBJECT = 7;
const TYPE_SCALAR = 'scalar';
const TYPE_STRING = 'string';
const TYPE_INTEGER = 'int';
const TYPE_FLOAT = 'float';
const TYPE_BOOLEAN = 'bool';
const TYPE_DATETIME = 'datetime';
const TYPE_OBJECT = 'object';

const IN_QUERY = 'query';
const IN_COOKIE = 'cookie';
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Serialization/ArraySerializator.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function serializeInit(Controller $controller, Method $method)
'arguments' => $method->getArguments(),
],
'id' => $id,
'tags' => $controller->getTags(),
'tags' => $method->getTags(),
'methods' => $method->getMethods(),
'mask' => $mask,
'description' => $method->getDescription(),
Expand Down