]> Raphaƫl G. Git Repositories - packbundle/blobdiff - Package/PathPackage.php
Rename routes config to match new bundle alias
[packbundle] / Package / PathPackage.php
index 8b531361d22b0d7e8dfd4360c486431d43996e05..c202b1931790893fba4a3e6f1b3ad807237cf17f 100644 (file)
@@ -21,21 +21,20 @@ 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,7 +53,7 @@ class PathPackage extends Package {
                }
 
                //Set base url
                }
 
                //Set base url
-               $this->baseUrl = $context->getBaseUrl();
+               $this->baseUrl = $this->context->getBaseUrl();
        }
 
        /**
        }
 
        /**
@@ -69,7 +68,7 @@ class PathPackage extends Package {
         *
         * {@inheritdoc}
         */
         *
         * {@inheritdoc}
         */
-       public function getUrl($path): string {
+       public function getUrl(string $path): string {
                //Match url starting with a bundle name
                if (preg_match('%^@([A-Z][a-zA-Z]*?)(?:Bundle/Resources/public)?/(.*)$%', $path, $matches)) {
                        //Handle empty or without replacement pattern basePath
                //Match url starting with a bundle name
                if (preg_match('%^@([A-Z][a-zA-Z]*?)(?:Bundle/Resources/public)?/(.*)$%', $path, $matches)) {
                        //Handle empty or without replacement pattern basePath