Laravel version update
Laravel version update
This commit is contained in:
@@ -2,159 +2,169 @@
|
||||
|
||||
class Manager {
|
||||
|
||||
protected $currentRoute;
|
||||
protected $generator;
|
||||
protected $view;
|
||||
protected $currentRoute;
|
||||
protected $generator;
|
||||
protected $view;
|
||||
|
||||
protected $callbacks = [];
|
||||
protected $viewName;
|
||||
protected $currentRouteManual;
|
||||
protected $callbacks = [];
|
||||
protected $viewName;
|
||||
protected $currentRouteManual;
|
||||
|
||||
public function __construct(CurrentRoute $currentRoute, Generator $generator, View $view)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
$this->currentRoute = $currentRoute;
|
||||
$this->view = $view;
|
||||
}
|
||||
public function __construct(CurrentRoute $currentRoute, Generator $generator, View $view)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
$this->currentRoute = $currentRoute;
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function register($name, $callback)
|
||||
{
|
||||
if (isset($this->callbacks[$name]))
|
||||
throw new Exception("Breadcrumb name \"{$name}\" has already been registered");
|
||||
$this->callbacks[$name] = $callback;
|
||||
}
|
||||
public function register($name, $callback)
|
||||
{
|
||||
if (isset($this->callbacks[$name]))
|
||||
throw new Exception("Breadcrumb name \"{$name}\" has already been registered");
|
||||
$this->callbacks[$name] = $callback;
|
||||
}
|
||||
|
||||
public function exists($name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
try {
|
||||
list($name) = $this->currentRoute->get();
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function exists($name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
try {
|
||||
list($name) = $this->currentRoute->get();
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return isset($this->callbacks[$name]);
|
||||
}
|
||||
return isset($this->callbacks[$name]);
|
||||
}
|
||||
|
||||
public function generate($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
public function generate($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
|
||||
public function generateArray($name, $params = [])
|
||||
{
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
public function generateArray($name, $params = [])
|
||||
{
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
|
||||
public function generateIfExists($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
public function generateIfExists($name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
try {
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
} catch (Exception $e) {
|
||||
return [];
|
||||
}
|
||||
} else {
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
}
|
||||
|
||||
if (!$this->exists($name))
|
||||
return [];
|
||||
if (!$this->exists($name))
|
||||
return [];
|
||||
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
|
||||
public function generateIfExistsArray($name, $params = [])
|
||||
{
|
||||
if (!$this->exists($name))
|
||||
return [];
|
||||
public function generateIfExistsArray($name, $params = [])
|
||||
{
|
||||
if (!$this->exists($name))
|
||||
return [];
|
||||
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
return $this->generator->generate($this->callbacks, $name, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since 3.0.0
|
||||
* @see generateIfExistsArray
|
||||
*/
|
||||
public function generateArrayIfExists()
|
||||
{
|
||||
return call_user_func_array([$this, 'generateIfExistsArray'], func_get_args());
|
||||
}
|
||||
/**
|
||||
* @deprecated Since 3.0.0
|
||||
* @see generateIfExistsArray
|
||||
*/
|
||||
public function generateArrayIfExists()
|
||||
{
|
||||
return call_user_func_array([$this, 'generateIfExistsArray'], func_get_args());
|
||||
}
|
||||
|
||||
public function render($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
public function render($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
|
||||
public function renderArray($name, $params = [])
|
||||
{
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
public function renderArray($name, $params = [])
|
||||
{
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
|
||||
public function renderIfExists($name = null)
|
||||
{
|
||||
if (is_null($name))
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
else
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
public function renderIfExists($name = null)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
try {
|
||||
list($name, $params) = $this->currentRoute->get();
|
||||
} catch (Exception $e) {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
}
|
||||
|
||||
if (!$this->exists($name))
|
||||
return '';
|
||||
if (!$this->exists($name))
|
||||
return '';
|
||||
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
|
||||
public function renderIfExistsArray($name, $params = [])
|
||||
{
|
||||
if (!$this->exists($name))
|
||||
return '';
|
||||
public function renderIfExistsArray($name, $params = [])
|
||||
{
|
||||
if (!$this->exists($name))
|
||||
return '';
|
||||
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
$breadcrumbs = $this->generator->generate($this->callbacks, $name, $params);
|
||||
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
return $this->view->render($this->viewName, $breadcrumbs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since 3.0.0
|
||||
* @see renderIfExistsArray
|
||||
*/
|
||||
public function renderArrayIfExists()
|
||||
{
|
||||
return call_user_func_array([$this, 'renderIfExistsArray'], func_get_args());
|
||||
}
|
||||
/**
|
||||
* @deprecated Since 3.0.0
|
||||
* @see renderIfExistsArray
|
||||
*/
|
||||
public function renderArrayIfExists()
|
||||
{
|
||||
return call_user_func_array([$this, 'renderIfExistsArray'], func_get_args());
|
||||
}
|
||||
|
||||
public function setCurrentRoute($name)
|
||||
{
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
public function setCurrentRoute($name)
|
||||
{
|
||||
$params = array_slice(func_get_args(), 1);
|
||||
|
||||
$this->currentRoute->set($name, $params);
|
||||
}
|
||||
$this->currentRoute->set($name, $params);
|
||||
}
|
||||
|
||||
public function setCurrentRouteArray($name, $params = [])
|
||||
{
|
||||
$this->currentRoute->set($name, $params);
|
||||
}
|
||||
public function setCurrentRouteArray($name, $params = [])
|
||||
{
|
||||
$this->currentRoute->set($name, $params);
|
||||
}
|
||||
|
||||
public function clearCurrentRoute()
|
||||
{
|
||||
$this->currentRoute->clear();
|
||||
}
|
||||
public function clearCurrentRoute()
|
||||
{
|
||||
$this->currentRoute->clear();
|
||||
}
|
||||
|
||||
public function setView($view)
|
||||
{
|
||||
$this->viewName = $view;
|
||||
}
|
||||
public function setView($view)
|
||||
{
|
||||
$this->viewName = $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class ServiceProvider extends BaseServiceProvider {
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app['breadcrumbs'] = $this->app->share(function($app)
|
||||
$this->app->singleton('breadcrumbs', function ($app)
|
||||
{
|
||||
$breadcrumbs = $this->app->make('DaveJamesMiller\Breadcrumbs\Manager');
|
||||
|
||||
|
Reference in New Issue
Block a user