コード例 #1
0
ファイル: Component.php プロジェクト: ukrcms/core
 /**
  * Attach behavior.
  * Set owner and init behavior
  *
  * <code>
  * public function init(){
  *  $this->image = new \Ub\Helper\Image\Object()
  *  $this->image->owner_field = 'image_data';
  *  $this->attachBehavior('image', $this->image);
  * }
  * </code>
  * @param string $name
  * @param Behavior $behavior
  * @return $this
  */
 public function attachBehavior($name, Behavior $behavior)
 {
     $behavior->setOwner($this);
     $behavior->init();
     $this->behaviors[$name] = $behavior;
     return $this;
 }