Changes
This commit is contained in:
@@ -6,9 +6,6 @@ services:
|
|||||||
pcm_icon.icon_extension:
|
pcm_icon.icon_extension:
|
||||||
public: true
|
public: true
|
||||||
class: Pcm\IconBundle\Twig\Functions\IconExtension
|
class: Pcm\IconBundle\Twig\Functions\IconExtension
|
||||||
arguments:
|
|
||||||
$directories: []
|
|
||||||
$palletes: []
|
|
||||||
|
|
||||||
Pcm\IconBundle\Twig\Functions\IconExtension:
|
Pcm\IconBundle\Twig\Functions\IconExtension:
|
||||||
public: false
|
public: false
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ class PcmIconExtension extends Extension
|
|||||||
|
|
||||||
$definition = $container->getDefinition('pcm_icon.icon_extension');
|
$definition = $container->getDefinition('pcm_icon.icon_extension');
|
||||||
|
|
||||||
$definition->replaceArgument('$directories', $config['directories']);
|
$definition->addArgument($config['directories']);
|
||||||
$definition->replaceArgument('$palletes', $config['palletes']);
|
$definition->addArgument($config['palletes']);
|
||||||
dump($configs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ final class IconExtension extends AbstractExtension
|
|||||||
'size' => self::DEFAULT_SIZE
|
'size' => self::DEFAULT_SIZE
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private array $directories, private array $palletes) {
|
public function __construct(private array $directories, private array $palletes) {}
|
||||||
dump($this->directories);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
@@ -71,9 +69,9 @@ final class IconExtension extends AbstractExtension
|
|||||||
{
|
{
|
||||||
foreach ($this->directories as $directory) {
|
foreach ($this->directories as $directory) {
|
||||||
$potentialFilepath = sprintf('%s/%s.svg', $directory, $iconName);
|
$potentialFilepath = sprintf('%s/%s.svg', $directory, $iconName);
|
||||||
if (file_exists($potentialFilepath)) {
|
|
||||||
|
if (file_exists($potentialFilepath))
|
||||||
return $potentialFilepath;
|
return $potentialFilepath;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IconNotFound(sprintf('File "%s.svg" not found in %s', $iconName, implode(', ', $this->directories)));
|
throw new IconNotFound(sprintf('File "%s.svg" not found in %s', $iconName, implode(', ', $this->directories)));
|
||||||
@@ -94,7 +92,6 @@ final class IconExtension extends AbstractExtension
|
|||||||
if (!is_string($title) && null !== $title)
|
if (!is_string($title) && null !== $title)
|
||||||
throw new \TypeError('Title must be a string!');
|
throw new \TypeError('Title must be a string!');
|
||||||
|
|
||||||
|
|
||||||
if ('' === $title)
|
if ('' === $title)
|
||||||
throw new \InvalidArgumentException('Title string must not be empty!');
|
throw new \InvalidArgumentException('Title string must not be empty!');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user