/** * Constructor * * If debug is off the component will be disabled and not do any further time tracking * or load the toolbar helper. * * @param ComponentCollection $collection * @param array $settings * @return \ToolbarComponent */ public function __construct(ComponentCollection $collection, $settings = array()) { $settings = array_merge((array) Configure::read('DebugKit'), $settings); $panels = $this->_defaultPanels; if (isset($settings['panels'])) { $panels = $this->_makePanelList($settings['panels']); unset($settings['panels']); } $this->controller = $collection->getController(); parent::__construct($collection, array_merge($this->settings, (array) $settings)); if (!Configure::read('debug') && empty($this->settings['forceEnable'])) { $this->enabled = false; return false; } if ($this->settings['autoRun'] === false && !isset($this->controller->request->query['debug'])) { $this->enabled = false; return false; } $this->controller->getEventManager()->attach($this); DebugMemory::record(__d('debug_kit', 'Component initialization')); $this->cacheKey .= $this->Session->read('Config.userAgent'); if (in_array('DebugKit.History', $panels) || isset($settings['history']) && $settings['history'] !== false) { $this->_createCacheConfig(); } $this->_loadPanels($panels, $settings); return false; }
/** * Dispatch event * * @param string $name Name of the event * @param object $subject the object that this event applies to (usually the object that is generating the event) * @param mixed $data any value you wish to be transported with this event to it can be read by listeners */ public static function dispatchEvent($name, $subject = null, $data = []) { $event = new CakeEvent($name, $subject, $data); if (!$subject) { CakeEventManager::instance()->dispatch($event); } else { $subject->getEventManager()->dispatch($event); } }
/** * Convenience method to dispatch event. * * Creates, dispatches, and returns a new CakeEvent object. * * @see CakeEvent::__construct() * @param string $name Name of the event * @param object $subject the object that this event applies to * @param mixed $data any value you wish to be transported with this event */ public static function dispatchEvent($name, $subject, $data = null) { $event = new CakeEvent($name, $subject, $data); $subject->getEventManager()->dispatch($event); return $event; }
/** * Setup of class. * * Generally helpers are instaciated with new Zikula_AbstractHelper($this), but it * will accept most Zikula classes, and override this method. * * @param object $object Zikula_AbstractBase, Zikula_ServiceManager, Zikula_EventManager, Zikula_AbstractEventHandler, Zikula_Hook_AbstractHandler, or other. * * @return void */ private function _setup($object) { $this->object = $object; if ($object instanceof Zikula_AbstractBase || $object instanceof Zikula_AbstractEventHandler || $object instanceof Zikula_Hook_AbstractHandler || $object instanceof Zikula_AbstractPlugin) { $this->serviceManager = $object->getServiceManager(); $this->eventManager = $object->getEventManager(); } else if ($object instanceof Zikula_ServiceManager) { $this->serviceManager = $object; $this->eventManager = $object->getService('zikula.eventmanager'); } else if ($object instanceof Zikula_EventManager) { $this->eventManager = $object; $this->serviceManager = $object->getServiceManager(); } if ($object instanceof Zikula_AbstractBase) { $this->domain = $object->getDomain(); } }