Skip to content

reference/index更新、reference/twig_referenceとreference/configuration/kernel追加,cookbook/configuration/override_dir_structure追加,reference/forms/twig_reference翻訳 #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,8 @@ HTTP 認証やフォームログインなどの全ての認証メカニズムは

ユーザが一旦ログアウトすると、そのユーザは、上記の ``target`` の値によって定義されたパス(``homepage`` など)にリダイレクトされます。ログアウトの設定に関する詳細は :doc:`Security Configuration Reference</reference/configuration/security>` を参照してください。

.. _book-security-template:

テンプレートにおけるアクセス制御
--------------------------------

Expand Down
5 changes: 4 additions & 1 deletion book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,10 @@ apples`` が使われます。
多くの場合、翻訳はテンプレート内で発生します。 Symfony2 は Twig と PHP テンプレートの
両方をネイティブでサポートします。

.. _book-translation-tags:

Twig テンプレート
~~~~~~~~~~~~~~~~~

Symfony2 はメッセージの翻訳に役立つよう特別な Twig タグ (``trans`` と ``transChoice``)
を提供します。

Expand Down Expand Up @@ -724,6 +725,8 @@ Symfony2 はメッセージの翻訳に役立つよう特別な Twig タグ (``t
{0} There is no apples|{1} There is one apple|]1,Inf] There are %count% apples
{% endtranschoice %}

.. _book-translation-filters:

``trans``、``transchoice``フィルターは、*variable texts*や複雑な式を変換するために使用できます。

.. code-block:: jinja
Expand Down
22 changes: 22 additions & 0 deletions cookbook/configuration/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. note::

* 対象バージョン:2.3
* 翻訳更新日:2013/11/26

コンフィギュレーション
=========================

.. toctree::
:maxdepth: 2

environments
override_dir_structure
external_parameters
pdo_session_storage


.. front_controllers_and_kernel 未翻訳
.. apache_router 未翻訳
.. web_server_configuration 未翻訳

.. 2013/11/26 77web fe5aa3ba5b9558c37db93c97ac5406d6c04d35ad
146 changes: 146 additions & 0 deletions cookbook/configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
.. index::
single: Override Symfony

.. note::

* 対象バージョン:2.3
* 翻訳更新日:2013/11/26


Symfony のディレクトリ構造をカスタマイズする方法
=====================================================

Symfony には最初からデフォルトのディレクトリ構造があります。このディレクトリ構造は開発者が好きなように変更することができます。
デフォルトのディレクトリ構造は下記のようになっています。

.. code-block:: text

app/
cache/
config/
logs/
...
src/
...
vendor/
...
web/
app.php
...

.. _override-cache-dir:

``cache`` ディレクトリを変更する
--------------------------------

キャッシュのディレクトリは、アプリケーションの ``AppKernel`` クラスの ``getCacheDir`` をオーバーライドすることにより変更できます。::

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
// ...

public function getCacheDir()
{
return $this->rootDir.'/'.$this->environment.'/cache';
}
}

``$this->rootDir`` は ``app`` ディレクトリへの絶対パスで、 ``$this->environment`` は現在の環境です(例えば、 ``dev`` のような)
上の例では、キャッシュのディレクトリを ``app/{environment}/cache`` に変更しています。

.. caution::

``cache`` ディレクトリは各環境ごとに別々にしておかなくてはいけません。さもないと、予想できない挙動となることがあります。
各環境にはそれぞれの設定ファイルのキャッシュを生成するため、キャッシュファイルを保存するために他とは違うディレクトリが必要なのです。

.. _override-logs-dir:

``logs`` ディレクトリを変更する
-------------------------------

``logs`` ディレクトリを変更する方法は、 ``cache`` ディレクトリを変更するのと同じですが、オーバーライドするメソッドは ``getLogDir`` です。::

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
// ...

public function getLogDir()
{
return $this->rootDir.'/'.$this->environment.'/logs';
}
}

上の例ではディレクトリのパスを ``app/{environment}/logs`` に変更しています。

``web`` ディレクトリを変更する
------------------------------

``web`` ディレクトリのパスを変更したり移動したりする必要があるなら、フロントコントローラーである ``app.php`` と ``app_dev.php`` にある ``app`` ディレクトリのパスが正しく保たれているだけで大丈夫です。
単に web ディレクトリのディレクトリ名を変更しただけであれば、そのままで構いません。しかし、もしどこかに移動したのなら、フロントコントローラーに含まれるパスを変更しなければなりません。::

require_once __DIR__.'/../Symfony/app/bootstrap.php.cache';
require_once __DIR__.'/../Symfony/app/AppKernel.php';

更に、 ``composer.json`` にある ``extra.symfony-web-dir`` オプションも変更しなければならないでしょう。

.. code-block:: json

{
...
"extra": {
...
"symfony-web-dir": "my_new_web_dir"
}
}

.. tip::

共有ホスティングでは ``public_html`` が公開ディレクトリとして使われることがあります。 ``web`` ディレクトリを ``public_html`` にリネームするのは、共有ホスティングで Symfony プロジェクトを動かす方法の一つです。
別の方法として、アプリケーションを公開ディレクトリ外にデプロイし、 ``public_html`` を削除して、アプリケーションの ``web`` ディレクトリへのシンボリックリンクに置き換えてしまうという方法もあります。

.. note::

