]> Raphaƫl G. Git Repositories - packbundle/blobdiff - Controller/MapController.php
Remove container member defined in AbstractController
[packbundle] / Controller / MapController.php
index 034cba1ebf260083327fb446334af7591b9679fa..5de1d8251a56a5a94a8fa8fc413961cb80074c04 100644 (file)
@@ -35,13 +35,6 @@ class MapController extends AbstractController implements ServiceSubscriberInter
         */
        protected string $cache;
 
-       /**
-        * The ContainerInterface instance
-        *
-        * @var ContainerInterface
-        */
-       protected $container;
-
        /**
         * The stream context instance
         */
@@ -55,7 +48,7 @@ class MapController extends AbstractController implements ServiceSubscriberInter
        /**
         * The public path
         */
-       protected string $public;
+       protected string $path;
 
        /**
         * The SluggerUtil instance
@@ -74,12 +67,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 +94,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 +125,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) {
@@ -293,6 +287,9 @@ class MapController extends AbstractController implements ServiceSubscriberInter
                //Set last modified
                $response->setLastModified(\DateTime::createFromFormat('U', strval($mtime)));
 
+               //Disable robot index
+               $response->headers->set('X-Robots-Tag', 'noindex');
+
                //Set as public
                $response->setPublic();
 
@@ -325,7 +322,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) {
@@ -538,6 +535,9 @@ class MapController extends AbstractController implements ServiceSubscriberInter
                //Set last modified
                $response->setLastModified(\DateTime::createFromFormat('U', strval($mtime)));
 
+               //Disable robot index
+               $response->headers->set('X-Robots-Tag', 'noindex');
+
                //Set as public
                $response->setPublic();