Skip to content

Commit

Permalink
adjust formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 18, 2017
1 parent 8af46a2 commit bb02fb2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 50 deletions.
57 changes: 24 additions & 33 deletions src/Illuminate/Routing/PendingResourceRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

class PendingResourceRegistration
{
/**
* The resource registrar.
*
* @var \Illuminate\Routing\ResourceRegistrar
*/
protected $registrar;

/**
* The resource name.
*
Expand All @@ -21,51 +28,25 @@ class PendingResourceRegistration
/**
* The resource options.
*
* @var string
* @var array
*/
protected $options = [];

/**
* The resource registrar.
*
* @var \Illuminate\Routing\ResourceRegistrar
*/
protected $registrar;

/**
* Create a new pending resource registration instance.
*
* @param \Illuminate\Routing\ResourceRegistrar $registrar
* @return void
*/
public function __construct(ResourceRegistrar $registrar)
{
$this->registrar = $registrar;
}

/**
* Handle the object's destruction.
*
* @return void
*/
public function __destruct()
{
$this->registrar->register($this->name, $this->controller, $this->options);
}

/**
* The name, controller and options to use when ready to register.
*
* @param string $name
* @param string $controller
* @param array $options
* @param array $options
* @return void
*/
public function remember($name, $controller, array $options)
public function __construct(ResourceRegistrar $registrar, $name, $controller, array $options)
{
$this->name = $name;
$this->controller = $controller;
$this->options = $options;
$this->registrar = $registrar;
$this->controller = $controller;
}

/**
Expand Down Expand Up @@ -108,7 +89,7 @@ public function names(array $names)
}

/**
* Set the route name for controller action.
* Set the route name for a controller action.
*
* @param string $method
* @param string $name
Expand All @@ -135,7 +116,7 @@ public function parameters(array $parameters)
}

/**
* Override the route parameter name.
* Override a route parameter's name.
*
* @param string $previous
* @param string $new
Expand All @@ -160,4 +141,14 @@ public function middleware($middleware)

return $this;
}

/**
* Handle the object's destruction.
*
* @return void
*/
public function __destruct()
{
$this->registrar->register($this->name, $this->controller, $this->options);
}
}
16 changes: 0 additions & 16 deletions src/Illuminate/Routing/ResourceRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,6 @@ public function __construct(Router $router)
$this->router = $router;
}

/**
* Create a new PendingResourceRegistration.
*
* @param string $name
* @param string $controller
* @param array $options
* @return \Illuminate\Routing\PendingResourceRegistration
*/
public function registration($name, $controller, array $options = [])
{
$registration = new PendingResourceRegistration($this);
$registration->remember($name, $controller, $options);

return $registration;
}

/**
* Route a resource to a controller.
*
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ public function resource($name, $controller, array $options = [])
$registrar = new ResourceRegistrar($this);
}

return $registrar->registration($name, $controller, $options);
return new PendingResourceRegistration(
$registrar, $name, $controller, $options
);
}

/**
Expand Down

0 comments on commit bb02fb2

Please sign in to comment.