コード例 #1
0
ファイル: Location.php プロジェクト: SYpanel/SYpanel
 public static function fromDirective(Directive $directive)
 {
     $results = new static();
     foreach ($directive->getChildScope()->getDirectives() as $subDirective) {
         $results[$subDirective->getName()] = $subDirective->getValue();
     }
     return $results;
 }
コード例 #2
0
ファイル: asset_pipeline.php プロジェクト: phpontrax/trax
 private function process_directive($line)
 {
     $directives = array('require ' => new RequireFile($this->manifest_file), 'require_directory' => new RequireDirectory($this->manifest_file), 'require_tree' => new RequireTree($this->manifest_file), 'require_self' => new RequireSelf($this->manifest_file));
     foreach ($directives as $directive_name => $directive) {
         $param = $this->get_directive_param($directive_name, $line);
         if (!is_null($param)) {
             return $directive->process($param);
         }
     }
     $directive = new Directive($this->manifest_file);
     return $directive->process_basic($line);
 }
コード例 #3
0
ファイル: Directives.php プロジェクト: lastguest/yay
 function add(Directive $directive)
 {
     $expectations = $directive->pattern()->expected()->all();
     foreach ($expectations as $expected) {
         if ($v = (string) $expected) {
             $this->raytraceLiteral[$v] = true;
         } else {
             $this->raytraceNonliteral[$expected->type()] = true;
         }
     }
     $this->directives[$directive->pattern()->specificity()][$directive->id()] = $directive;
     krsort($this->directives);
 }
コード例 #4
0
 private static function newDirectiveWithoutScope($nameString, Text $configString)
 {
     $configString->inc();
     list($name, $value) = self::processText($nameString);
     $directive = new Directive($name, $value);
     $comment = self::checkRestOfTheLineForComment($configString);
     if (false !== $comment) {
         $directive->setComment($comment);
     }
     return $directive;
 }
コード例 #5
0
ファイル: Scope.php プロジェクト: SYpanel/SYpanel
 /**
  * Set parent directive for this Scope.
  *
  * Sets parent directive for this Scope and also
  * sets the $parentDirective->setChildScope($this)
  *
  * @param Directive $parentDirective
  * @return $this
  */
 public function setParentDirective(Directive $parentDirective)
 {
     $this->parentDirective = $parentDirective;
     if ($parentDirective->getChildScope() !== $this) {
         $parentDirective->setChildScope($this);
     }
     return $this;
 }
コード例 #6
0
ファイル: Directives.php プロジェクト: assertchris/yay
 function add(Directive $directive)
 {
     $this->directives[$directive->specificity()][] = $directive;
     krsort($this->directives);
 }
コード例 #7
0
ファイル: Parser.php プロジェクト: arjenve/RST
 /**
  * Register a new directive handler
  *
  * @param $directive a directive handler
  */
 protected function registerDirective(Directive $directive)
 {
     $this->directives[$directive->getName()] = $directive;
 }
コード例 #8
0
ファイル: Server.php プロジェクト: SYpanel/SYpanel
 public function __toString()
 {
     $server = Directive::create('server');
     $childScope = Scope::create();
     foreach ($this->directives as $key => $value) {
         $childScope->addDirective(Directive::create($key, $value));
     }
     $server->setChildScope($childScope);
     foreach ($this->locations as $url => $location) {
         if ($location === null || !$location instanceof Location) {
             throw new \RuntimeException(sprintf('expected %s but got %s', Location::class, gettype($location)));
         }
         $directive = Directive::create('location', $url);
         $locationChildScope = Scope::create();
         foreach ($location as $key => $value) {
             if (!is_array($value)) {
                 $locationChildScope->addDirective(Directive::create($key, $value));
                 continue;
             }
             foreach ($value as $item) {
                 $locationChildScope->addDirective(Directive::create($key, $item));
             }
         }
         $directive->setChildScope($locationChildScope);
         $childScope->addDirective($directive);
     }
     return (string) Scope::create()->addDirective($server);
 }
コード例 #9
0
 public function testCreate()
 {
     $config_string = (string) Scope::create()->addDirective(Directive::create('server')->setChildScope(Scope::create()->addDirective(Directive::create('listen', 8080))->addDirective(Directive::create('server_name', 'example.net'))->addDirective(Directive::create('root', 'C:/www/example_net'))->addDirective(Directive::create('location', '^~ /var/', Scope::create()->addDirective(Directive::create('deny', 'all')))->setCommentText('Deny access for location /var/'))))->__toString();
     $this->assertEquals($config_string, @file_get_contents('tests/scope_create_output.conf'));
 }