We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
3.nでは #2127 でSymfonyFrameworkExtraBundleが提供している各種アノテーションを利用できるようになりました。
本issueは、コントローラに付与するアノテーションについての規約の素案です。
/** * @Component * // - @Routeでコンテナからインスタンスを取得するため、@Componentでコンテナに登録する * // - コンテナIDの指定は原則行わなず、クラス名のFQDNでコンテナに登録する * * @Route(service=TopController::class) * // - serviceのみ指定する * // - serviceはコントローラのクラス名を指定し、コンテナからインスタンスを取得する */ class TopController { /** * // @Method("POST") * // - ControllerProviderでmatch指定されているものは原則省略する * // - POST/DELETE/PUTなど、必要な場合のみ付与する * * @Route("/", requirements={"id" = "\d+"}, name="homepage") * // - path, requirements, nameの順に指定する * // - nameは3.0.xのControllerProviderのbindの値を踏襲する * * @Template("index.twig") * // - テンプレート名は省略しない * // - メソッドの戻り値はパラメータの連想配列を返却。$app->renderは使用しない * // - ※現状省略してもTemplateGuesserが対応していないため機能しない * * // @ParamConverter * // - コードの記述を減らせるため積極的に利用する * // - @Route("path/to/{id}") の形式の場合は、自動変換が行われるため@ParamConverterは省略可能 * */ public function index(Application $app, Request $request, Product $Product) { return []; // @Templateで指定したtwigに引き渡すパラメータを連想配列で返却 } }
メソッドの引数は、3.0.xと同様、Application $app, Request $request, [params...] で統一します。
Application $app, Request $request, [params...]
public function index(Application $app, Request $request, Product $Product...) {
管理画面のpathを指定する場合は、/{_admin}を指定します。
/{_admin}
/** * @Component * @Route(service=CustomerController::class) */ class CustomerController { /** * @Route("/{_admin}/customer", name="admin_customer") */ public function index(Application $app, Request $request) {
3.0.xでは、以下のように、明示的に有効にする必要がありましたが、3.nでは自動的に判定されるため、以下のコードは不要です。
// 強制SSL if ($app['config']['force_ssl'] == \Eccube\Common\Constant::ENABLED) { $c->requireHttps(); }
AbstractControllerの取扱
$app->url()
コントローラのリファクタリング
#2463
The text was updated successfully, but these errors were encountered:
使用するコンポーネントが変わっていたりするので更新が必要です。
Sorry, something went wrong.
コントローラで使用できるアノテーションは以下を参照してください http://doc4.ec-cube.net/customize_controller
No branches or pull requests
概要(Overview)
3.nでは #2127 でSymfonyFrameworkExtraBundleが提供している各種アノテーションを利用できるようになりました。
本issueは、コントローラに付与するアノテーションについての規約の素案です。
アノテーションのコーディング規約
全体コード
メソッドの引数について
メソッドの引数は、3.0.xと同様、
Application $app, Request $request, [params...]
で統一します。管理画面のpath指定について
管理画面のpathを指定する場合は、
/{_admin}
を指定します。httpsの指定について
3.0.xでは、以下のように、明示的に有効にする必要がありましたが、3.nでは自動的に判定されるため、以下のコードは不要です。
課題事項
AbstractControllerの取扱
$app->url()
など)はコントローラで使用できるようにTrait化するコントローラのリファクタリング
関連
#2463
The text was updated successfully, but these errors were encountered: