log = mfLoghandler::singleton(); $this->contract = $contract; if($contract->product) { $this->product = $contract->product; if(is_array($this->product->attributes) && count($this->product->attributes)) { $this->product_attributes = $this->product->attributes; } } $this->loadConfigItems(); if(method_exists($this, "init")) { $this->init(); } } private function loadConfigItems() { $m = []; if(preg_match('/^Contractconfig_Hook_(.+)$/', get_class($this), $m)) { if($m[1]) { $this->config_prefix = strtolower($m[1]); } } else { return false; } foreach($this->contract->configgroups as $configgroup) { foreach($configgroup->items as $item) { if(strpos($item->name, $this->config_prefix) === 0) { $short_name = substr($item->name, strlen($this->config_prefix)+1); //var_dump($short_name); $this->configitems[$short_name] = $item; } } } return true; } public function isResponsible() { if(!$this->contract) return false; if(!$this->product) return false; if(!$this->product_attributes) return false; // only work on contracts with our producttech attributes if(!$this->testMyProductAttributes()) { return false; } return true; } private function testMyProductAttributes() { if(!$this->product_attributes) return false; //var_dump($this->product_attributes);exit; //var_dump($this->required_product_attributes);exit; foreach($this->required_product_attributes as $needed_attribute) { // every needed attribute must exist in product if(!array_key_exists($needed_attribute, $this->product_attributes)) { return false; } } return true; } }