示例#1
0
 /**
  *
  */
 public function parse(InfosAbstract $object)
 {
     parent::parse($object);
     $json = array_merge(array("required-modules" => array(), "autoload" => array()), $this->json);
     $json['autoload'] = array_merge(array('files' => array(), 'classmap' => array(), 'psr-0' => array(), 'psr-4' => array()), $json['autoload']);
     /**
      * @var array of array('type'=>'module/plugin','version'=>'','id'=>'','name'=>'')
      */
     foreach ($json['required-modules'] as $name => $version) {
         $object->dependencies[] = array('version' => $version, 'name' => $name);
     }
     // module
     if (isset($json['autoload']['psr-4'])) {
         foreach ($json['autoload']['psr-4'] as $ns => $dir) {
             if (!is_array($dir)) {
                 $dir = array($dir);
             }
             if ($ns == '') {
                 $object->autoloadPsr4Namespaces[0] = $dir;
             } else {
                 $object->autoloadPsr4Namespaces[trim($ns, '\\')] = $dir;
             }
         }
     }
     if (isset($json['autoload']['psr-0'])) {
         foreach ($json['autoload']['psr-0'] as $ns => $dir) {
             if (!is_array($dir)) {
                 $dir = array($dir);
             }
             if ($ns == '') {
                 $object->autoloadPsr0Namespaces[0] = $dir;
             } else {
                 $object->autoloadPsr0Namespaces[trim($ns, '\\')] = $dir;
             }
         }
     }
     if (isset($json['autoload']['classmap'])) {
         $basepath = $this->path;
         foreach ($json['autoload']['classmap'] as $path) {
             $classes = \Jelix\External\ClassMapGenerator::createMap($basepath . $path);
             // remove directory base path
             $classes = array_map(function ($c) use($basepath) {
                 if (strpos($c, $basepath) === 0) {
                     return substr($c, strlen($basepath));
                 }
                 return $c;
             }, $classes);
             $object->autoloadClasses = array_merge($object->autoloadClasses, $classes);
         }
     }
     if (isset($json['autoload']['files'])) {
         $object->autoloaders = $json['autoload']['files'];
     }
     if (isset($json['autoload']['include-path'])) {
         $object->autoloadIncludePath = $json['autoload']['include-path'];
     }
     return $object;
 }
示例#2
0
 /**
  *
  */
 public function parse(InfosAbstract $object)
 {
     parent::parse($object);
     $json = array_merge(array("entrypoints" => array(), "directories" => array()), $this->json);
     $json['directories'] = array_merge(array("config" => "", "var" => "", "log" => "", "www" => "", "temp" => ""), $json['directories']);
     if (is_array($json['entrypoints'])) {
         foreach ($json['entrypoints'] as $ep) {
             $file = $ep['file'];
             if (strpos($file, '.php') === false) {
                 $file .= '.php';
             }
             $object->entrypoints[$file] = array('config' => $ep['config'], 'file' => $file, 'type' => isset($ep['type']) ? $ep['type'] : 'classic');
         }
     }
     $j = $json['directories'];
     $object->configPath = $j['config'];
     $object->logPath = $j['log'];
     $object->varPath = $j['var'];
     $object->wwwPath = $j['www'];
     $object->tempPath = $j['temp'];
     return $object;
 }