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

类 CommandCollection

命令集合。

应用程序使用它来指定其控制台命令。CakePHP 将使用映射的命令来构建和调度 shell 命令。

命名空间: Cake\Console

属性摘要

  • $commands protected
    array<string,Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>>

    命令列表

方法摘要

  • __construct() public

    构造函数

  • add() public

    将命令添加到集合中

  • addMany() public

    一次添加多个命令。

  • autoDiscover() public

    自动发现 CakePHP、应用程序和所有插件中的命令。

  • count() public

    Countable 的实现。

  • discoverPlugin() public

    自动从指定的插件中发现命令。

  • get() public

    获取命令的目标。

  • getIterator() public

    IteratorAggregate 的实现。

  • has() public

    检查指定的 shell 是否存在于集合中。

  • keys() public

    获取可用的命令名称列表。

  • remove() public

    如果存在,则从集合中移除一个命令。

  • resolveNames() protected

    根据现有的命令解析名称

方法详细信息

__construct() ¶ public

__construct(array<string,Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>> $commands = [])

构造函数

参数
array<string,Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>> $commands optional

要添加到集合中的命令映射。

add() ¶ public

add(string $name, Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface> $command): $this

将命令添加到集合中

参数
string $name

要映射的命令的名称。

Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface> $command

要映射的命令。可以是 FQCN 或 CommandInterface 实例。

返回值
$this
抛出
InvalidArgumentException

addMany() ¶ public

addMany(array<string,Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>> $commands): $this

一次添加多个命令。

参数
array<string,Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>> $commands

命令名称 => 命令类/实例的映射。

返回值
$this
参见
\Cake\Console\CommandCollection::add()

autoDiscover() ¶ public

autoDiscover(): array<string, class-stringCake\Console\CommandInterface>>

自动发现 CakePHP、应用程序和所有插件中的命令。

命令将使用文件系统约定来定位。命令按照以下顺序发现

  • CakePHP 提供的命令
  • 应用程序命令

在应用程序中定义的命令将覆盖 CakePHP 提供的具有相同名称的命令。

返回值
array<string, class-stringCake\Console\CommandInterface>>

count() ¶ public

count(): int

Countable 的实现。

获取集合中命令的数量。

返回值
int

discoverPlugin() ¶ public

discoverPlugin(string $plugin): array<string, class-stringCake\Console\CommandInterface>>

自动从指定的插件中发现命令。

发现的命令将与其名称在集合中的现有命令去重。如果一个命令已经定义在集合中,并在一个插件中发现,则只返回长名称 (plugin.command)。

参数
string $plugin

要扫描的插件。

返回值
array<string, class-stringCake\Console\CommandInterface>>

get() ¶ public

get(string $name): Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>

获取命令的目标。

参数
string $name

指定的 shell。

返回值
Cake\Console\CommandInterface|class-stringCake\Console\CommandInterface>
抛出
InvalidArgumentException
当未知的命令被获取时。

getIterator() ¶ public

getIterator(): Traversable

IteratorAggregate 的实现。

返回值
Traversable

has() ¶ public

has(string $name): bool

检查指定的 shell 是否存在于集合中。

参数
string $name

指定的 shell。

返回值
bool

keys() ¶ public

keys(): list<string>

获取可用的命令名称列表。

返回值
list<string>

remove() ¶ public

remove(string $name): $this

如果存在,则从集合中移除一个命令。

参数
string $name

指定的 shell。

返回值
$this

resolveNames() ¶ protected

resolveNames(array<array<string, string>> $input): array<string, class-stringCake\Console\CommandInterface>>

根据现有的命令解析名称

参数
array<array<string, string>> $input

CommandScanner 操作的结果。

返回值
array<string, class-stringCake\Console\CommandInterface>>

属性详细信息

$commands ¶ protected

命令列表

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

使用 CakePHP API Docs 生成