core = $core; $cleaners = new arrayObject(); try { $this->core->callBehavior('advancedCleanerAdd', $cleaners, $this->core); foreach ($cleaners as $cleaner) { if ($cleaner instanceof advancedCleaner && !isset($this->cleaners[$cleaner->id])) { $this->cleaners[$cleaner->id] = $cleaner; } } } catch (Exception $e) { $core->error->add($e->getMessage()); } } public function get($type = null, $silent = false) { if (null === $type) { return $this->cleaners; } if (isset($this->cleaners[$type])) { return $this->cleaners[$type]; } if ($silent) { return false; } throw new exception(sprintf(__('unknow cleaner type %s'), $type)); } public function set($type, $action, $ns) { if (!isset($this->cleaners[$type])) { throw new exception(sprintf(__('unknow cleaner type %s'), $type)); } if (strtolower($ns) == 'dcadvancedcleaner') { throw new exception(__("dcAdvancedCleaner can't remove itself")); } # BEHAVIOR dcAdvancedCleanerBeforeAction $this->core->callBehavior('dcAdvancedCleanerBeforeAction', $type, $action, $ns); $ret = $this->cleaners[$type]->set($action, $ns); if ($ret === false) { $msg = $this->cleaners[$type]->error($action); throw new Exception($msg ?? __('Unknow error')); } return true; } }