Ejemplo n.º 1
0
 protected function connect(core\argument $arg)
 {
     try {
         $sLink = 'mysql:dbname=' . $arg->read('database') . ';host=' . $arg->read('host') . ';charset=UTF8';
         $result = new \PDO($sLink, $arg->read('user'), $arg->read('password'), array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
     } catch (\PDOException $e) {
         $this->throwException(sprintf('Connection failed : %s', $e->getMessage()));
     }
     return $result;
 }
Ejemplo n.º 2
0
 protected function loadFileBase(core\argument $class, $sDirectory = '')
 {
     if ($sInlineDirectory = $this->getArguments()->getLastDirectory()) {
         $sDirectory = $sInlineDirectory;
     }
     if ($sFile = $class->read('file', false)) {
         $class->set('file', core\functions\path\toAbsolute($sFile, $sDirectory));
     }
 }
Ejemplo n.º 3
0
 protected function loadArguments(core\argument $arg = null)
 {
     if ($sArguments = static::ARGUMENTS) {
         if ($this->getDirectory('', false)) {
             $manager = $this->getManager(static::ARGUMENT_MANAGER);
             $this->setArguments($manager->createArguments($this->getFile($sArguments)));
         }
     } else {
         if ($arg and $sArguments = $arg->read('arguments', null, false)) {
             $this->setArguments($sArguments);
             $this->setSettings($this->getArguments(false));
             // TODO : settings will replace arguments
         }
     }
 }
Ejemplo n.º 4
0
 protected function buildModule(core\argument $module)
 {
     return array('dummy' => $module->read('@dummy'), '_alias' => 'module');
 }
Ejemplo n.º 5
0
 protected function loadArguments(core\argument $arg = null)
 {
     if ($arg and $sArguments = $arg->read('arguments', null, false)) {
         $this->setArguments($sArguments);
     }
 }
Ejemplo n.º 6
0
 /**
  * Create an object from an argument using @method buildClass()
  *
  * @param argument $class The argument object containing the classes infos
  *  Ex : array(classes' => array('keyname' => array('name' => 'classname', 'file' => 'filename')))
  * @param* array $aArguments The list of arguments to send to __construct
  *
  * @return mixed The object created
  */
 public function createObject(core\argument $class, array $aArguments = array())
 {
     $result = null;
     if (!($sClass = $class->read('name', false))) {
         // has name ?
         $this->throwException(sprintf('Cannot build object. No "name" defined in class'), array(), 3);
     }
     if (self::includeClass($sClass, $class->read('file', false))) {
         $result = $this->buildClass($sClass, $aArguments);
     }
     //$this->getManager('init')->addStat($sClass);
     return $result;
 }
Ejemplo n.º 7
0
 protected function testRoute(core\argument $alt, $sCurrent, $iKey)
 {
     $sPattern = $alt->read('pattern', false);
     $iResult = 0;
     if (!$sPattern || preg_match($sPattern, $sCurrent)) {
         $iWeight = $alt->read('weight', false);
         $iResult = $iWeight ? $iWeight : $iKey;
     }
     return $iResult;
 }
Ejemplo n.º 8
0
 protected function buildStep(core\argument $step)
 {
     $aResult = array('_alias' => $step->getName());
     switch ($step->getName()) {
         case 'event':
             $aResult['name'] = $step->read('@name');
             $aResult['element'] = $step->read('@element');
             break;
         case 'input':
             $aResult['element'] = $step->read('@element');
             $aResult['value'] = $step->read();
             break;
         case 'watcher':
             $aResult['element'] = $step->read('@element');
             $aResult['delay'] = $step->read('@delay', false);
             foreach ($step->query('property', false) as $property) {
                 $aResult['property'][] = array('name' => $property->read('@name'), 'value' => $property->read());
             }
             $this->loadVariable($step, $aResult);
             break;
         case 'snapshot':
             $aResult['element'] = $step->read('@element');
             $aResult['content'] = $step->read('content', false);
             foreach ($step->query('exclude', false) as $exclude) {
                 $aResult['excludes'][] = array('element' => $exclude->read('@element'));
             }
             break;
         case 'call':
             $aResult['path'] = $step->read('@path');
             $aResult['get'] = $step->read('@method', false) === 'get';
             $this->loadVariable($step, $aResult);
             break;
         case 'query':
             $aResult['value'] = $step->read();
             $aResult['creation'] = $step->read('@creation');
             $aResult['timeshift'] = $step->read('@timeshift', false);
             $aResult['connection'] = $step->read('@connection', false);
             break;
     }
     return $aResult;
 }