Skip to content

Commit

Permalink
Merge branch 'mathmarques-move-add-method' into 3.x
Browse files Browse the repository at this point in the history
Closes #1634
  • Loading branch information
akrabat committed Nov 29, 2015
2 parents 06675cf + 77aa1d1 commit e269160
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 39 deletions.
19 changes: 19 additions & 0 deletions Slim/Routable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
namespace Slim;

use Closure;
use Interop\Container\ContainerInterface;

/**
Expand Down Expand Up @@ -80,4 +81,22 @@ public function setContainer(ContainerInterface $container)
$this->container = $container;
return $this;
}

/**
* Prepend middleware to the middleware collection
*
* @param mixed $callable The callback routine
*
* @return static
*/
public function add($callable)
{
$callable = $this->resolveCallable($callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}

$this->middleware[] = $callable;
return $this;
}
}
21 changes: 0 additions & 21 deletions Slim/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
namespace Slim;

use Closure;
use Exception;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -85,26 +84,6 @@ public function __construct($methods, $pattern, $callable, $groups = [], $identi
$this->identifier = 'route' . $identifier;
}

/**
* Add middleware
*
* This method prepends new middleware to the route's middleware stack.
*
* @param mixed $callable The callback routine
*
* @return RouteInterface
*/
public function add($callable)
{
$callable = $this->resolveCallable($callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}

$this->middleware[] = $callable;
return $this;
}

/**
* Finalize the route in preparation for dispatching
*/
Expand Down
18 changes: 0 additions & 18 deletions Slim/RouteGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,6 @@ public function __construct($pattern, $callable)
$this->callable = $callable;
}

/**
* Prepend middleware to the group middleware collection
*
* @param mixed $callable The callback routine
*
* @return static
*/
public function add($callable)
{
$callable = $this->resolveCallable($callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}

$this->middleware[] = $callable;
return $this;
}

/**
* Invoke the group to register any Routable objects within it.
*
Expand Down

0 comments on commit e269160

Please sign in to comment.