ホームページ >バックエンド開発 >PHPチュートリアル >Magentoの実行プロセス?
Magento の実行プロセスは 1 枚の図で完全に説明できます。
Magento も MVC モードのプログラムですが、通常の MVC の構造とは異なります。
登録の 1 つを通じてプログラムの実行プロセスを見てみましょう:
まず、アドレス バーに http://localhost/magento/index.php/customer/account/create/ と入力して、登録ページに入ります。
ステップ 1: プログラムが URL で顧客を取得すると、モジュール app/code/core/Mage/Customer を自動的に見つけます。
ステップ 2: 次に、プログラムがアカウントを取得すると、コントローラー ファイル app を自動的に見つけます。 /code/core/Mage/Customer/controllers/AccountController.php
ステップ 3: プログラムが作成されると、見つかったコントローラー ファイル内の createAction() メソッドが作成されます。
<code>public function createAction(){ if ($this->_getSession()->isLoggedIn()) { $this->_redirect('*/*'); return; } $this->loadLayout(); $this->_initLayoutMessages('customer/session'); $this->renderLayout(); }</code>
ステップ 4: プログラム読み込みディレクトリ app/design/frontend/base/default/layout/ で customer.xml を実行します。次に、
<code><customer_account_create translate="label"> <label>Customer Account Registration Form</label> <!-- Mage_Customer --> <remove name="right"/> <remove name="left"/> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> <reference name="content"> <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml"> <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label"> <label>Form Fields Before</label> </block> </block> </reference> </customer_account_create></code>
という名前のタグを探します。ステップ 5: 使用するブロックとテンプレートは customer で定義されています。 $this を使用してクラス メソッドにアクセスできます。
したがって、Magento のプログラム実行プロセスは次のように要約できます:
実行コントローラーを取得する -> 実行メソッドでビジネス ロジックとモデル データを処理する -> コントローラーがレイアウト オブジェクトをインスタンス化する -> レイアウト オブジェクトが次のようにブロックをインスタンス化するリクエストに対して→ブロックとテンプレートが1対1に対応して表示ロジックが完成します。