LoginSignup
6
10

More than 3 years have passed since last update.

symfony 1.4 メモ(context)

Last updated at Posted at 2017-03-31
  1. symfony 1.4 メモ(アクション)
  2. symfony 1.4 メモ(context)
  3. symfony 1.4 メモ(モデル)
  4. symfony 1.4 メモ(schemaの書き方)
  5. symfony 1.4 メモ(Doctrine)
  6. symfony 1.4 メモ(フォーム)
  7. symfony 1.4 メモ(コマンド)
  8. symfony 1.4 メモ(ユーティリティ)

テンプレート上での使用

contextオブジェクト全体(sfContextインスタンス)

// アクション名を得る
$sf_context->getActionName()

// モジュール名を得る
$sf_context->getModuleName()

// モジュールディレクトリを得る
$sf_context->getModuleDirectory()

requestオブジェクト(sfRequestインスタンス)

// エラーが生じれば真
$sf_request->hasErrors()

// 生じたすべてのエラー内容の配列を得る
$sf_request->getErrors()

// リクエストのメソッド(GETかPOSTか)を得る
$sf_request->getMethod()

// パラメーター'a'の値を得る
$sf_request->getParameter('a')

// URI
$sf_request->getUri()

// タイトル
$sf_request->getTitle()

リクエストのパラメーター

// パラメーター'a'が存在すれば真
$sf_params->has('a')

// パラメーター'a'の値を得る。得られなければ'default'を返す
$sf_params->get('a', 'default')

// エスケープの影響を受けない
$sf_params->getParameter('a', 'default')

ユーザーセッションオブジェクト(sfUserインスタンス)

// ユーザーの文化を$cultureに設定する
$sf_user->setCulture($culture)

// ユーザーの文化を得る
$sf_user->getCulture()

// ユーザーの属性を得る
$sf_user->getAttribute($name)

// ユーザーのパラメーターを得る
$sf_user->getParameter($name)

アクション上での使用

contextオブジェクト全体(sfContextインスタンス)

// contextオブジェクトを得る
$this->getContext()

// アクション名を得る
$this->getActionName()

// モジュール名を得る
$this->getModuleName()

requestオブジェクト(sfRequestインスタンス)

// requestオブジェクトを得る
$this->getRequest()

// エラーが生じれば真
$request->hasErrors()

// 生じたすべてのエラー内容の配列を得る
$request->getErrors()

// リクエストのメソッド(GETかPOSTか)を得る
$request->getMethod()

// パラメーター'a'の値を得る
$request->getParameter('a')

// 全てのパラメータの配列
$request->getParameterHolder()->getAll()

// URI
$request->getUri()

// タイトル
$request->getTitle()

リクエストのパラメーター

// パラメーター'a'が存在すれば真
$this->hasRequestParameter('a')

// パラメーター'a'の値を得る。得られなければ'default'を返す
$this->getRequestParameter('a', 'default')

ユーザーセッションオブジェクト(sfUserインスタンス)

// ユーザーの文化を$cultureに設定する
$this->getUser()->setCulture($culture)

// ユーザーの文化を得る
$this->getUser()->getCulture()

// ユーザーの属性を得る
$this->getUser()->getAttribute($name)

// ユーザーのパラメーターを得る
$this->getUser()->getParameter($name)

その他の場所での使用

contextオブジェクト全体(sfContextインスタンス)

// アクション名を得る
sfContext::getInstance()->getActionName()

// モジュール名を得る
sfContext::getInstance()->getModuleName()

// モジュールディレクトリを得る
sfContext::getInstance()->getModuleDirectory()

requestオブジェクト(sfRequestインスタンス)

// エラーが生じれば真
sfContext::getInstance()->getRequest()->hasErrors()

// 生じたすべてのエラー内容の配列を得る
sfContext::getInstance()->getRequest()->getErrors()

// リクエストのメソッド(GETかPOSTか)を得る
sfContext::getInstance()->getRequest()->getMethod()

// パラメーター'a'の値を得る
sfContext::getInstance()->getRequest()->getParameter('a')

// URI
sfContext::getInstance()->getRequest()->getUri()

// タイトル
sfContext::getInstance()->getRequest()->getTitle()
6
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
10