New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localizable collection routes not working #1164

Closed
peda opened this Issue Dec 16, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@peda

peda commented Dec 16, 2016

Expected behaviour

I do expect collection routes to be localizable as per documentation

routes.yaml

collections:
  blog:
    en: '/blog/{year}/{month}/{day}/{slug}'
    de: '/neues/{year}/{month}/{day}/{slug}'

Actual behaviour

Only one of the the routes is working

Steps to reproduce

collections:
  blog:
    en: '/blog/{year}/{month}/{day}/{slug}'
    de: '/neues/{year}/{month}/{day}/{slug}'

Server configuration

Statamic version: 2.1.18

Updated from an older Statamic or fresh install: fresh install

Cause

Some methods in AggregateRepository do not expect the parameter $local but it's passed an expected in Repository

Patch

Index: statamic/core/Stache/AggregateRepository.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- statamic/core/Stache/AggregateRepository.php	(revision 2e2ee398c6c420e241a1cff3a9a5488a6dc06972)
+++ statamic/core/Stache/AggregateRepository.php	(revision )
@@ -101,10 +101,10 @@
      *
      * @return Collection
      */
-    public function getUris()
+    public function getUris($locale = null)
     {
-        return $this->repositories->map(function ($repo) {
-            return $repo->getUris();
+        return $this->repositories->map(function ($repo) use (&$locale) {
+            return $repo->getUris($locale);
         });
     }
 
@@ -229,13 +229,13 @@
      * @param string $url
      * @return $this
      */
-    public function setUri($id, $url)
+    public function setUri($id, $url, $locale = null)
     {
         list($repo, $id) = $this->extractKeys($id);
 
         $this->ensureRepo($repo);
 
-        $this->repo($repo)->setUri($id, $url);
+        $this->repo($repo)->setUri($id, $url, $locale);
 
         return $this;
     }

@peda peda changed the title from Localizable collection routes to Localizable collection routes not working Dec 16, 2016

@peda

This comment has been minimized.

peda commented Dec 16, 2016

Please also take a look at my comment #886 as fixing this issue unveils another (at the moment hidden) bug located in Statamic\Stache\Updater::updateLocaleAggregate

@peda

This comment has been minimized.

peda commented Aug 8, 2017

that was fixed as part of #886

@peda peda closed this Aug 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment