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
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
      • 客户端
      • Cookie
      • 异常
      • 中间件
      • 会话
      • 测试套件
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用程序
    • 验证
    • 视图

类 MiddlewareQueue

提供用于创建和操作中间件“队列”的方法。此队列用于通过 \Cake\Http\Runner 处理请求并生成响应。

命名空间: Cake\Http

属性摘要

  • $container protected
    Cake\Core\ContainerInterface|null
  • $position protected
    int

    迭代器的内部位置。

  • $queue protected
    array<int, mixed>

    中间件的队列。

方法摘要

  • __construct() public

    构造函数

  • add() public

    将中间件追加到队列末尾。

  • count() public

    获取连接的中间件层的数量。

  • current() public

    返回当前中间件。

  • insertAfter() public

    在第一个匹配类之后插入一个中间件对象。

  • insertAt() public

    在特定索引处插入中间件。

  • insertBefore() public

    在第一个匹配类之前插入一个中间件。

  • key() public

    返回中间件的键。

  • next() public

    将当前位置移动到下一个中间件。

  • prepend() public

    将中间件预置到队列开头。

  • push() public

    MiddlewareQueue::add() 的别名。

  • resolve() protected

    将中间件名称解析为符合 PSR 15 的中间件实例。

  • rewind() public

    倒回到队列的第一个元素。

  • seek() public

    在队列中查找给定的位置。

  • valid() public

    检查当前位置是否有效。

方法详情

__construct() ¶ public

__construct(array $middleware = [], Cake\Core\ContainerInterface $container = null)

构造函数

参数
array $middleware 可选

要追加的中间件列表。

Cake\Core\ContainerInterface $container 可选

容器实例。

add() ¶ public

add(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this

将中间件追加到队列末尾。

参数
Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware

要追加的中间件。

返回值
$this

count() ¶ public

count(): int

获取连接的中间件层的数量。

实现 Countable 接口。

返回值
int

current() ¶ public

current(): Psr\Http\Server\MiddlewareInterface

返回当前中间件。

返回值
Psr\Http\Server\MiddlewareInterface
另请参阅
\Iterator::current()

insertAfter() ¶ public

insertAfter(string $class, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this

在第一个匹配类之后插入一个中间件对象。

查找与提供的类匹配的第一个中间件的索引,并在其后插入提供的中间件。如果未找到该类,此方法将像 add() 一样执行。

参数
string $class

要插入中间件之前的类名。

Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware

要插入的中间件。

返回值
$this

insertAt() ¶ public

insertAt(int $index, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this

在特定索引处插入中间件。

如果索引已存在,则将插入新的中间件,并且现有元素将向后移动一个索引。

参数
int $index

要插入的索引。

Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware

要插入的中间件。

返回值
$this

insertBefore() ¶ public

insertBefore(string $class, Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): $this

在第一个匹配类之前插入一个中间件。

查找与提供的类匹配的第一个中间件的索引,并在其前插入提供的中间件。

参数
string $class

要插入中间件之前的类名。

Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware

要插入的中间件。

返回值
$this
抛出
LogicException
如果要插入的中间件未找到。

key() ¶ public

key(): int

返回中间件的键。

返回值
int
另请参阅
\Iterator::key()

next() ¶ public

next(): void

将当前位置移动到下一个中间件。

返回值
void
另请参阅
\Iterator::next()

prepend() ¶ public

prepend(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this

将中间件预置到队列开头。

参数
Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware

要预置的中间件。

返回值
$this

push() ¶ public

push(Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware): $this

MiddlewareQueue::add() 的别名。

参数
Psr\Http\Server\MiddlewareInterfaceClosure|array|string $middleware

要追加的中间件。

返回值
$this
另请参阅
MiddlewareQueue::add()

resolve() ¶ protected

resolve(Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware): Psr\Http\Server\MiddlewareInterface

将中间件名称解析为符合 PSR 15 的中间件实例。

参数
Psr\Http\Server\MiddlewareInterfaceClosure|string $middleware

要解析的中间件。

返回值
Psr\Http\Server\MiddlewareInterface
抛出
InvalidArgumentException
如果未找到中间件。

rewind() ¶ public

rewind(): void

倒回到队列的第一个元素。

返回值
void
另请参阅
\Iterator::rewind()

seek() ¶ public

seek(int $position): void

在队列中查找给定的位置。

参数
int $position

要查找的位置。

返回值
void
另请参阅
\SeekableIterator::seek()

valid() ¶ public

valid(): bool

检查当前位置是否有效。

返回值
bool
另请参阅
\Iterator::valid()

属性详情

$container ¶ protected

类型
Cake\Core\ContainerInterface|null

$position ¶ protected

迭代器的内部位置。

类型
int

$queue ¶ protected

中间件的队列。

类型
array<int, mixed>
OpenHub
Pingping
Linode
  • 企业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻简报
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API Docs 生成