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
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget

类 Cell

Cell 基类。

抽象
命名空间: Cake\View

常量

  • 字符串
    TEMPLATE_FOLDER ¶
    'cell'

    包含 Cell 模板的文件夹名称的常量。

属性摘要

  • $View protected
    Cake\View\View

    渲染期间创建的 View 实例。在调用 Cell::__toString()/render() 之前不会设置。

  • $_cache protected
    数组|布尔值

    缓存设置。

  • $_eventClass protected
    字符串

    新事件对象的默认类名。

  • $_eventManager protected
    Cake\Event\EventManagerInterface|null

    此对象正在使用的 Cake\Event\EventManager 实例,用于分派内部事件。

  • $_tableLocator protected
    Cake\ORM\Locator\LocatorInterface|null

    表定位器实例

  • $_validCellOptions protected
    列表<字符串>

    有效选项列表(构造函数的第四个参数)在子类中覆盖此属性以允许您想要设置为 Cell 中属性的选项。

  • $_viewBuilder protected
    Cake\View\ViewBuilder|null

    正在使用的视图构建器实例。

  • $action protected
    字符串

    Cell 要调用的动作。

  • $args protected
    数组

    要传递给 Cell 动作的参数。

  • $defaultTable protected
    字符串|null

    此对象的默认表别名。

  • $request protected
    Cake\Http\ServerRequest

    Cake\Http\ServerRequest 对象的实例,其中包含有关当前请求的信息。此对象包含有关请求的所有信息,以及用于读取有关请求的更多信息的几种方法。

  • $response protected
    Cake\Http\Response

    Response 对象的实例,其中包含有关即将发生的响应的信息

方法摘要

  • __construct() public

    构造函数。

  • __debugInfo() public

    调试信息。

  • __toString() public

    魔术方法。

  • _cacheConfig() protected

    生成此 Cell 要使用的缓存键。

  • createView() public

    根据当前配置构造视图类实例。

  • dispatchEvent() public

    创建和分派事件的包装器。

  • fetchTable() public

    获取表实例的便捷方法。

  • getEventManager() public

    返回此对象的 Cake\Event\EventManager 管理器实例。

  • getTableLocator() public

    获取表定位器。

  • initialize() public

    初始化钩子方法。

  • render() public

    渲染 Cell。

  • set() public

    保存一个变量或一个关联变量数组以在模板中使用。

  • setEventManager() public

    返回此对象的 Cake\Event\EventManagerInterface 实例。

  • setTableLocator() public

    设置表定位器。

  • viewBuilder() public

    获取正在使用的视图构建器。

方法详情

__construct() ¶ public

__construct(Cake\Http\ServerRequest $request, Cake\Http\Response $response, Cake\Event\EventManagerInterface|null $eventManager = null, array<string, mixed> $cellOptions = [])

构造函数。

参数
Cake\Http\ServerRequest $request

要在 Cell 中使用的请求。

Cake\Http\Response $response

要在 Cell 中使用的响应。

Cake\Event\EventManagerInterface|null $eventManager optional

要绑定事件的 eventManager。

array<string, mixed> $cellOptions optional

要应用的 Cell 选项。

__debugInfo() ¶ public

__debugInfo(): array<string, mixed>

调试信息。

返回值
array<string, mixed>

__toString() ¶ public

__toString(): string

魔术方法。

当 Cell 被回显时,启动渲染过程。

注意 当视图渲染出现问题时,此方法将触发错误。这是因为 PHP 不允许 __toString() 方法抛出异常。

返回值
字符串
抛出
Error
包含 PHP 7 致命错误的错误详细信息。

_cacheConfig() ¶ protected

_cacheConfig(string $action, string|null $template = null): array

生成此 Cell 要使用的缓存键。

如果键未定义,将使用 Cell 类和动作名称。

参数
字符串 $action

调用的动作。

字符串|null $template optional

要渲染的模板名称。

返回值
数组

createView() ¶ public

createView(string|null $viewClass = null): Cake\View\View

根据当前配置构造视图类实例。

参数
字符串|null $viewClass optional

要实例化的 View 类的可选命名空间类名。

返回值
Cake\View\View
抛出
Cake\View\Exception\MissingViewException
如果未找到视图类。

dispatchEvent() ¶ public

dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>

创建和分派事件的包装器。

返回已分派的事件。

参数
字符串 $name

