CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与其中
    • 问题 (Github)
    • 面包店
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻稿
    • 领英
    • 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

类 BreadcrumbsHelper

BreadcrumbsHelper 用于注册和显示视图的面包屑跟踪

命名空间: Cake\View\Helper

属性摘要

  • $Url public @property
    Cake\View\Helper\UrlHelper
  • $_View protected
    Cake\View\View

    此辅助程序附加到的视图实例

  • $_config protected
    array<string, mixed>

    运行时配置

  • $_configInitialized protected
    bool

    配置属性是否已使用默认值配置

  • $_defaultConfig protected
    array<string, mixed>

    辅助程序的默认配置。

  • $_templater protected
    Cake\View\StringTemplate|null

    StringTemplate 实例。

  • $crumbs protected
    array

    面包屑列表。

  • $helperInstances protected
    array<string,Cake\View\Helper>

    已加载的辅助程序实例。

  • $helpers protected
    array

    BreadcrumbsHelper 使用的其他辅助程序。

方法摘要

  • __construct() public

    默认构造函数

  • __debugInfo() public

    返回一个可用于描述此对象内部状态的数组。

  • __get() public

    延迟加载辅助程序。

  • _configDelete() protected

    删除单个配置键。

  • _configRead() protected

    读取配置键。

  • _configWrite() protected

    写入配置键。

  • _confirm() protected

    返回一个用作确认对话框的 onclick 处理程序的字符串。

  • add() public

    在跟踪的末尾添加面包屑。

  • addClass() public

    将给定类添加到元素选项中

  • configShallow() public

    将提供的配置与现有配置合并。与 config() 对嵌套键进行递归合并不同,此方法进行简单合并。

  • findCrumb() protected

    在当前堆栈中搜索标题与作为参数提供的内容匹配的面包屑。如果找到,将返回匹配面包屑的索引。

  • formatTemplate() public

    使用 $data 格式化模板字符串

  • getConfig() public

    返回配置。

  • getConfigOrFail() public

    返回此特定键的配置。

  • getCrumbs() public

    返回面包屑列表。

  • getTemplates() public

    获取要使用的模板或特定模板。

  • getView() public

    获取此辅助程序绑定到的视图实例。

  • implementedEvents() public

    获取此辅助程序感兴趣的视图回调。

  • initialize() public

    构造函数钩子方法。

  • insertAfter() public

    在第一个标题与指定标题匹配的面包屑之后插入面包屑。

  • insertAt() public

    在特定索引处插入面包屑。

  • insertBefore() public

    在第一个标题与指定标题匹配的面包屑之前插入面包屑。

  • prepend() public

    将面包屑添加到队列的开头。

  • render() public

    呈现面包屑跟踪。

  • reset() public

    删除所有现有面包屑。

  • setConfig() public

    设置配置。

  • setTemplates() public

    设置要使用的模板。

  • templater() public

    返回模板器实例。

方法详情

__construct() ¶ public

__construct(Cake\View\View $view, array<string, mixed> $config = [])

默认构造函数

参数
Cake\View\View $view

此辅助程序附加到的视图。

array<string, mixed> $config optional

辅助程序的配置设置。

__debugInfo() ¶ public

__debugInfo(): array<string, mixed>

返回一个可用于描述此对象内部状态的数组。

返回
array<string, mixed>

__get() ¶ public

__get(string $name): Cake\View\Helper|null

延迟加载辅助程序。

参数
string $name

正在访问的属性的名称。

返回
Cake\View\Helper|null

_configDelete() ¶ protected

_configDelete(string $key): void

删除单个配置键。

参数
string $key

要删除的键。

返回
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_configRead() ¶ protected

_configRead(string|null $key): mixed

读取配置键。

参数
string|null $key

要读取的键。

返回
mixed

_configWrite() ¶ protected

_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void

写入配置键。

参数
array<string, mixed>|string $key

要写入的键。

mixed $value

要写入的值。

string|bool $merge optional

True 表示递归合并,'shallow' 表示简单合并,false 表示覆盖,默认为 false。

返回
void
抛出
Cake\Core\Exception\CakeException
如果尝试覆盖现有配置

_confirm() ¶ protected

_confirm(string $okCode, string $cancelCode): string

返回一个用作确认对话框的 onclick 处理程序的字符串。

参数
string $okCode

用户选择“确定”后要执行的代码

string $cancelCode

用户选择“取消”后要执行的代码

返回
string

add() ¶ public

