@@ -22,20 +22,20 @@ |
||
| 22 | 22 | public string $path, |
| 23 | 23 | ?string $prefix, |
| 24 | 24 | ?Context $context = null, |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | $this->prefix = $prefix ?? \substr($path, \strrpos($path, '/') + 1); |
| 27 | 27 | $this->context = $context; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
| 31 | 31 | { |
| 32 | - $path = \substr($name, \strlen((string) $this->prefix) + 1); |
|
| 33 | - if ($path === '') { |
|
| 32 | + $path = \substr($name, \strlen((string)$this->prefix) + 1); |
|
| 33 | + if ($path === ''){ |
|
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $path = \str_replace('.', DIRECTORY_SEPARATOR, $path); |
| 38 | 38 | |
| 39 | - return $builder->load($this->path . DIRECTORY_SEPARATOR . $path); |
|
| 39 | + return $builder->load($this->path.DIRECTORY_SEPARATOR.$path); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -30,7 +30,8 @@ |
||
| 30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
| 31 | 31 | { |
| 32 | 32 | $path = \substr($name, \strlen((string) $this->prefix) + 1); |
| 33 | - if ($path === '') { |
|
| 33 | + if ($path === '') |
|
| 34 | + { |
|
| 34 | 35 | return null; |
| 35 | 36 | } |
| 36 | 37 | |
@@ -23,29 +23,29 @@ |
||
| 23 | 23 | private string $path, |
| 24 | 24 | private ?string $prefix = null, |
| 25 | 25 | ?Context $context = null, |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | $this->context = $context; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
| 31 | 31 | { |
| 32 | - if ($this->template === null) { |
|
| 32 | + if ($this->template === null){ |
|
| 33 | 33 | $this->template = $builder->load($this->path); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $path = $name; |
| 37 | - if ($this->prefix !== null) { |
|
| 37 | + if ($this->prefix !== null){ |
|
| 38 | 38 | $path = \substr($path, \strlen($this->prefix) + 1); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if ($path === '') { |
|
| 41 | + if ($path === ''){ |
|
| 42 | 42 | return null; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** @var ImportInterface $import */ |
| 46 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
| 46 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import){ |
|
| 47 | 47 | $tpl = $import->resolve($builder, $path); |
| 48 | - if ($tpl !== null) { |
|
| 48 | + if ($tpl !== null){ |
|
| 49 | 49 | return $tpl; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -29,23 +29,28 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function resolve(Builder $builder, string $name): ?Template |
| 31 | 31 | { |
| 32 | - if ($this->template === null) { |
|
| 32 | + if ($this->template === null) |
|
| 33 | + { |
|
| 33 | 34 | $this->template = $builder->load($this->path); |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | $path = $name; |
| 37 | - if ($this->prefix !== null) { |
|
| 38 | + if ($this->prefix !== null) |
|
| 39 | + { |
|
| 38 | 40 | $path = \substr($path, \strlen($this->prefix) + 1); |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - if ($path === '') { |
|
| 43 | + if ($path === '') |
|
| 44 | + { |
|
| 42 | 45 | return null; |
| 43 | 46 | } |
| 44 | 47 | |
| 45 | 48 | /** @var ImportInterface $import */ |
| 46 | - foreach ($this->template->getAttribute(ImportContext::class, []) as $import) { |
|
| 49 | + foreach ($this->template->getAttribute(ImportContext::class, []) as $import) |
|
| 50 | + { |
|
| 47 | 51 | $tpl = $import->resolve($builder, $path); |
| 48 | - if ($tpl !== null) { |
|
| 52 | + if ($tpl !== null) |
|
| 53 | + { |
|
| 49 | 54 | return $tpl; |
| 50 | 55 | } |
| 51 | 56 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct( |
| 26 | 26 | public array $nodes = [], |
| 27 | - ) {} |
|
| 27 | + ){} |
|
| 28 | 28 | |
| 29 | 29 | public function setContext(?Context $context = null): void |
| 30 | 30 | { |
@@ -24,7 +24,8 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct( |
| 26 | 26 | public array $nodes = [], |
| 27 | - ) {} |
|
| 27 | + ) { |
|
| 28 | +} |
|
| 28 | 29 | |
| 29 | 30 | public function setContext(?Context $context = null): void |
| 30 | 31 | { |