事件名称。

数组 $data optional

您希望与此事件一起传送的任何值,监听器都可以读取它。

TSubject|null $subject optional

此事件适用的对象(默认情况下为 $this)。

返回值
Cake\Event\EventInterface<TSubject>

fetchTable() ¶ public

fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table

获取表实例的便捷方法。

参数
字符串|null $alias optional

您要获取的别名。应为驼峰式格式。如果为 `null`,则使用 $defaultTable 属性的值。

array<string, mixed> $options optional

您想要构建表的选项。如果表已加载,则注册表选项将被忽略。

返回值
Cake\ORM\Table
抛出
Cake\Core\Exception\CakeException
如果 `$alias` 参数和 `$defaultTable` 属性都为 `null`。
另请参阅
\Cake\ORM\TableLocator::get()

getEventManager() ¶ public

getEventManager(): Cake\Event\EventManagerInterface

返回此对象的 Cake\Event\EventManager 管理器实例。

您可以使用此实例注册任何新的侦听器或回调到对象事件,或者创建您自己的事件并在需要时触发它们。

返回值
Cake\Event\EventManagerInterface

getTableLocator() ¶ public

getTableLocator(): Cake\ORM\Locator\LocatorInterface

获取表定位器。

返回值
Cake\ORM\Locator\LocatorInterface

initialize() ¶ public

initialize(): void

初始化钩子方法。

实现此方法以避免必须覆盖构造函数并调用 parent::__construct()。

返回值
void

render() ¶ public

render(string|null $template = null): string

渲染 Cell。

参数
字符串|null $template optional

要渲染的自定义模板名称。如果没有提供(null),将使用最后一个值。此值由 CellTrait::cell() 自动设置。

返回值
字符串
抛出
Cake\View\Exception\MissingCellTemplateExceptionBadMethodCallException

set() ¶ public

set(array|string $name, mixed $value = null): $this

保存一个变量或一个关联变量数组以在模板中使用。

参数
数组|字符串 $name

字符串或数据数组。

混合 $value optional

如果 $name 是字符串(然后用作键),则为值。如果 $name 是关联数组,则未使用,否则用作 $name 键的值。

返回值
$this

setEventManager() ¶ public

setEventManager(Cake\Event\EventManagerInterface $eventManager): $this

返回此对象的 Cake\Event\EventManagerInterface 实例。

您可以使用此实例注册任何新的侦听器或回调到对象事件,或者创建您自己的事件并在需要时触发它们。

参数
Cake\Event\EventManagerInterface $eventManager

要设置的事件管理器

返回值
$this

setTableLocator() ¶ public

setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this

设置表定位器。

参数
Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface 实例。

返回值
$this

viewBuilder() ¶ public

viewBuilder(): Cake\View\ViewBuilder

获取正在使用的视图构建器。

返回值
Cake\View\ViewBuilder

属性详情

$View ¶ protected

渲染期间创建的 View 实例。在调用 Cell::__toString()/render() 之前不会设置。

类型
Cake\View\View

$_cache ¶ protected

缓存设置。

类型
数组|布尔值

$_eventClass ¶ protected

新事件对象的默认类名。

类型
字符串

$_eventManager ¶ protected

此对象正在使用的 Cake\Event\EventManager 实例,用于分派内部事件。

类型
Cake\Event\EventManagerInterface|null

$_tableLocator ¶ protected

表定位器实例

类型
Cake\ORM\Locator\LocatorInterface|null

$_validCellOptions ¶ protected

有效选项列表(构造函数的第四个参数)在子类中覆盖此属性以允许您想要设置为 Cell 中属性的选项。

类型
列表<字符串>

$_viewBuilder ¶ protected

正在使用的视图构建器实例。

类型
Cake\View\ViewBuilder|null

$action ¶ protected

Cell 要调用的动作。

类型
字符串

$args ¶ protected

要传递给 Cell 动作的参数。

类型
数组

$defaultTable ¶ protected

此对象的默认表别名。

类型
字符串|null

$request ¶ protected

Cake\Http\ServerRequest 对象的实例,其中包含有关当前请求的信息。此对象包含有关请求的所有信息,以及用于读取有关请求的更多信息的几种方法。

类型
Cake\Http\ServerRequest

$response ¶ protected

Response 对象的实例,其中包含有关即将发生的响应的信息

类型
Cake\Http\Response
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成