Skip to content

Commit

Permalink
Refactoting
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiopogliani authored Apr 8, 2022
1 parent 312d366 commit e1284d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Extension/ComponentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

class ComponentExtension extends AbstractExtension
{
private Configuration $options;
private Configuration $configuration;

public function __construct(Configuration $options)
public function __construct(Configuration $configuration)
{
$this->options = $options;
$this->configuration = $configuration;
}

public function getTokenParsers()
{
return [
new ComponentTokenParser($this->options),
new ComponentTokenParser($this->configuration),
new SlotTokenParser(),
];
}
Expand Down
12 changes: 4 additions & 8 deletions src/TokenParser/ComponentTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@

final class ComponentTokenParser extends IncludeTokenParser
{
/**
* @var String Directory for the components files.
*/
private $path;
private Configuration $configuration;

/**
* ComponentTokenParser constructor.
* @param string $tag
* @param string $path
*/
public function __construct(Configuration $options = null)
public function __construct(Configuration $configuration)
{
$this->configuration = $options;
$this->path = $this->configuration->getTemplatesPath();
$this->configuration = $configuration;
}

public function getComponentPath(string $name)
Expand All @@ -33,7 +29,7 @@ public function getComponentPath(string $name)
return $name . '.' . $this->configuration->getTemplatesExtension();
}

return rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name . '.' . $this->configuration->getTemplatesExtension();
return rtrim($this->configuration->getTemplatesPath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name . '.' . $this->configuration->getTemplatesExtension();
}

public function parse(Token $token): Node
Expand Down

0 comments on commit e1284d8

Please sign in to comment.