AsseticBundle を使っている場合は、バンドルが ``web`` ディレクトリを正しく使えるように下記の設定も必要です。

.. configuration-block::

.. code-block:: yaml

# app/config/config.yml

# ...
assetic:
# ...
read_from: "%kernel.root_dir%/../../public_html"

.. code-block:: xml

<!-- app/config/config.xml -->

<!-- ... -->
<assetic:config read-from="%kernel.root_dir%/../../public_html" />

.. code-block:: php

// app/config/config.php

// ...
$container->loadFromExtension('assetic', array(
// ...
'read_from' => '%kernel.root_dir%/../../public_html',
));

設定を変更したら、再度アセットをダンプするだけで、アプリケーションを使うことができます。

.. code-block:: bash

$ php app/console assetic:dump --env=prod --no-debug


.. 2013/12/09 77web 1f7898045f3f1ad06dc63f32f4d921519fc5e3d7
4 changes: 1 addition & 3 deletions cookbook/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

email
gmail
configuration/environments
configuration/pdo_session_storage
configuration/external_parameters
configuration/index
templating/PHP
controller/error_pages
controller/service
Expand Down
8 changes: 6 additions & 2 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@
* :doc:`/cookbook/validation/custom_constraint`
* (doctrine) :doc:`/cookbook/doctrine/file_uploads`

* **コンフィギュレーションとサービスコンテナ**
* **コンフィギュレーション**

* :doc:`/cookbook/configuration/environments`
* :doc:`/cookbook/configuration/override_dir_structure`
* :doc:`/cookbook/configuration/external_parameters`
* :doc:`/cookbook/configuration/pdo_session_storage`

* **サービスコンテナ**

* :doc:`/cookbook/service_container/factories`
* :doc:`/cookbook/service_container/parentservices`
* :doc:`/cookbook/service_container/scopes`
* :doc:`/cookbook/service_container/tags`
* :doc:`/cookbook/configuration/pdo_session_storage`

* **バンドル**

Expand Down
5 changes: 0 additions & 5 deletions reference/YAML.rst

This file was deleted.

91 changes: 91 additions & 0 deletions reference/configuration/kernel.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.. index::
single: Configuration reference; Kernel class

.. note::

* 対象バージョン : 2.3(2.1以降)
* 翻訳更新日 : 2013/11/25

カーネルの設定(例えば AppKernel)
==========================================

設定の中にはカーネルクラス自体によって行うことができるものもあります。(カーネルクラスは通常 ``app/AppKernel.php`` にあります) 設定のカスタマイズは、継承元の :class:`Symfony\\Component\\HttpKernel\\Kernel` クラスの特定のメソッドをオーバーライドすることで実現できます。

設定
-------------

* `キャラクタセット`_
* `カーネル名`_
* `ルートディレクトリ`_
* `キャッシュディレクトリ`_
* `ログディレクトリ`_

キャラクタセット
~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``UTF-8``

アプリケーションで使用されるキャラクタセットです。キャラクタセットを変更するには、 :method:`Symfony\\Component\\HttpKernel\\Kernel::getCharset` メソッドをオーバーライドし、別のキャラクタセットを返すように変更します。たとえば下記のようにします。::

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
public function getCharset()
{
return 'ISO-8859-1';
}
}

カーネル名
~~~~~~~~~~~

**type**: ``string`` **default**: ``app`` (カーネルクラスが配置されているディレクトリ名)

設定を変更するには、 :method:`Symfony\\Component\\HttpKernel\\Kernel::getName` メソッドをオーバーライドしてください。或いは、カーネルクラスを他のディレクトリに移動しても良いです。
たとえば、カーネルを ``app`` から ``foo`` ディレクトリに移動すると、カーネル名は ``foo`` になります。

カーネル名は、通常は直接問題になることはありません。キャッシュファイルの生成に使われるだけだからです。
カーネルを複数使用するアプリケーションを作る場合、一番簡単な方法は ``app`` ディレクトリをコピーしてディレクトリ名を変更することです。( ``foo`` のようなディレクトリ名に)

ルートディレクトリ
~~~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``AppKernel`` のディレクトリ

カーネルのルートディレクトリを返します。 Symfony Standard edition の場合、ルートディレクトリは ``app`` ディレクトリを指しています。

設定を変更するには、 :method:`Symfony\\Component\\HttpKernel\\Kernel::getRootDir` メソッドをオーバーライドします。::

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
// ...

public function getRootDir()
{
return realpath(parent::getRootDir().'/../');
}
}

キャッシュディレクトリ
~~~~~~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``$this->rootDir/cache/$this->environment``

キャッシュディレクトリのパスを返します。設定を変更するには、 :method:`Symfony\\Component\\HttpKernel\\Kernel::getCacheDir` メソッドをオーバーライドしてください。
詳しくは、 ":ref:`override-cache-dir`" を参照してください。


ログディレクトリ
~~~~~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``$this->rootDir/logs``

ログディレクトリのパスを返します。設定を変更するには、 :method:`Symfony\\Component\\HttpKernel\\Kernel::getLogDir` メソッドをオーバーライドしてください。
詳しくは ":ref:`override-logs-dir`" を参照してください。

.. 2013/11/26 77web 4346f75f05a5ee010d0148ea251e99c7f6a02c38
5 changes: 0 additions & 5 deletions reference/configuration/mongodb.rst

This file was deleted.

Loading