add(array|string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

在跟踪的末尾添加面包屑。

参数
array|string $title

如果提供为字符串,则表示面包屑的标题。或者,如果你想一次添加多个面包屑,可以提供一个数组,每个值都是一个面包屑。数组应采用以下形式

array|string|null $url optional

面包屑的 URL。可以是字符串,传递给 Url::build() 的路由参数数组,或者如果面包屑没有链接,则为 null 或空。

array<string, mixed> $options optional

选项数组。这些选项将用作面包屑将被渲染到的 HTML 属性的属性(a

  • 标签(默认情况下)。它接受两个特殊键

  • 返回
    $this

    addClass() ¶ public

    addClass(array<string, mixed> $options, string $class, string $key = 'class'): array<string, mixed>

    将给定类添加到元素选项中

    参数
    array<string, mixed> $options

    要添加类的数组选项/属性

    string $class

    要添加的类名。

    string $key optional

    用于类的键。默认为 'class'。

    返回
    array<string, mixed>

    configShallow() ¶ public

    configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this

    将提供的配置与现有配置合并。与 config() 对嵌套键进行递归合并不同,此方法进行简单合并。

    设置特定值

    $this->configShallow('key', $value);

    设置嵌套值

    $this->configShallow('some.nested.key', $value);

    同时更新多个配置设置

    $this->configShallow(['one' => 'value', 'another' => 'value']);
    参数
    array<string, mixed>|string $key

    要设置的键,或完整的配置数组。

    mixed|null $value optional

    要设置的值。

    返回
    $this

    findCrumb() ¶ protected

    findCrumb(string $title): int|null

    在当前堆栈中搜索标题与作为参数提供的内容匹配的面包屑。如果找到,将返回匹配面包屑的索引。

    参数
    string $title

    要查找的标题。

    返回
    int|null

    formatTemplate() ¶ public

    formatTemplate(string $name, array<string, mixed> $data): string

    使用 $data 格式化模板字符串

    参数
    string $name

    模板名称。

    array<string, mixed> $data

    要插入的数据。

    返回
    string

    getConfig() ¶ public

    getConfig(string|null $key = null, mixed $default = null): mixed

    返回配置。

    用法

    读取整个配置

    $this->getConfig();

    读取特定值

    $this->getConfig('key');

    读取嵌套值

    $this->getConfig('some.nested.key');

    读取默认值

    $this->getConfig('some-key', 'default-value');
    参数
    string|null $key optional

    要获取的键,或获取整个配置的 null。

    mixed $default optional

    键不存在时的返回值。

    返回
    mixed

    getConfigOrFail() ¶ public

    getConfigOrFail(string $key): mixed

    返回此特定键的配置。

    此键的配置值必须存在,永远不能为 null。

    参数
    string $key

    要获取的键。

    返回
    mixed
    抛出
    InvalidArgumentException

    getCrumbs() ¶ public

    getCrumbs(): array

    返回面包屑列表。

    返回
    array

    getTemplates() ¶ public

    getTemplates(string|null $template = null): array|string

    获取要使用的模板或特定模板。

    参数
    string|null $template optional

    用于读取特定模板的字符串,null 表示所有模板。

    返回
    array|string

    getView() ¶ public

    getView(): Cake\View\View

    获取此辅助程序绑定到的视图实例。

    返回
    Cake\View\View

    implementedEvents() ¶ public

    implementedEvents(): array<string, mixed>

    获取此辅助程序感兴趣的视图回调。

    通过定义其中一个回调方法,假设助手对相关事件感兴趣。

    如果您需要添加非传统事件监听器,或希望助手监听非标准事件,请重写此方法。

    返回
    array<string, mixed>

    initialize() ¶ public

    initialize(array<string, mixed> $config): void

    构造函数钩子方法。

    实现此方法以避免必须覆盖构造函数并调用父级。

    参数
    array<string, mixed> $config

    提供给此助手的配置设置。

    返回
    void

    insertAfter() ¶ public

    insertAfter(string $matchingTitle, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    在第一个标题与指定标题匹配的面包屑之后插入面包屑。

    找到第一个与提供的类匹配的面包屑的索引,并在其之前插入提供的可调用函数。

    参数
    string $matchingTitle

    要在此面包屑之后插入的面包屑的标题。

    string $title

    面包屑的标题。

    array|string|null $url optional

    面包屑的 URL。可以是字符串,传递给 Url::build() 的路由参数数组,或者如果面包屑没有链接,则为 null 或空。

    array<string, mixed> $options optional

    选项数组。这些选项将用作面包屑将被渲染到的 HTML 属性的属性(a

  • 标签(默认情况下)。它接受两个特殊键

  • 返回
    $this
    抛出
    LogicException
    如果找不到匹配的面包屑。

    insertAt() ¶ public

    insertAt(int $index, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    在特定索引处插入面包屑。

    如果索引已经存在,新的面包屑将被插入到现有元素之前,将现有元素的索引移到比之前大 1 的位置。

    如果索引超出范围,将抛出异常。

    参数
    int $index

    要插入的索引。

    string $title

    面包屑的标题。

    array|string|null $url optional

    面包屑的 URL。可以是字符串,传递给 Url::build() 的路由参数数组,或者如果面包屑没有链接,则为 null 或空。

    array<string, mixed> $options optional

    选项数组。这些选项将用作面包屑将被渲染到的 HTML 属性的属性(a

  • 标签(默认情况下)。它接受两个特殊键

  • 返回
    $this
    抛出
    LogicException
    如果索引超出范围

    insertBefore() ¶ public

    insertBefore(string $matchingTitle, string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    在第一个标题与指定标题匹配的面包屑之前插入面包屑。

    找到第一个与提供的类匹配的面包屑的索引,并在其之前插入提供的可调用函数。

    参数
    string $matchingTitle

    要在此面包屑之前插入的面包屑的标题。

    string $title

    面包屑的标题。

    array|string|null $url optional

    面包屑的 URL。可以是字符串,传递给 Url::build() 的路由参数数组,或者如果面包屑没有链接,则为 null 或空。

    array<string, mixed> $options optional

    选项数组。这些选项将用作面包屑将被渲染到的 HTML 属性的属性(a

  • 标签(默认情况下)。它接受两个特殊键

  • 返回
    $this
    抛出
    LogicException
    如果找不到匹配的面包屑

    prepend() ¶ public

    prepend(array|string $title, array|string|null $url = null, array<string, mixed> $options = []): $this

    将面包屑添加到队列的开头。

    参数
    array|string $title

    如果提供为字符串,则表示面包屑的标题。或者,如果你想一次添加多个面包屑,可以提供一个数组,每个值都是一个面包屑。数组应采用以下形式

    array|string|null $url optional

    面包屑的 URL。可以是字符串,传递给 Url::build() 的路由参数数组,或者如果面包屑没有链接,则为 null 或空。

    array<string, mixed> $options optional

    选项数组。这些选项将用作面包屑将被渲染到的 HTML 属性的属性(a

  • 标签(默认情况下)。它接受两个特殊键

  • 返回
    $this

    render() ¶ public

    render(array<string, mixed> $attributes = [], array<string, mixed> $separator = []): string

    呈现面包屑跟踪。

    参数
    array<string, mixed> $attributes optional

    应用于 wrapper 模板的属性数组。接受 templateVars 键以允许在模板中插入自定义模板变量。

    array<string, mixed> $separator optional

    separator 模板的属性数组。可能的属性是

    返回
    string

    reset() ¶ public

    reset(): $this

    删除所有现有面包屑。

    返回
    $this

    setConfig() ¶ public

    setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this

    设置配置。

    用法

    设置特定值

    $this->setConfig('key', $value);

    设置嵌套值

    $this->setConfig('some.nested.key', $value);

    同时更新多个配置设置

    $this->setConfig(['one' => 'value', 'another' => 'value']);
    参数
    array<string, mixed>|string $key

    要设置的键,或完整的配置数组。

    mixed|null $value optional

    要设置的值。

    bool $merge optional

    是否递归合并或覆盖现有配置,默认为 true。

    返回
    $this
    抛出
    Cake\Core\Exception\CakeException
    尝试设置无效的键时。

    setTemplates() ¶ public

    setTemplates(array<string, string> $templates): $this

    设置要使用的模板。

    参数
    array<string, string> $templates

    要添加的模板。

    返回
    $this

    templater() ¶ public

    templater(): Cake\View\StringTemplate

    返回模板器实例。

    返回
    Cake\View\StringTemplate

    属性详情

    $Url ¶ public @property

    类型
    Cake\View\Helper\UrlHelper

    $_View ¶ protected

    此辅助程序附加到的视图实例

    类型
    Cake\View\View

    $_config ¶ protected

    运行时配置

    类型
    array<string, mixed>

    $_configInitialized ¶ protected

    配置属性是否已使用默认值配置

    类型
    bool

    $_defaultConfig ¶ protected

    辅助程序的默认配置。

    类型
    array<string, mixed>

    $_templater ¶ protected

    StringTemplate 实例。

    类型
    Cake\View\StringTemplate|null

    $crumbs ¶ protected

    面包屑列表。

    类型
    array

    $helperInstances ¶ protected

    已加载的辅助程序实例。

    类型
    array<string,Cake\View\Helper>

    $helpers ¶ protected

    BreadcrumbsHelper 使用的其他辅助程序。

    类型
    array
    OpenHub
    Pingping
    Linode
    • 商业解决方案
    • 展示
    • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
    • 社区
    • 参与其中
    • 问题 (Github)
    • 面包店
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻稿
    • 领英
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持

    使用 CakePHP API 文档 生成