attach(new $plugin); } return true; } public function attach(SplObserver $observer) { if (!isset($observer)) return false; // Add observer $this->observers[] = $observer; return true; } public function detach(SplObserver $observer) { if (!isset($observer)) return false; // Remove observer $key = array_search($observer, $this->observers, true); if ($key) unset($this->observers[$key]); return true; } public function notify() { // Notify each observer foreach ($this->observers as $value) $value->update($this); return true; } public function activate($name, $location, array $args) { if (!isset($name, $location, $args)) return false; // Parse $location = ($location===0 ? 'before' : 'after'); $action = $name . ":" . $location; // Save vars $this->action = $action; $this->args = $args; // Notify observers $this->notify(); return true; } } ?>