Ejemplo n.º 1
0
		/**
		 * @param Mod $mod
		 * @param string $filename
		 */
		public function process(Mod $mod, $filename)
		{
			$file = $mod->getPath() . DIRECTORY_SEPARATOR . $filename;
			if (!is_readable($file))
				throw new Exception('Permision denied');
			
			$xml = simplexml_load_file($file);
			foreach (
				get_object_vars($xml->{"action-group"}->children()) 
				as 
				$name => $actionElement
			) {
				if (!is_array($actionElement))
					$actionElement = array($actionElement);
				
				$cnt = count($actionElement);
				
				foreach ($actionElement as $i => $action) {
					
					if (!is_object($action)) {
						$action = 
							($cnt > 1) 
							? $xml->{"action-group"}->{$name}[$i]
							: $xml->{"action-group"}->{$name};
					}
					
					if (
						$name == 'sql'
						&&
						in_array($mod->getName(), $this->lastInstalled)
					) continue;
					
					$className = ucfirst($name).'Action';
					if (class_exists($className)) {
						Singleton::getInstance($className)->
						setXmlElement($action)->
						setParentAction($this)->
						run();
					}
				}
			}
		}