]> Raphaƫl G. Git Repositories - packbundle/blobdiff - Package/PathPackage.php
Add facebook source file
[packbundle] / Package / PathPackage.php
index 4746fe913368a2abe81df7591d6ff3e19b468ed6..c53b10fc268c74ef7fc179592db25c2ca2b47709 100644 (file)
 
 namespace Rapsys\PackBundle\Package;
 
 
 namespace Rapsys\PackBundle\Package;
 
+use Rapsys\PackBundle\Context\NullContext;
+
 use Symfony\Component\Asset\Context\ContextInterface;
 use Symfony\Component\Asset\Package;
 use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
 
 use Symfony\Component\Asset\Context\ContextInterface;
 use Symfony\Component\Asset\Package;
 use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
 
-use Rapsys\PackBundle\Context\NullContext;
-
 /**
  * {@inheritdoc}
  */
 class PathPackage extends Package {
 /**
  * {@inheritdoc}
  */
 class PathPackage extends Package {
-       //The base path
-       protected $basePath;
-
-       //The base url
-       protected $baseUrl;
+       /**
+        * The base url
+        */
+       protected string $baseUrl;
 
        /**
         * {@inheritdoc}
         */
 
        /**
         * {@inheritdoc}
         */
-       public function __construct(string $basePath, VersionStrategyInterface $versionStrategy, ContextInterface $context = null) {
+       public function __construct(protected string $basePath, protected VersionStrategyInterface $versionStrategy, protected ?ContextInterface $context = null) {
                //Without context use a null context
                //Without context use a null context
-               $context = $context ?? new NullContext();
+               $this->context = $this->context ?? new NullContext();
 
                //Call parent constructor
 
                //Call parent constructor
-               parent::__construct($versionStrategy, $context);
+               parent::__construct($this->versionStrategy, $this->context);
 
                //Without base path
                if (empty($basePath)) {
 
                //Without base path
                if (empty($basePath)) {
@@ -54,10 +53,12 @@ class PathPackage extends Package {
                }
 
                //Set base url
                }
 
                //Set base url
-               $this->baseUrl = $context->getBaseUrl();
+               $this->baseUrl = $this->context->getBaseUrl();
        }
 
        /**
        }
 
        /**
+        * {@inheritdoc}
+        *
         * Returns an absolute or root-relative public path
         *
         * Transform @BundleBundle to bundle and remove /Resources/public fragment from path
         * Returns an absolute or root-relative public path
         *
         * Transform @BundleBundle to bundle and remove /Resources/public fragment from path
@@ -66,8 +67,6 @@ class PathPackage extends Package {
         * @link https://symfony.com/doc/current/bundles.html#overridding-the-bundle-directory-structure
         * @see vendor/symfony/framework-bundle/Command/AssetsInstallCommand.php +113
         * @see vendor/symfony/framework-bundle/Command/AssetsInstallCommand.php +141
         * @link https://symfony.com/doc/current/bundles.html#overridding-the-bundle-directory-structure
         * @see vendor/symfony/framework-bundle/Command/AssetsInstallCommand.php +113
         * @see vendor/symfony/framework-bundle/Command/AssetsInstallCommand.php +141
-        *
-        * {@inheritdoc}
         */
        public function getUrl(string $path): string {
                //Match url starting with a bundle name
         */
        public function getUrl(string $path): string {
                //Match url starting with a bundle name