components.xmlは、フレームワーク初期化時にコンテナに登録するコンポーネントを設定します。
通常インストール状態から変更することはありませんが、WEBアプリケーション内共通で使用するコンポーネントを追加する場合は、
このファイルに追加します。
アクションレベルでのコンポーネントを登録する場合は、actions.xml で定義します。
<?xml version="1.0" encoding="UTF-8" ?>
<syl-components xmlns="http://syl.jp/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://syl.jp/schema syl-components.xsd">
<component name="request"
class="SyL_RequestAbstract"
file="Core/Request/SyL_RequestAbstract.php"
priority="2">
<constructor name="getInstance" static="true" />
</component>
<component name="response"
class="SyL_ResponseAbstract"
file="Core/Response/SyL_ResponseAbstract.php"
priority="5">
<constructor name="getInstance" static="true" />
<method name="display" event="renderStream">
<arg type="component">view</arg>
</method>
</component>
<component name="data"
class="SyL_Data"
file="Core/SyL_Data.php"
priority="5">
<constructor name="createInstance" static="true">
<arg type="component">request</arg>
</constructor>
</component>
<component name="context"
class="SyL_ContextAbstract"
file="Core/Context/SyL_ContextAbstract.php"
priority="6">
<constructor name="createInstance" static="true">
<arg type="component">data</arg>
</constructor>
</component>
<component name="view"
class="SyL_ViewAbstract"
file="Core/View/SyL_ViewAbstract.php"
event="renderStream"
priority="1">
<constructor name="createInstance" static="true">
<arg type="component">context</arg>
<arg type="component">data</arg>
</constructor>
<method name="render" />
</component>
</syl-components>
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| syl-components | - | - | - | components.xmlのTOPレベルノード |
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| component | syl-components | - | - | コントローラ起動時にコンテナに登録するコンポーネントを指定するタグ。 下位ノードには「constructor」「setter」「method」ノードを1つ以上指定する。 |
| name | ○ | コンポーネント名。コンテナ内で一意な名前を指定する。 | ||
| file | ○ | コンポーネントのファイル名 | ||
| class | コンポーネントとして登録するクラス名。デフォルトはname属性で指定された値 | |||
| reference | コンポーネントのインスタンスを参照で取得するフラグ。 true … 参照渡しで取得する false … 値渡しで取得する(デフォルト) ※ただし、PHP5ではコンポーネントの取得は全て参照となる。 |
|||
| event | コンポーネントのインスタンスを作成するイベント。デフォルトは「initStream」。 | |||
| priority | コンポーネントの実行優先順位。デフォルトは「3」 | |||
| enable | - | コンポーネントを使用するフラグ true … 使用する(デフォルト) false … 使用しない |
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| constructor | component | - | - | コンポーネントのコンストラクタインジェクションメソッド。 |
| static | スタティックメソッドで取得する場合、そのメソッド名を指定する。 | |||
| event | コンポーネントのインスタンスを作成するイベント。componentノードにも指定されている場合は、上書きする。 |
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| setter | component | - | - | コンポーネントのセッターインジェクションメソッド。 |
| name | ○ | セッターメソッド名。 direct属性がtrueの場合、直接オブジェクトのプロパティにセットされ、falseの場合セッターメソッド(例えば、setNameならテキストに「name」のみ指定)を指定する。 |
||
| direct | オブジェクトのプロパティ直接セットするフラグ。 true … 直接オブジェクトのプロパティにセット false … セッターメソッドを使用してセット(デフォルト) |
|||
| event | メソッドを実行するイベント。 |
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| method | component | - | - | コンポーネントのメソッドインジェクションメソッド。 |
| name | ○ | メソッド名 | ||
| event | メソッドを実行するイベント。 |
| タグ名 | 親タグ名 | 属性 | 必須 | 説明 |
|---|---|---|---|---|
| arg | constructor setter method |
- | - | constructor、setter、methodの各ノードに対する引数を指定するタグ。 |
| type | - | テキスト値を解釈するタイプ。 component … コンテナ内のコンポーネント名 constant … 定数名 value … 指定値(デフォルト) |
||
| reference | - | 取得する値を参照で取得するかフラグ。 true … 参照渡しで取得する false … 値渡しで取得する(デフォルト) ※ただし、PHP5ではコンポーネントの取得は全て参照となる。 |
||
| (値) | ○ | type属性に対応した値を指定する。 |