/** * 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; }