_attached)) { return true; } $options = array_merge( array('break' => false, 'breakOn' => false), $options ); $count = count($this->_attached); for ($i = 0; $i < $count; $i++) { $name = $this->_attached[$i]; if (in_array($name, $this->_disabled)) { continue; } $result = call_user_func_array(array($this->{$name}, $callback), $params); if ( $options['break'] && ($result === $options['breakOn'] || (is_array($options['breakOn']) && in_array($result, $options['breakOn'], true))) ) { return $result; } } return true; } /** * Enables callbacks on a behavior or array of behaviors * * @param mixed $name CamelCased name of the behavior(s) to enable (string or array) * @return void */ public function enable($name) { $this->_disabled = array_diff($this->_disabled, (array)$name); } /** * Disables callbacks on a object or array of objects. Public object methods are still * callable as normal. * * @param mixed $name CamelCased name of the objects(s) to disable (string or array) * @return void */ public function disable($name) { foreach ((array)$name as $object) { if (in_array($object, $this->_attached) && !in_array($object, $this->_disabled)) { $this->_disabled[] = $object; } } } /** * Gets the list of currently-enabled objects, or, the current status of a single objects * * @param string $name Optional. The name of the object to check the status of. If omitted, * returns an array of currently-enabled object * @return mixed If $name is specified, returns the boolean status of the corresponding object. * Otherwise, returns an array of all enabled objects. */ public function enabled($name = null) { if (!empty($name)) { return (in_array($name, $this->_attached) && !in_array($name, $this->_disabled)); } return array_diff($this->_attached, $this->_disabled); } /** * Gets the list of attached behaviors, or, whether the given behavior is attached * * @param string $name Optional. The name of the behavior to check the status of. If omitted, * returns an array of currently-attached behaviors * @return mixed If $name is specified, returns the boolean status of the corresponding behavior. * Otherwise, returns an array of all attached behaviors. */ public function attached($name = null) { if (!empty($name)) { return (in_array($name, $this->_attached)); } return $this->_attached; } }