diff --git a/src/Content.php b/src/Content.php index 697d521c05a..bf7bfe00c4d 100644 --- a/src/Content.php +++ b/src/Content.php @@ -9,6 +9,7 @@ use Maid\Maid; use Silex; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Routing\Exception\RouteNotFoundException; class Content implements \ArrayAccess { @@ -536,13 +537,18 @@ public function setTaxonomy($taxonomytype, $slug, $name = '', $sortorder = 0) } // Make the 'key' of the array an absolute link to the taxonomy. - $link = $this->app['url_generator']->generate( - 'taxonomylink', - array( - 'taxonomytype' => $taxonomytype, - 'slug' => $slug, - ) - ); + try { + $link = $this->app['url_generator']->generate( + 'taxonomylink', + array( + 'taxonomytype' => $taxonomytype, + 'slug' => $slug, + ) + ); + } catch (RouteNotFoundException $e) { + // Fallback to unique key (yes, also a broken link) + $link = $taxonomytype . '/' . $slug; + } // Set the 'name', for displaying the pretty name, if there is any. if ($this->app['config']->get('taxonomy/' . $taxonomytype . '/options/' . $slug)) {