Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\ControllerMetadata\Adapter;

use Doctrine\Common\Annotations\Annotation;

/**
* Allows a custom adapter to be implemented.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*/
interface AnnotationAdapterInterface
{
/**
* The identifier for the annotation.
*
* @return string
*/
public function getIdentifier();

/**
* The actual annotation found.
*
* @return mixed
*/
public function getAnnotation();

/**
* Indicates whether the given annotation may be used multiple times on a given method or class.
*
* @return bool
*/
public function allowMultiple();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\ControllerMetadata\Adapter;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\FrameworkBundle\ControllerMetadata\Configuration\ConfigurationAnnotation;

/**
* Wraps the Annotation into a usable layer.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*/
final class ConfigurationAnnotationAdapter implements AnnotationAdapterInterface
{
/**
* @var ConfigurationAnnotation
*/
private $annotation;

/**
* @param ConfigurationAnnotation $annotation
*/
public function __construct(ConfigurationAnnotation $annotation)
{
$this->annotation = $annotation;
}

/**
* {@inheritdoc}
*/
public function getIdentifier()
{
return $this->annotation->getAliasName();
}

/**
* {@inheritdoc}
*
* @returns ConfigurationAnnotation
*/
public function getAnnotation()
{
return $this->annotation;
}

/**
* {@inheritdoc}
*/
public function allowMultiple()
{
return $this->annotation->allowArray();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\ControllerMetadata\Adapter;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Component\Routing\Annotation\Route;

/**
* Wraps the Route into a usable layer.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*/
final class RouteAnnotationAdapter implements AnnotationAdapterInterface
{
/**
* @var Route
*/
private $annotation;

/**
* @param Route $annotation
*/
public function __construct(Route $annotation)
{
$this->annotation = $annotation;
}

/**
* {@inheritdoc}
*/
public function getIdentifier()
{
return $this->annotation->getName();
}

/**
* {@inheritdoc}
*
* @returns Route
*/
public function getAnnotation()
{
return $this->annotation;
}

/**
* {@inheritdoc}
*
* @return bool always true
*/
public function allowMultiple()
{
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\ControllerMetadata;

use Symfony\Bundle\FrameworkBundle\ControllerMetadata\Adapter\AnnotationAdapterInterface;

/**
* Responsible for storing metadata of a controller.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*/
final class ClassMetadata implements \Serializable
{
/**
* @var string
*/
private $className;

/**
* @var AnnotationAdapterInterface[]
*/
private $annotations;

/**
* @var array
*/
private $methods;

/**
* @param string $className
* @param MethodMetadata[] $methods
* @param AnnotationAdapterInterface[] $annotations
*/
public function __construct($className, array $methods = [], array $annotations = [])
{
$this->className = $className;
$this->methods = $methods;
$this->annotations = $annotations;
}

public function getClassName()
{
return $this->className;
}

public function getAnnotations()
{
return $this->annotations;
}

public function serialize()
{
return serialize(array($this->className, $this->methods, $this->annotations));
}

public function unserialize($serialized)
{
list($this->className, $this->methods, $this->annotations) = unserialize($serialized);
}
}
Loading