Beispiel #1
0
 protected function lookupClass($sPath, core\argument $args, $bDebug = true)
 {
     $args->registerToken(self::DIRECTORY_TOKEN);
     $args->registerToken(self::CLASSBASE_TOKEN);
     $result = parent::lookupClass($sPath, $args, $bDebug);
     $args->unRegisterToken(self::DIRECTORY_TOKEN);
     $args->unRegisterToken(self::CLASSBASE_TOKEN);
     return $result;
 }
Beispiel #2
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;
 }
Beispiel #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
         }
     }
 }
Beispiel #4
0
 protected function normalizeArgument(core\argument $arg, $bEmpty = false)
 {
     return $arg->asArray($bEmpty);
 }
Beispiel #5
0
 protected function buildModule(core\argument $module)
 {
     return array('dummy' => $module->read('@dummy'), '_alias' => 'module');
 }
Beispiel #6
0
 protected function loadArguments(core\argument $arg = null)
 {
     if ($arg and $sArguments = $arg->read('arguments', null, false)) {
         $this->setArguments($sArguments);
     }
 }
Beispiel #7
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;
 }
Beispiel #8
0
 public function setOptions(core\argument $arg)
 {
     $this->setNamespace($arg->getNamespace());
     $this->setName($arg->getRoot());
     $this->options = $arg;
 }
Beispiel #9
0
 public function argumentAsDOM(core\argument $arg)
 {
     $result = null;
     $node = $arg->asDOM();
     $doc = $this->createDocument();
     $doc->addElement('window', null, array(), $this->getNamespace('self'));
     $doc->add($node->getx('self:items', $this->getNS(), false));
     //dsp($doc);
     if (!$doc->isEmpty()) {
         $result = $this->getTemplate(static::PHP_TEMPLATE)->parseDocument($doc);
     }
     return $result;
 }
Beispiel #10
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;
 }
Beispiel #11
0
 protected function loadNamespaces(core\argument $namespaces)
 {
     $this->aNamespaces = $namespaces->asArray();
 }
Beispiel #12
0
 protected function normalizeArgument(core\argument $arg, $bEmpty = false)
 {
     if ($bEmpty) {
         $result = $arg->asArray($bEmpty);
     } else {
         $result = $arg->asDOM();
     }
     return $result;
 }
Beispiel #13
0
 protected function setArgument(core\argument $arg)
 {
     $doc = $arg->asDOM();
     return $this->setObject($doc);
 }
Beispiel #14
0
 protected function loadVariable(core\argument $step, array &$aStep)
 {
     if ($var = $step->get('variable', false)) {
         $aStep['variable'][] = array('name' => $var->read('@name'));
     }
 }