]> Raphaël G. Git Repositories - packbundle/commitdiff
Remove prefix from cache and public path
authorRaphaël Gertz <git@rapsys.eu>
Mon, 3 Oct 2022 02:46:40 +0000 (04:46 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Mon, 3 Oct 2022 02:46:40 +0000 (04:46 +0200)
Controller/ImageController.php
Controller/MapController.php

index 83516532cb5932d4e254f809b7504dcd52642c24..298ee3f66d48cddc5645dd071b4bed322aa8b900 100644 (file)
@@ -50,7 +50,7 @@ class ImageController extends AbstractController implements ServiceSubscriberInt
        /**
         * The public path
         */
-       protected string $public;
+       protected string $path;
 
        /**
         * The SluggerUtil instance
@@ -64,11 +64,12 @@ class ImageController extends AbstractController implements ServiceSubscriberInt
         * @param ImageUtil $image The MapUtil instance
         * @param SluggerUtil $slugger The SluggerUtil instance
         * @param string $cache The cache path
-        * @param string $public The public path
+        * @param string $path The public path
+        * @param string $prefix The prefix
         */
-       function __construct(ContainerInterface $container, ImageUtil $image, SluggerUtil $slugger, string $cache = '../var/cache/image', string $public = './bundles/rapsyspack/image') {
+       function __construct(ContainerInterface $container, ImageUtil $image, SluggerUtil $slugger, string $cache = '../var/cache', string $path = './bundles/rapsyspack', string $prefix = 'image') {
                //Set cache
-               $this->cache = $cache;
+               $this->cache = $cache.'/'.$prefix;
 
                //Set container
                $this->container = $container;
@@ -76,8 +77,8 @@ class ImageController extends AbstractController implements ServiceSubscriberInt
                //Set image
                $this->image = $image;
 
-               //Set public
-               $this->public = $public;
+               //Set path
+               $this->path = $path.'/'.$prefix;
 
                //Set slugger
                $this->slugger = $slugger;
@@ -105,7 +106,7 @@ class ImageController extends AbstractController implements ServiceSubscriberInt
                $hashed = array_reverse(str_split(strval($updated)));
 
                //Set captcha
-               $captcha = $this->public.'/'.$hashed[0].'/'.$hashed[1].'/'.$hashed[2].'/'.$updated.'/'.$equation.'/'.$width.'x'.$height.'.jpeg';
+               $captcha = $this->path.'/'.$hashed[0].'/'.$hashed[1].'/'.$hashed[2].'/'.$updated.'/'.$equation.'/'.$width.'x'.$height.'.jpeg';
 
                //Unshort equation
                $equation = $this->slugger->unshort($equation);
@@ -256,7 +257,7 @@ class ImageController extends AbstractController implements ServiceSubscriberInt
                $hashed = array_reverse(str_split(strval($updated)));
 
                //Set thumb
-               $thumb = $this->public.'/'.$hashed[0].'/'.$hashed[1].'/'.$hashed[2].'/'.$updated.'/'.$path.'/'.$width.'x'.$height.'.jpeg';
+               $thumb = $this->path.'/'.$hashed[0].'/'.$hashed[1].'/'.$hashed[2].'/'.$updated.'/'.$path.'/'.$width.'x'.$height.'.jpeg';
 
                //Unshort path
                $path = $this->slugger->unshort($path);
index 034cba1ebf260083327fb446334af7591b9679fa..730fb7270103aeccb4b96380e7d91a99066c00d8 100644 (file)
@@ -55,7 +55,7 @@ class MapController extends AbstractController implements ServiceSubscriberInter
        /**
         * The public path
         */
-       protected string $public;
+       protected string $path;
 
        /**
         * The SluggerUtil instance
@@ -74,12 +74,13 @@ class MapController extends AbstractController implements ServiceSubscriberInter
         * @param MapUtil $map The MapUtil instance
         * @param SluggerUtil $slugger The SluggerUtil instance
         * @param string $cache The cache path
-        * @param string $public The public path
+        * @param string $path The public path
+#       * @param string $prefix The prefix
         * @param string $url The tile server url
         */
-       function __construct(ContainerInterface $container, MapUtil $map, SluggerUtil $slugger, string $cache = '../var/cache/map', string $public = './bundles/rapsyspack/map', string $url = MapUtil::osm) {
+       function __construct(ContainerInterface $container, MapUtil $map, SluggerUtil $slugger, string $cache = '../var/cache', string $path = './bundles/rapsyspack', string $prefix = 'map', string $url = MapUtil::osm) {
                //Set cache
-               $this->cache = $cache;
+               $this->cache = $cache.'/'.$prefix;
 
                //Set container
                $this->container = $container;
@@ -100,8 +101,8 @@ class MapController extends AbstractController implements ServiceSubscriberInter
                //Set map
                $this->map = $map;
 
-               //Set public
-               $this->public = $public;
+               //Set path
+               $this->path = $path.'/'.$prefix;
 
                //Set slugger
                $this->slugger = $slugger;
@@ -131,7 +132,7 @@ class MapController extends AbstractController implements ServiceSubscriberInter
                }
 
                //Set map
-               $map = $this->public.'/'.$zoom.'/'.$latitude.'/'.$longitude.'/'.$width.'x'.$height.'.jpeg';
+               $map = $this->path.'/'.$zoom.'/'.$latitude.'/'.$longitude.'/'.$width.'x'.$height.'.jpeg';
 
                //Without multi up to date file
                if (!is_file($map) || !($mtime = stat($map)['mtime']) || $mtime < $updated) {
@@ -325,7 +326,7 @@ class MapController extends AbstractController implements ServiceSubscriberInter
                }
 
                //Set multi
-               $map = $this->public.'/'.$zoom.'/'.$latitude.'/'.$longitude.'/'.$coordinate.'/'.$width.'x'.$height.'.jpeg';
+               $map = $this->path.'/'.$zoom.'/'.$latitude.'/'.$longitude.'/'.$coordinate.'/'.$width.'x'.$height.'.jpeg';
 
                //Without multi up to date file
                if (!is_file($map) || !($mtime = stat($map)['mtime']) || $mtime < $updated) {