Created
August 3, 2012 05:06
-
-
Save EclipseGc/3244566 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Definition of Drupal\Core\Annotation\Plugin. | |
*/ | |
namespace Drupal\Core\Annotation; | |
use Drupal\Core\Annotation\AnnotationInterface; | |
/** | |
* @Annotation | |
*/ | |
class Plugin implements AnnotationInterface { | |
protected $definition; | |
/** | |
* Build up the plugin definition and invoke the get() method for any classed | |
* annotations that were used. | |
*/ | |
public function __construct($values) { | |
$this->definition = $this->parse($values); | |
} | |
protected function parse($values) { | |
$definition = array(); | |
foreach ($values as $key => $value) { | |
if ($value instanceof AnnotationInterface) { | |
$definition[$key] = $value->get(); | |
} | |
elseif (is_array($value)) { | |
$definition[$key] = $this->parse($value); | |
} | |
else { | |
$definition[$key] = $value; | |
} | |
} | |
return $definition; | |
} | |
/** | |
* Implements AnnotationInterface::get(). | |
*/ | |
public function get() { | |
return $this->definition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment