diff --git a/docs/ja/development.rst b/docs/ja/development.rst
index 070e43a5c..6e8a0eeaa 100644
--- a/docs/ja/development.rst
+++ b/docs/ja/development.rst
@@ -17,20 +17,19 @@ Bake イベント
例えば、bake ビュークラスに他のヘルパーを追加するためにこのイベントは使用されます。 ::
on('Bake.initialize', function (Event $event) {
+ // in src/Application::bootstrapCli()
+
+ EventManager::instance()->on('Bake.initialize', function (EventInterface $event) {
$view = $event->getSubject();
// bake テンプレートの中で MySpecial ヘルパーの使用を可能にします
$view->loadHelper('MySpecial', ['some' => 'config']);
// そして、$author 変数を利用可能にするために追加
- $view->set('author', 'Andy');
-
+\ $view->set('author', 'Andy');
});
別のプラグインの中から bake を変更したい場合は、プラグインの ``config/bootstrap.php``
@@ -42,12 +41,12 @@ Bake イベントは、既存のテンプレートに小さな変更を行うた
``Bake.beforeRender`` で呼び出される関数を使用することができます。 ::
on('Bake.beforeRender', function (Event $event) {
+ // in src/Application::bootstrapCli()
+
+ EventManager::instance()->on('Bake.beforeRender', function (EventInterface $event) {
$view = $event->getSubject();
// indexes の中のメインデータ変数に $rows を使用
@@ -65,36 +64,34 @@ Bake イベントは、既存のテンプレートに小さな変更を行うた
if ($view->get('singularVar')) {
$view->set('singularVar', 'theOne');
}
-
- });
-
+
特定の生成されたファイルへの ``Bake.beforeRender`` と ``Bake.afterRender``
イベントを指定することもあるでしょう。例えば、
**Controller/controller.twig** ファイルから生成する際、 UsersController
に特定のアクションを追加したい場合、以下のイベントを使用することができます。 ::
on(
'Bake.beforeRender.Controller.controller',
- function (Event $event) {
+ function (EventInterface $event) {
$view = $event->getSubject();
- if ($view->viewVars['name'] == 'Users') {
+ if ($view->get('name') === 'Users') {
// Users コントローラーに login と logout を追加
- $view->viewVars['actions'] = [
+ $view->set('actions', [
'login',
'logout',
'index',
'view',
'add',
'edit',
- 'delete'
- ];
+ 'delete',
+ ]);
}
}
);
@@ -109,71 +106,100 @@ Bake テンプレート構文
Bake テンプレートファイルは、 `Twig `__
テンプレート構文を使用します。
-だから、例えば、以下のようにシェルを bake した場合:
+だから、例えば、以下のようにコマンドを bake した場合:
.. code-block:: bash
- bin/cake bake shell Foo
+ bin/cake bake command Foo
-(**vendor/cakephp/bake/src/Template/Bake/Shell/shell.twig**) を使用した
+(**vendor/cakephp/bake/templates/bake/Command/command.twig**) を使用した
テンプレートは、以下のようになります。 ::
`` Bake テンプレートの PHP 終了タグ
- * ``<%=`` Bake テンプレートの PHP ショートエコータグ
- * ``<%-`` Bake テンプレートの PHP 開始タグ、タグの前に、先頭の空白を除去
- * ``-%>`` Bake テンプレートの PHP 終了タグ、タグの後に末尾の空白を除去
-
.. _creating-a-bake-theme:
Bake テーマの作成
@@ -184,102 +210,107 @@ Bake テーマの作成
これを行うための最善の方法は、次のとおりです。
#. 新しいプラグインを bake します。プラグインの名前は bake の「テーマ」名になります。
-#. 新しいディレクトリー **plugins/[name]/src/Template/Bake/Template/** を作成します。
-#. **vendor/cakephp/bake/src/Template/Bake/Template** から上書きしたい
+ 例 ``bin/cake bake plugin custom_bake``
+#. 新しいディレクトリー **plugins/CustomBake/templates/bake/** を作成します。
+#. **vendor/cakephp/bake/templates/bake** から上書きしたい
テンプレートをあなたのプラグインの中の適切なファイルにコピーしてください。
-#. bake を実行するときに、必要であれば、 bake のテーマを指定するための ``--theme``
+#. bake を実行するときに、必要であれば、 bake のテーマを指定するための ``--theme CustomBake``
オプションを使用してください。各呼び出しでこのオプションを指定しなくても済むように、
カスタムテーマをデフォルトテーマとして使用するように設定することもできます。 ::
Test->classSuffixes[$this->name()])) {
- $this->Test->classSuffixes[$this->name()] = 'Foo';
+ $this->Test->classSuffixes[$this->name()] = 'Foo';
}
$name = ucfirst($this->name());
if (!isset($this->Test->classTypes[$name])) {
- $this->Test->classTypes[$name] = 'Foo';
+ $this->Test->classTypes[$name] = 'Foo';
}
return parent::bakeTest($className);
@@ -291,6 +322,20 @@ FooTask.php ファイルは次のようになります。 ::
あなたのファイルを導くために使用されるサブ名前空間です。
前の例では、名前空間 ``App\Test\TestCase\Foo`` でテストを作成します。
+BakeView クラスの設定
+==============================
+
+bake コマンドは ``BakeView`` クラスをテンプレートをレンダリングするために使います。 You can
+access the instance by listening to the ``Bake.initialize`` イベントを監視するためにこのインスタンスにアクセスできます。 例えば、以下の様にして独自のヘルパーを読み込みbakeテンプレートで使用できます::
+
+ on(
+ 'Bake.initialize',
+ function ($event, $view) {
+ $view->loadHelper('Foo');
+ }
+ );
+
.. meta::
:title lang=ja: Bake の拡張
:keywords lang=ja: command line interface,development,bake view, bake template syntax,twig,erb tags,percent tags
diff --git a/docs/ja/index.rst b/docs/ja/index.rst
index a4e503963..ce1e65ed9 100644
--- a/docs/ja/index.rst
+++ b/docs/ja/index.rst
@@ -14,7 +14,7 @@ bake は数分で完全に機能するアプリケーションを作成できま
bake を使用したり拡張する前に、アプリケーションに bake をインストールしておいてください。
bake は Composer を使ってインストールするプラグインとして提供されています。 ::
- composer require --dev cakephp/bake:"^2.0"
+ composer require --dev cakephp/bake:"^3.0"
上記のコマンドは、bake を開発環境で使用するパッケージとしてインストールします。
この入れ方の場合、本番環境としてデプロイする際には、 bake はインストールされません。
diff --git a/docs/ja/usage.rst b/docs/ja/usage.rst
index 9912102ef..595c520f1 100644
--- a/docs/ja/usage.rst
+++ b/docs/ja/usage.rst
@@ -12,87 +12,59 @@ cake コンソールは、 PHP CLI (command line interface) で実行します
bake を実行する前にデータベースとの接続を確認しましょう。
-``bin/cake bake`` を引数無しで実行すると可能なタスクを表示できます。
-
-Windows システムの場合、 ``bin\cake bake`` を試してみてください。
-
-それは以下のように表示されます。 ::
-
- $ bin/cake bake
-
- Welcome to CakePHP v3.1.6 Console
- ---------------------------------------------------------------
- App : src
- Path: /var/www/cakephp.dev/src/
- PHP: 5.5.8
- ---------------------------------------------------------------
- The following commands can be used to generate skeleton code for your application.
-
- Available bake commands:
-
- - all
- - behavior
- - cell
- - component
- - controller
- - fixture
- - form
- - helper
- - mailer
- - migration
- - migration_snapshot
- - model
- - plugin
- - template
- - test
-
- By using `cake bake [name]` you can invoke a specific bake task.
-
-より詳しい各コマンドの情報を得るには、 ``--help`` オプションをつけ実行してください。 ::
-
- $ bin/cake bake controller --help
-
- Welcome to CakePHP v3.1.6 Console
- ---------------------------------------------------------------
- App : src
- Path: /var/www/cakephp.dev/src/
- ---------------------------------------------------------------
- Bake a controller skeleton.
-
- Usage:
- cake bake controller [subcommand] [options] []
-
- Subcommands:
-
- all Bake all controllers with CRUD methods.
-
- To see help on a subcommand use `cake bake controller [subcommand] --help`
-
- Options:
-
- --help, -h Display this help.
- --verbose, -v Enable verbose output.
- --quiet, -q Enable quiet output.
- --plugin, -p Plugin to bake into.
- --force, -f Force overwriting existing files without prompting.
- --connection, -c The datasource connection to get data from.
- (default: default)
- --theme, -t The theme to use when baking code.
- --components The comma separated list of components to use.
- --helpers The comma separated list of helpers to use.
- --prefix The namespace/routing prefix to use.
- --no-test Do not generate a test skeleton.
- --no-actions Do not generate basic CRUD action methods.
-
- Arguments:
-
- name Name of the controller to bake. Can use Plugin.name to bake
- controllers into plugins. (optional)
-
-Bake テーマオプション
+``bin/cake bake --help`` を実行すると可能なbakeコマンドを表示できます。
+(Windows システムの場合、 ``bin\cake bake --help`` を使います。)::
+
+ $ bin/cake bake --help
+ Current Paths:
+
+ * app: src/
+ * root: /path/to/your/app/
+ * core: /path/to/your/app/vendor/cakephp/cakephp/
+
+ Available Commands:
+
+ Bake:
+ - bake all
+ - bake behavior
+ - bake cell
+ - bake command
+ - bake command_helper
+ - bake component
+ - bake controller
+ - bake controller all
+ - bake enum
+ - bake fixture
+ - bake fixture all
+ - bake form
+ - bake helper
+ - bake mailer
+ - bake middleware
+ - bake model
+ - bake model all
+ - bake plugin
+ - bake template
+ - bake template all
+ - bake test
+
+ To run a command, type `cake command_name [args|options]`
+ To get help on a specific command, type `cake command_name --help`
+
+Bake モデル
+===========
+
+モデルは、既存のデータベーステーブルから一般的に生成(bake)されます。
+規約が適用されるため、外部キー ``thing_id`` とテーブル ``things`` の主キー ``id`` に基づいてリレーションが検出されます。
+
+規約から外れたリレーションの場合、Bake がリレーションを検出するために、制約/外部キー定義でリレーションを使用できます。例::
+
+ ->addForeignKey('billing_country_id', 'countries') // defaults to `id`
+ ->addForeignKey('shipping_country_id', 'countries', 'cid')
+
+Bake テーマ
=====================
-テーマオプションは全 bake コマンドで一般的です。また、bake テンプレートファイルを変更することができます。
+テーマオプションは全 bake コマンドで共通です。また、bakeする際のbake テンプレートファイルを変更することができます。
テーマを作るには、 :ref:`Bake テーマ作成ドキュメント ` をご覧ください。
.. meta::