TwigOptions
in package
Twig サービス ({@see \Acms\Services\Template\Twig}) の Environment 構築をコンストラクタ DI で 切り替えるための設定オブジェクト。
同じ Twig クラスを、用途ごとに設定違いでサービスコンテナへ別キー登録する:
template.twig… 公開側テーマ (options=null = 既定。本クラスの既定値と同等)template.mail.twig… メールのファイル経路 (制作者)。フル機能・非サンドボックスtemplate.mail.twig.sandboxed… メールのフォーム直接入力 (運営者)。サンドボックス
Twig 本体はメール固有概念を持たず、本オブジェクトの値だけで挙動が決まる。
Table of Contents
Constants
- DEFAULT_EXTENSIONS = [self::EXTENSION_ACMS, self::EXTENSION_DEBUG, self::EXTENSION_COMMENTED_INCLUDE, self::EXTENSION_ACMS_CONFIG]
- 既定の組込み拡張一式 (公開側テーマ・メールのファイル経路で使うフルセット)。
- EXTENSION_ACMS = 'acms'
- 組込み拡張キー: AcmsExtension (Corrector フィルタ・module/touch/vite 関数・グローバル変数)
- EXTENSION_ACMS_CONFIG = 'acms_config'
- 組込み拡張キー: AcmsConfigExtension (acms_config())
- EXTENSION_COMMENTED_INCLUDE = 'commented_include'
- 組込み拡張キー: CommentedIncludeExtension
- EXTENSION_DEBUG = 'debug'
- 組込み拡張キー: Twig DebugExtension (dump)。信頼境界=制作者の経路でのみ使う
Properties
- $autoescape : mixed
- $cacheDir : string|false
- $extensions : array<string|int, mixed>
- $markdown : bool
- $sandboxFilters : array<string|int, mixed>
- $sandboxFunctions : array<string|int, mixed>
- $sandboxTags : array<string|int, mixed>|null
- $useStringLoader : bool
- $useThemeLoader : bool
Methods
- __construct() : mixed
- isSandboxed() : bool
- サンドボックス経路かどうか。
Constants
DEFAULT_EXTENSIONS
既定の組込み拡張一式 (公開側テーマ・メールのファイル経路で使うフルセット)。
public
array<int, string>
DEFAULT_EXTENSIONS
= [self::EXTENSION_ACMS, self::EXTENSION_DEBUG, self::EXTENSION_COMMENTED_INCLUDE, self::EXTENSION_ACMS_CONFIG]
EXTENSION_ACMS
組込み拡張キー: AcmsExtension (Corrector フィルタ・module/touch/vite 関数・グローバル変数)
public
mixed
EXTENSION_ACMS
= 'acms'
EXTENSION_ACMS_CONFIG
組込み拡張キー: AcmsConfigExtension (acms_config())
public
mixed
EXTENSION_ACMS_CONFIG
= 'acms_config'
EXTENSION_COMMENTED_INCLUDE
組込み拡張キー: CommentedIncludeExtension
public
mixed
EXTENSION_COMMENTED_INCLUDE
= 'commented_include'
EXTENSION_DEBUG
組込み拡張キー: Twig DebugExtension (dump)。信頼境界=制作者の経路でのみ使う
public
mixed
EXTENSION_DEBUG
= 'debug'
Properties
$autoescape read-only
public
mixed
$autoescape
= null
$cacheDir read-only
public
string|false
$cacheDir
= false
$extensions read-only
public
array<string|int, mixed>
$extensions
= self::DEFAULT_EXTENSIONS
$markdown read-only
public
bool
$markdown
= true
$sandboxFilters read-only
public
array<string|int, mixed>
$sandboxFilters
= []
$sandboxFunctions read-only
public
array<string|int, mixed>
$sandboxFunctions
= []
$sandboxTags read-only
public
array<string|int, mixed>|null
$sandboxTags
= null
$useStringLoader read-only
public
bool
$useStringLoader
= false
$useThemeLoader read-only
public
bool
$useThemeLoader
= true
Methods
__construct()
public
__construct([string|callable|false|null $autoescape = null ][, string|false $cacheDir = false ][, array<int, string> $extensions = self::DEFAULT_EXTENSIONS ][, bool $markdown = true ][, bool $useThemeLoader = true ][, bool $useStringLoader = false ][, array<int, string>|null $sandboxTags = null ][, array<int, string> $sandboxFilters = [] ][, array<int, string> $sandboxFunctions = [] ]) : mixed
Parameters
- $autoescape : string|callable|false|null = null
-
Twig の autoescape 設定。 null は Twig 既定に委ねる (= 設定しない。公開側の現挙動を保つ)。 メール HTML は 'html'、プレーン/サンドボックスは false、拡張子で切替えるなら callable。
- $cacheDir : string|false = false
-
キャッシュディレクトリ。false でキャッシュ無効 (文字列レンダ向け)
- $extensions : array<int, string> = self::DEFAULT_EXTENSIONS
-
Environment に attach する組込み拡張キーの配列 (self::EXTENSION_ACMS 等)。 既定は self::DEFAULT_EXTENSIONS (フルセット)。サンドボックス経路は [self::EXTENSION_ACMS] のように 絞り、dump を提供する DebugExtension 等の危険な拡張を持ち込まない。未知のキーは無視される。
- $markdown : bool = true
-
Markdown トークンパーサ (MarkdownTokenParser) を追加するか
- $useThemeLoader : bool = true
-
テーマ階層を走査する CustomLoader を使うか (include/extends・パス指定 render に必要)
- $useStringLoader : bool = false
-
文字列を載せる ArrayLoader を前段に持つか (Twig::renderString 用)
- $sandboxTags : array<int, string>|null = null
-
null で非サンドボックス。非 null で SandboxExtension を有効化し、 この許可タグに加えて AcmsExtension・extendsTwig 由来のフィルタ/関数名を許可リストへ自動合成する
- $sandboxFilters : array<int, string> = []
-
サンドボックスの基本許可フィルタ
- $sandboxFunctions : array<int, string> = []
-
サンドボックスの基本許可関数
isSandboxed()
サンドボックス経路かどうか。
public
isSandboxed() : bool