Skip to content

Commit

Permalink
Fallback to unique key if generating taxonomy link fails. Fixes bolt#…
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Mar 9, 2015
1 parent 0ec909c commit 57606f0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Maid\Maid;
use Silex;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Routing\Exception\RouteNotFoundException;

class Content implements \ArrayAccess
{
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 57606f0

Please sign in to comment.