CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 周边产品
  • 自驾游
  • 团队
  • 社区
    • 社区
    • 参与其中
    • 问题 (Github)
    • 面包房
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • LinkedIn
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助与支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
      • Configure
      • Exception
      • Retry
      • TestSuite
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

类 BasePlugin

基本插件类

每个插件都应该扩展此类或实现接口,并在其 src 根文件夹中包含一个插件类。

命名空间: Cake\Core

常量

  • list<string>
    VALID_HOOKS ¶
    ['bootstrap', 'console', 'middleware', 'routes', 'services', 'events']

    有效的钩子列表。

属性概要

  • $bootstrapEnabled protected
    bool

    是否执行引导

  • $classPath protected
    string|null

    此插件的类路径。

  • $configPath protected
    string|null

    此插件的配置路径。

  • $consoleEnabled protected
    bool

    控制台中间件

  • $eventsEnabled protected
    bool

    是否加载事件

  • $middlewareEnabled protected
    bool

    启用中间件

  • $name protected
    string|null

    此插件的名称

  • $path protected
    string|null

    此插件的路径。

  • $routesEnabled protected
    bool

    是否加载路由

  • $servicesEnabled protected
    bool

    注册容器服务

  • $templatePath protected
    string|null

    此插件的模板路径。

方法概要

  • __construct() public

    构造函数

  • bootstrap() public

    加载所有应用程序配置和引导逻辑。

  • checkHook() protected

    检查钩子名称是否有效

  • console() public

    为插件添加控制台命令。

  • disable() public

    禁用指定的钩子

  • enable() public

    启用指定的钩子

  • events() public

    注册应用程序事件。

  • getClassPath() public

    获取此插件的配置的系统路径

  • getConfigPath() public

    获取此插件的配置的系统路径

  • getName() public

    获取此插件的名称。

  • getPath() public

    获取此插件的系统路径

  • getTemplatePath() public

    获取此插件的模板的系统路径

  • initialize() public

    从构造函数调用的初始化钩子。

  • isEnabled() public

    检查指定的钩子是否已启用

  • middleware() public

    为插件添加中间件。

  • routes() public

    为插件添加路由。

  • services() public

    为该插件注册容器服务。

方法详情

__construct() ¶ public

__construct(array<string, mixed> $options = [])

构造函数

参数
array<string, mixed> $options optional

选项

bootstrap() ¶ public

bootstrap(Cake\Core\PluginApplicationInterface $app): void

加载所有应用程序配置和引导逻辑。

此方法的默认实现将在插件中包含 config/bootstrap.php(如果存在)。您可以覆盖此方法来替换该行为。

主机应用程序作为参数提供。这允许您加载其他插件依赖项或附加事件。

参数
Cake\Core\PluginApplicationInterface $app
返回值
void

checkHook() ¶ protected

checkHook(string $hook): void

检查钩子名称是否有效

参数
string $hook

要检查的钩子名称

返回值
void
抛出
InvalidArgumentException
针对无效的钩子

console() ¶ public

console(Cake\Console\CommandCollection $commands): Cake\Console\CommandCollection

为插件添加控制台命令。

参数
Cake\Console\CommandCollection $commands
返回值
Cake\Console\CommandCollection

disable() ¶ public

disable(string $hook): $this

禁用指定的钩子

参数
string $hook
返回值
$this

enable() ¶ public

enable(string $hook): $this

启用指定的钩子

参数
string $hook
返回值
$this

events() ¶ public

events(Cake\Event\EventManagerInterface $eventManager): Cake\Event\EventManagerInterface

注册应用程序事件。

参数
Cake\Event\EventManagerInterface $eventManager

用于注册监听器的全局事件管理器

返回值
Cake\Event\EventManagerInterface

getClassPath() ¶ public

getClassPath(): string

获取此插件的配置的系统路径

返回值
string

getConfigPath() ¶ public

getConfigPath(): string

获取此插件的配置的系统路径

返回值
string

getName() ¶ public

getName(): string

获取此插件的名称。

返回值
string

getPath() ¶ public

getPath(): string

获取此插件的系统路径

返回值
string

getTemplatePath() ¶ public

getTemplatePath(): string

获取此插件的模板的系统路径

返回值
string

initialize() ¶ public

initialize(): void

从构造函数调用的初始化钩子。

返回值
void

isEnabled() ¶ public

isEnabled(string $hook): bool

检查指定的钩子是否已启用

参数
string $hook
返回值
bool

middleware() ¶ public

middleware(Cake\Http\MiddlewareQueue $middlewareQueue): Cake\Http\MiddlewareQueue

为插件添加中间件。

参数
Cake\Http\MiddlewareQueue $middlewareQueue
返回值
Cake\Http\MiddlewareQueue

routes() ¶ public

routes(Cake\Routing\RouteBuilder $routes): void

为插件添加路由。

此方法的默认实现将在插件中包含 config/routes.php(如果存在)。您可以覆盖此方法来替换该行为。

参数
Cake\Routing\RouteBuilder $routes
返回值
void

services() ¶ public

services(Cake\Core\ContainerInterface $container): void

为该插件注册容器服务。

参数
Cake\Core\ContainerInterface $container

要添加服务的容器。

返回值
void

属性详情

$bootstrapEnabled ¶ protected

是否执行引导

类型
bool

$classPath ¶ protected

此插件的类路径。

类型
string|null

$configPath ¶ protected

此插件的配置路径。

类型
string|null

$consoleEnabled ¶ 受保护

控制台中间件

类型
bool

$eventsEnabled ¶ 受保护

是否加载事件

类型
bool

$middlewareEnabled ¶ 受保护

启用中间件

类型
bool

$name ¶ 受保护

此插件的名称

类型
string|null

$path ¶ 受保护

此插件的路径。

类型
string|null

$routesEnabled ¶ 受保护

是否加载路由

类型
bool

$servicesEnabled ¶ 受保护

注册容器服务

类型
bool

$templatePath ¶ 受保护

此插件的模板路径。

类型
string|null
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与其中
  • 问题 (Github)
  • 面包房
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • LinkedIn
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成