示例#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;
 }
示例#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;
 }
示例#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
         }
     }
 }
示例#4
0
 protected function normalizeArgument(core\argument $arg, $bEmpty = false)
 {
     return $arg->asArray($bEmpty);
 }
示例#5
0
 protected function buildModule(core\argument $module)
 {
     return array('dummy' => $module->read('@dummy'), '_alias' => 'module');
 }
示例#6
0
 protected function loadArguments(core\argument $arg = null)
 {
     if ($arg and $sArguments = $arg->read('arguments', null, false)) {
         $this->setArguments($sArguments);
     }
 }
示例#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;
 }
示例#8
0
 public function setOptions(core\argument $arg)
 {
     $this->setNamespace($arg->getNamespace());
     $this->setName($arg->getRoot());
     $this->options = $arg;
 }
示例#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;
 }
示例#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;
 }
示例#11
0
 protected function loadNamespaces(core\argument $namespaces)
 {
     $this->aNamespaces = $namespaces->asArray();
 }
示例#12
0
 protected function normalizeArgument(core\argument $arg, $bEmpty = false)
 {
     if ($bEmpty) {
         $result = $arg->asArray($bEmpty);
     } else {
         $result = $arg->asDOM();
     }
     return $result;
 }
示例#13
0
 protected function setArgument(core\argument $arg)
 {
     $doc = $arg->asDOM();
     return $this->setObject($doc);
 }
示例#14
0
 protected function loadVariable(core\argument $step, array &$aStep)
 {
     if ($var = $step->get('variable', false)) {
         $aStep['variable'][] = array('name' => $var->read('@name'));
     }
 }