chg: [Component:Navigation] Breadcrumbs get loaded before rendering to have access to view var
So that it can have access to view variablespull/93/head
parent
aa42e6763a
commit
d2a88b3a18
|
@ -128,7 +128,6 @@ class AppController extends Controller
|
|||
}
|
||||
|
||||
$this->ACL->checkAccess();
|
||||
$this->set('breadcrumb', $this->Navigation->getBreadcrumb());
|
||||
$this->set('ajax', $this->request->is('ajax'));
|
||||
$this->request->getParam('prefix');
|
||||
$this->set('baseurl', Configure::read('App.fullBaseUrl'));
|
||||
|
@ -143,6 +142,11 @@ class AppController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function beforeRender(EventInterface $event)
|
||||
{
|
||||
$this->set('breadcrumb', $this->Navigation->getBreadcrumb());
|
||||
}
|
||||
|
||||
private function authApiUser(): void
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_AUTHORIZATION']) && strlen($_SERVER['HTTP_AUTHORIZATION'])) {
|
||||
|
|
|
@ -5,11 +5,13 @@ class BaseNavigation
|
|||
{
|
||||
protected $bcf;
|
||||
protected $request;
|
||||
protected $viewVars;
|
||||
|
||||
public function __construct($bcf, $request)
|
||||
public function __construct($bcf, $request, $viewVars)
|
||||
{
|
||||
$this->bcf = $bcf;
|
||||
$this->request = $request;
|
||||
$this->viewVars = $viewVars;
|
||||
}
|
||||
|
||||
public function addRoutes() {}
|
||||
|
|
|
@ -42,7 +42,7 @@ class NavigationComponent extends Component
|
|||
$this->request = $config['request'];
|
||||
}
|
||||
|
||||
public function beforeFilter($event)
|
||||
public function beforeRender($event)
|
||||
{
|
||||
$this->fullBreadcrumb = $this->genBreadcrumb();
|
||||
$this->breadcrumb = $this->getBreadcrumb();
|
||||
|
@ -140,7 +140,8 @@ class NavigationComponent extends Component
|
|||
$navigationClassname = str_replace('.php', '', $navigationFile);
|
||||
require_once(APP . 'Controller' . DS . 'Component' . DS . 'Navigation' . DS . $navigationFile);
|
||||
$reflection = new \ReflectionClass("BreadcrumbNavigation\\{$navigationClassname}Navigation");
|
||||
$navigationClasses[$navigationClassname] = $reflection->newInstance($bcf, $request);
|
||||
$viewVars = $this->_registry->getController()->viewBuilder()->getVars();
|
||||
$navigationClasses[$navigationClassname] = $reflection->newInstance($bcf, $request, $viewVars);
|
||||
}
|
||||
return $navigationClasses;
|
||||
}
|
||||
|
@ -249,6 +250,7 @@ class BreadcrumbFactory
|
|||
$routeConfig = $this->addIfNotEmpty($routeConfig, $config, 'icon');
|
||||
$routeConfig = $this->addIfNotEmpty($routeConfig, $config, 'label');
|
||||
$routeConfig = $this->addIfNotEmpty($routeConfig, $config, 'textGetter');
|
||||
$routeConfig = $this->addIfNotEmpty($routeConfig, $config, 'badge');
|
||||
return $routeConfig;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue