Skip to content

Commit

Permalink
Fix the 'The slug '%slug%' is used in more than one contenttype' noti…
Browse files Browse the repository at this point in the history
…ce. Working on #823.
  • Loading branch information
bobdenotter committed Feb 7, 2014
1 parent 9788150 commit 0f83c75
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions app/src/Bolt/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private function parseConfigYaml($basename, $default = array(), $useDefaultConfi
if (!self::$yamlParser) {
self::$yamlParser = new Yaml\Parser();
}

$filename = $useDefaultConfigPath ? (BOLT_CONFIG_DIR . '/' . $basename) : $basename;

if (is_readable($filename)) {
return self::$yamlParser->parse(file_get_contents($filename) . "\n");
}
Expand Down Expand Up @@ -158,8 +158,8 @@ public function getConfig()
$config['routing'] = $this->parseConfigYaml('routing.yml');
$config['permissions'] = $this->parseConfigYaml('permissions.yml');
$config['extensions'] = array();
// fetch the theme config. requires special treatment due to the path

// fetch the theme config. requires special treatment due to the path
$paths = getPaths($config);
$themeConfigFile = $paths['themepath'] . '/config.yml';
$config['theme'] = $this->parseConfigYaml($themeConfigFile, array(), false);
Expand Down Expand Up @@ -367,23 +367,6 @@ public function checkConfig()
}
}

// Show some helpful warnings if slugs or names are not set correctly.
if ($ct['slug'] == $ct['singular_slug']) {
$error = __(
"The slug and singular_slug for '%contenttype%' are the same (%slug%). Please edit contenttypes.yml, and make them distinct.",
array('%contenttype%' => $key, '%slug%' => $ct['slug'])
);
$this->app['session']->getFlashBag()->set('error', $error);
}

if ($ct['name'] == $ct['singular_name']) {
$error = __(
"The name and singular_name for '%contenttype%' are the same (%name%). Please edit contenttypes.yml, and make them distinct.",
array('%contenttype%' => $key, '%name%' => $ct['name'])
);
$this->app['session']->getFlashBag()->set('error', $error);
}

// Keep a running score of used slugs..
if (!isset($slugs[$ct['slug']])) {
$slugs[$ct['slug']] = 0;
Expand All @@ -392,7 +375,9 @@ public function checkConfig()
if (!isset($slugs[$ct['singular_slug']])) {
$slugs[$ct['singular_slug']] = 0;
}
$slugs[$ct['singular_slug']]++;
if ($ct['singular_slug'] != $ct['slug']) {
$slugs[$ct['singular_slug']]++;
}
}

// Check DB-tables integrity
Expand Down

0 comments on commit 0f83c75

Please sign in to comment.