Exemple #1
0
 public function render(Environment $twig)
 {
     $templates = ArrayCollection::create($this->template)->map(function ($template) {
         return Str::endsWith($template, '.twig') ? $template : $template . '.twig';
     });
     $this->setContent($twig->resolveTemplate($templates->toArray())->render($this->variables->toArray()));
     $this->rendered = true;
 }
Exemple #2
0
 public function test_does_not_endsWith()
 {
     $this->assertFalse(Str::endsWith("blah", "q"));
     $this->assertFalse(Str::endsWith("blah", "qblah"));
     $this->assertFalse(Str::endsWith("blah", "lalh"));
     $this->assertFalse(Str::endsWith("blah", "lahq"));
     $this->assertFalse(Str::endsWith("blah", "BLAH"));
 }
 /** @inheritdoc */
 public static function getValue($section, $key, $default = null, $allowEmpty = false)
 {
     $value = parent::getValue($section, $key, $default, $allowEmpty);
     if (!is_string($value) || !Str::startsWith($value, '%') || !Str::endsWith($value, '%')) {
         return $value;
     }
     $env = substr($value, 1, strlen($value) - 2);
     if (!static::$environments->containsKey($env)) {
         $location = static::$envName . " > " . ($section ? "{$section} > " : "") . "{$key}";
         throw new ConfigException("Config file does not contain the environment: \"{$env}\" requested by {$location}");
     }
     static::$config = static::$environments->get($env);
     $value = static::getValue($section, $key, $default, $allowEmpty);
     static::$config = static::$environments->get(static::$envName);
     return $value;
 }