Skip to content

Instantly share code, notes, and snippets.

@EclipseGc
Created August 3, 2012 05:06
Show Gist options
  • Save EclipseGc/3244566 to your computer and use it in GitHub Desktop.
Save EclipseGc/3244566 to your computer and use it in GitHub Desktop.
<?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