それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

symfonyのテンプレート名前付けルールを応用する。

indexSuccess.phpの名前付けルール
/usr/share/php/symfony/view/sfView.class.php

に以下のようなコードが有る。つまり、indexSuccessの他に、

  • indexAlert
  • indexError
  • indexInput
  • indexNone

が可能ということ。それぞれ、のテンプレートに切り分けるときは

return sfView::ERROR;

などreturnする変数を変える。で、応用を考える。

class myView extends sfView {
  const HOGE = 'Hoge';
}

などと書けば、

indexHoge.php

をテンプレートとして使えるかも。

<?php
abstract class sfView
{
  /**
   * Show an alert view.
   */
  const ALERT = 'Alert';
  /**
   * Show an error view.
   */
  const ERROR = 'Error';
  /**
   * Show a form input view.
   */
  const INPUT = 'Input';
  /**
   * Skip view execution.
   */
  const NONE = 'None';
  /** 
   * Show a success view.
   */
  const SUCCESS = 'Success';
  /** 
   * Do not render the presentation.
   */
  const RENDER_NONE = 1;
  /** 
   * Render the presentation to the client.
   */