Registers a handler for tags. The class specified is autoloaded if it's
not available. It must inherit from this class.
final public static registerTagHandler ( string $tag, string | null $handler ) : boolean | ||
$tag | string | Name of tag to regiser a handler for. When registering a namespaced tag, the full name, along with a prefixing slash MUST be provided. |
$handler | string | null | FQCN of handler. Specifing NULL removes the handler for the specified tag, if any. |
Результат | boolean | TRUE on success, FALSE on failure. |
/** * * @return \phpDocumentor\Reflection\DocBlock */ protected function getDocBlock() { if (!self::$registered) { Tag::registerTagHandler('requiresRight', '\\oat\\tao\\model\\controllerMap\\RequiresRightTag'); self::$registered = true; } return new DocBlock($this->method); }
/** * Registers all tags handlers. */ public static function registerTagHandlers() { static $isRegistered; if (!$isRegistered) { $mapping = ['query' => '\\pahanini\\restdoc\\tags\\QueryTag', 'field' => '\\phpDocumentor\\Reflection\\DocBlock\\Tag\\ParamTag', 'link' => '\\phpDocumentor\\Reflection\\DocBlock\\Tag\\ParamTag', 'label' => '\\phpDocumentor\\Reflection\\DocBlock\\Tag', 'extraField' => '\\phpDocumentor\\Reflection\\DocBlock\\Tag\\ParamTag', 'extraLink' => '\\phpDocumentor\\Reflection\\DocBlock\\Tag\\ParamTag']; foreach ($mapping as $suffix => $class) { $tagName = Doc::TAG_PREFIX . $suffix; Tag::registerTagHandler($tagName, $class); } } }
/** * Perform post-registration booting of services. * * @return void */ public function boot() { // Registering custom tags Tag::registerTagHandler('apiParam', '\\phpDocumentor\\Reflection\\DocBlock\\Tag\\ParamTag'); // Set router RouteResolver::setRouter(app()->make('router')); // use this if your package needs a config file // $this->publishes([ // __DIR__.'/config/config.php' => config_path('skeleton.php'), // ]); // use the vendor configuration file as fallback // $this->mergeConfigFrom( // __DIR__.'/config/config.php', 'skeleton' // ); }
/** * @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler * * @return void */ public function testIncompatibleTagHandlerRegistration() { $currentHandler = __NAMESPACE__ . '\\Tag\\VarTag'; $tagPreReg = Tag::createInstance('@var mixed'); $this->assertInstanceOf($currentHandler, $tagPreReg); $this->assertInstanceOf(__NAMESPACE__ . '\\Tag', $tagPreReg); $this->assertFalse(Tag::registerTagHandler('var', __NAMESPACE__ . '\\TagTest')); $tagPostReg = Tag::createInstance('@var mixed'); $this->assertInstanceOf($currentHandler, $tagPostReg); $this->assertInstanceOf(__NAMESPACE__ . '\\Tag', $tagPostReg); }