CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 徽标和商标
  • 商业解决方案
  • 礼品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 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
    • I18n
    • 日志
    • 邮件器
      • 异常
      • 传输
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用工具
    • 验证
    • 视图

类 TransportFactory

用于生成电子邮件传输实例的工厂类。

命名空间: Cake\Mailer

属性摘要

  • $_config protected static
    array<string|int, array<string, mixed>>

    配置集。

  • $_dsnClassMap protected static
    array<string, string>

    一个将 URL 方案映射到完全限定的 Transport 类名的数组

  • $_registry protected static
    Cake\Mailer\TransportRegistry

    用于创建和使用传输实例的传输注册表。

方法摘要

  • _buildTransport() protected static

    查找并构建所需传输类的实例。

  • configured() public static

    返回包含命名配置的数组

  • drop() public static

    删除已构造的适配器。

  • get() public static

    获取传输实例。

  • getConfig() public static

    读取现有配置。

  • getConfigOrFail() public static

    读取特定键的现有配置。

  • getDsnClassMap() public static

    返回此类的 DSN 类映射。

  • getRegistry() public static

    返回用于创建和使用传输实例的传输注册表。

  • parseDsn() public static

    将 DSN 解析为有效的连接配置

  • setConfig() public static

    此方法可用于为应用程序定义配置适配器。

  • setDsnClassMap() public static

    更新此类的 DSN 类映射。

  • setRegistry() public static

    设置用于创建和使用传输实例的传输注册表实例。

方法详细信息

_buildTransport() ¶ protected static

_buildTransport(string $name): void

查找并构建所需传输类的实例。

参数
string $name

需要构建传输实例的配置数组的名称

返回
void
抛出
InvalidArgumentException
当无法创建传输时。

configured() ¶ public static

configured(): list<string>

返回包含命名配置的数组

返回
list<string>

drop() ¶ public static

drop(string $config): bool

删除已构造的适配器。

如果要修改现有配置,应先删除它,更改配置,然后重新添加它。

如果实现的对象支持一个 $_registry 对象,则命名配置也将从注册表中卸载。

参数
string $config

要删除的现有配置。

返回
bool

get() ¶ public static

get(string $name): Cake\Mailer\AbstractTransport

获取传输实例。

参数
string $name

配置名称。

返回
Cake\Mailer\AbstractTransport

getConfig() ¶ public static

getConfig(string $key): mixed|null

读取现有配置。

参数
string $key

配置的名称。

返回
mixed|null

getConfigOrFail() ¶ public static

getConfigOrFail(string $key): mixed

读取特定键的现有配置。

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

参数
string $key

配置的名称。

返回
mixed
抛出
InvalidArgumentException
如果值不存在。

getDsnClassMap() ¶ public static

getDsnClassMap(): array<string, class-string>

返回此类的 DSN 类映射。

返回
array<string, class-string>

getRegistry() ¶ public static

getRegistry(): Cake\Mailer\TransportRegistry

返回用于创建和使用传输实例的传输注册表。

返回
Cake\Mailer\TransportRegistry

parseDsn() ¶ public static

parseDsn(string $dsn): array<string, mixed>

将 DSN 解析为有效的连接配置

此方法允许使用类似于 PEAR::DB 中使用的格式设置 DSN。以下是其用法的示例

$dsn = 'mysql://user:pass@localhost/database?';
$config = ConnectionManager::parseDsn($dsn);

$dsn = 'Cake\Log\Engine\FileLog://?types=notice,info,debug&file=debug&path=LOGS';
$config = Log::parseDsn($dsn);

$dsn = 'smtp://user:secret@localhost:25?timeout=30&client=null&tls=null';
$config = Email::parseDsn($dsn);

$dsn = 'file:///?className=\My\Cache\Engine\FileEngine';
$config = Cache::parseDsn($dsn);

$dsn = 'File://?prefix=myapp_cake_translations_&serialize=true&duration=+2 minutes&path=/tmp/persistent/';
$config = Cache::parseDsn($dsn);

对于所有类,scheme 的值都设置为 className 的值,除非它们已另行指定。

请注意,查询字符串参数也会被解析并设置为返回配置中的值。

参数
string $dsn

要转换为配置数组的 DSN 字符串

返回
array<string, mixed>
抛出
InvalidArgumentException
如果没有传递字符串,或者传递了无效字符串

setConfig() ¶ public static

setConfig(array<string, mixed>|string $key, mixed $config = null): void

此方法可用于为应用程序定义配置适配器。

要在运行时更改适配器的配置,首先删除适配器,然后重新配置它。

适配器在执行第一个操作之前不会被构造。

用法

假设该类的名称是 Cache,则支持以下方案

设置缓存引擎。

Cache::setConfig('default', $settings);

注入已构造的适配器

Cache::setConfig('default', $instance);

一次配置多个适配器

Cache::setConfig($arrayOfConfig);
参数
array<string, mixed>|string $key

配置的名称,或多个配置的数组。

mixed $config optional

配置值。通常是适配器名称 => 配置数据的数组。

返回
void
抛出
BadMethodCallException
当尝试修改现有配置时。
LogicException
当尝试存储结构无效的配置数组时。

setDsnClassMap() ¶ public static

setDsnClassMap(array<string, string> $map): void

更新此类的 DSN 类映射。

参数
array<string, string> $map

要应用的类映射的添加/编辑。

返回
void

setRegistry() ¶ public static

setRegistry(Cake\Mailer\TransportRegistry $registry): void

设置用于创建和使用传输实例的传输注册表实例。

还可以注入新的注册表实例。

参数
Cake\Mailer\TransportRegistry $registry

可注入的注册表对象。

返回
void

属性详细信息

$_config ¶ protected static

配置集。

类型
array<string|int, array<string, mixed>>

$_dsnClassMap ¶ protected static

一个将 URL 方案映射到完全限定的 Transport 类名的数组

类型
array<string, string>

$_registry ¶ protected static

用于创建和使用传输实例的传输注册表。

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

使用 CakePHP API 文档 生成