LoginSignup
0
0

More than 5 years have passed since last update.

CakePHP2でstatic function内からモデルのプロパティへアクセスする

Last updated at Posted at 2018-07-24

概要

CakePHP2のComponentに実装した静的メソッド内から、モデルのプロパティへアクセスする必要があったのでメモ。
静的メソッド内からは$this->Model->propertyではアクセスできない1 ので、別の方法で対応。

対応方法

public static function foo() {
  $val = ClassRegistry::init('Model')->property;
  ...
}
0
0
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
0
0