本文整理匯總了PHP中Doctrine\Common\Annotations\Reader::addNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reader::addNamespace方法的具體用法?PHP Reader::addNamespace怎麽用?PHP Reader::addNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Annotations\Reader
的用法示例。
在下文中一共展示了Reader::addNamespace方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onConfigureRoute
/**
* Reads the "@Access" annotations from the controller stores them in the "access" route option.
*/
public function onConfigureRoute($event, $route)
{
if (!$this->reader) {
$this->reader = new SimpleAnnotationReader();
$this->reader->addNamespace('Pagekit\\User\\Annotation');
}
if (!$route->getControllerClass()) {
return;
}
$access = [];
foreach (array_merge($this->reader->getClassAnnotations($route->getControllerClass()), $this->reader->getMethodAnnotations($route->getControllerMethod())) as $annot) {
if (!$annot instanceof Access) {
continue;
}
if ($expression = $annot->getExpression()) {
$access[] = $expression;
}
if ($admin = $annot->getAdmin() !== null) {
$route->setPath('admin' . rtrim($route->getPath(), '/'));
$permission = 'system: access admin area';
if ($admin) {
$access[] = $permission;
} else {
if ($key = array_search($permission, $access)) {
unset($access[$key]);
}
}
}
}
if ($access) {
$route->setDefault('_access', array_unique($access));
}
}
示例2: setUp
protected function setUp()
{
AnnotationRegistry::registerLoader('class_exists');
$this->reader = new SimpleAnnotationReader();
$this->reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
$this->driver = new AnnotationDriver($this->reader);
}
示例3: getAnnotationReader
/**
* Gets the used doctrine annotation reader.
*
* @return \Doctrine\Common\Annotations\Reader
* The annotation reader.
*/
protected function getAnnotationReader()
{
if (!isset($this->annotationReader)) {
$this->annotationReader = new SimpleAnnotationReader();
// Add the namespaces from the main plugin annotation, like @EntityType.
$namespace = substr($this->pluginDefinitionAnnotationName, 0, strrpos($this->pluginDefinitionAnnotationName, '\\'));
$this->annotationReader->addNamespace($namespace);
}
return $this->annotationReader;
}
示例4: getAnnotationReader
/**
* Get the annotation reader instance.
*
* @return Reader
*/
protected function getAnnotationReader()
{
if (!$this->reader) {
$this->reader = new SimpleAnnotationReader();
$this->reader->addNamespace('Pagekit\\Routing\\Annotation');
}
return $this->reader;
}
示例5: getAnnotationReader
/**
* @return Reader The annotation reader
*/
public function getAnnotationReader()
{
if ($this->annotationReader == null) {
AnnotationRegistry::registerAutoloadNamespace('DI\\Annotation', __DIR__ . '/../../../');
$this->annotationReader = new SimpleAnnotationReader();
$this->annotationReader->addNamespace('DI\\Annotation');
}
return $this->annotationReader;
}
示例6: onConfigureRoute
/**
* Reads the "@Access" annotations from the controller stores them in the "access" route option.
*
* @param ConfigureRouteEvent $event
*/
public function onConfigureRoute(ConfigureRouteEvent $event)
{
if (!$this->reader) {
$this->reader = new SimpleAnnotationReader();
$this->reader->addNamespace('Pagekit\\User\\Annotation');
}
$admin = false;
$access = [];
foreach ($this->reader->getClassAnnotations($event->getClass()) as $annot) {
if ($annot instanceof Access) {
if ($expression = $annot->getExpression()) {
$access[] = $expression;
}
if ($annot->getAdmin()) {
$admin = true;
}
}
}
foreach ($this->reader->getMethodAnnotations($event->getMethod()) as $annot) {
if ($annot instanceof Access) {
if ($expression = $annot->getExpression()) {
$access[] = $expression;
}
if ($annot->getAdmin()) {
$admin = true;
}
}
}
$route = $event->getRoute();
if ($admin) {
$route->setPath(rtrim('admin' . $route->getPath(), '/'));
$access[] = 'system: access admin area';
}
if ($access) {
$route->setDefault('_access', array_unique($access));
}
}