|
|
@@ -14,11 +14,12 @@
|
|
|
*/
|
|
|
namespace Cake\Routing;
|
|
|
|
|
|
+use BadMethodCallException;
|
|
|
use Cake\Core\App;
|
|
|
-use Cake\Core\Exception\Exception;
|
|
|
-use Cake\Routing\Router;
|
|
|
use Cake\Routing\Route\Route;
|
|
|
+use Cake\Routing\Router;
|
|
|
use Cake\Utility\Inflector;
|
|
|
+use InvalidArgumentException;
|
|
|
|
|
|
/**
|
|
|
* Provides features for building routes inside scopes.
|
|
|
@@ -310,7 +311,8 @@ class RouteBuilder {
|
|
|
* shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
|
|
|
* custom routing class.
|
|
|
* @return void
|
|
|
- * @throws \Cake\Core\Exception\Exception
|
|
|
+ * @throws \InvalidArgumentException
|
|
|
+ * @throws \BadMethodCallException
|
|
|
*/
|
|
|
public function connect($route, array $defaults = [], $options = []) {
|
|
|
if (empty($options['action'])) {
|
|
|
@@ -332,7 +334,8 @@ class RouteBuilder {
|
|
|
* @param array $defaults Default parameters.
|
|
|
* @param array $options Additional options parameters.
|
|
|
* @return \Cake\Routing\Route\Route
|
|
|
- * @throws \Cake\Core\Exception\Exception when route class or route object is invalid.
|
|
|
+ * @throws \InvalidArgumentException when route class or route object is invalid.
|
|
|
+ * @throws \BadMethodCallException when the route to make conflicts with the current scope
|
|
|
*/
|
|
|
protected function _makeRoute($route, $defaults, $options) {
|
|
|
if (is_string($route)) {
|
|
|
@@ -341,7 +344,7 @@ class RouteBuilder {
|
|
|
$routeClass = App::className($options['routeClass'], 'Routing/Route');
|
|
|
}
|
|
|
if ($routeClass === false) {
|
|
|
- throw new Exception(sprintf('Cannot find route class %s', $options['routeClass']));
|
|
|
+ throw new InvalidArgumentException(sprintf('Cannot find route class %s', $options['routeClass']));
|
|
|
}
|
|
|
unset($options['routeClass']);
|
|
|
|
|
|
@@ -352,7 +355,7 @@ class RouteBuilder {
|
|
|
if (isset($defaults[$param]) && $defaults[$param] !== $val) {
|
|
|
$msg = 'You cannot define routes that conflict with the scope. ' .
|
|
|
'Scope had %s = %s, while route had %s = %s';
|
|
|
- throw new Exception(sprintf(
|
|
|
+ throw new BadMethodCallException(sprintf(
|
|
|
$msg,
|
|
|
$param,
|
|
|
$val,
|
|
|
@@ -370,7 +373,9 @@ class RouteBuilder {
|
|
|
if ($route instanceof Route) {
|
|
|
return $route;
|
|
|
}
|
|
|
- throw new Exception('Route class not found, or route class is not a subclass of Cake\Routing\Route\Route');
|
|
|
+ throw new InvalidArgumentException(
|
|
|
+ 'Route class not found, or route class is not a subclass of Cake\Routing\Route\Route'
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|