コード例 #1
0
 public function expand()
 {
     $config = new Config([], function ($in) {
         return 'res://' . strtolower(substr($in, 1, -1));
     });
     $config->append('{USER}');
     $this->assertEquals([new ResourcePropertySource('user')], $config->sources());
 }
コード例 #2
0
 /**
  * Entry point method. Receives the following arguments from web.php:
  * 
  * 0. The web root - a directory
  * 1. The application source - either a directory or a layout or scriptlet class name
  * 2. The server profile - any name, really, defaulting to "dev"
  * 3. The script URL - the resolved path, including leading "/"
  *
  * @param  string[] $args
  * @return void
  */
 public static function main(array $args)
 {
     $self = new self($args[0], $args[2]);
     $sources = explode(PATH_SEPARATOR, ltrim($args[1], ':'));
     $source = array_shift($sources);
     $config = new Config([], [$self, 'expand']);
     foreach ($sources as $dir) {
         if (0 === strlen($dir)) {
             // Skip
         } else {
             if ('~' === $dir[0]) {
                 $config->append($self->webroot . substr($dir, 1));
             } else {
                 $config->append($dir);
             }
         }
     }
     $self->layout((new Source($source, $config))->layout())->run($args[3]);
 }