Skip to content

Commit

Permalink
Use Composer's runtime API to find the location of FA
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Apr 6, 2022
1 parent 02975ea commit da65e6c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
],
"require": {
"php": ">= 8.1",
"composer-runtime-api": "^2.1",
"fortawesome/font-awesome": "^6.1",
"symfony/dependency-injection": "^6",
"symfony/http-kernel": "^6",
Expand Down
15 changes: 2 additions & 13 deletions src/DependencyInjection/TwigAwesomeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rabus\TwigAwesomeBundle\DependencyInjection;

use Rabus\TwigAwesomeBundle\Exception\RuntimeException;
use Composer\InstalledVersions;
use Rabus\TwigAwesomeBundle\IconLocator;
use Rabus\TwigAwesomeBundle\Twig\FaExtension;
use Rabus\TwigAwesomeBundle\Twig\FaTokenParser;
Expand All @@ -30,17 +30,6 @@ public function load(array $configs, ContainerBuilder $container): void

private function determineFaPath(): string
{
$guessedPaths = [
\dirname(__DIR__, 2).\DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.self::PACKAGE_NAME,
\dirname(__DIR__, 4).\DIRECTORY_SEPARATOR.self::PACKAGE_NAME,
];

foreach ($guessedPaths as $current) {
if (file_exists($current)) {
return $current;
}
}

throw new RuntimeException('Unable to locate FontAwesome.');
return realpath(InstalledVersions::getInstallPath(self::PACKAGE_NAME));
}
}
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace Rabus\TwigAwesomeBundle\Exception;

class InvalidArgumentException extends \InvalidArgumentException
final class InvalidArgumentException extends \InvalidArgumentException
{
}
9 changes: 0 additions & 9 deletions src/Exception/RuntimeException.php

This file was deleted.

0 comments on commit da65e6c

Please sign in to comment.