Skip to content

Commit

Permalink
Use setter injection for dynamic params
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Sep 25, 2017
1 parent 944b900 commit cf9de63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions EventListener/SetTagsAdminPageLayoutListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@ class SetTagsAdminPageLayoutListener implements EventSubscriberInterface
/**
* @var bool
*/
protected $isAdminSiteAccess;
protected $isAdminSiteAccess = false;

/**
* Constructor.
*
* @param \Netgen\TagsBundle\Templating\Twig\AdminGlobalVariable $globalVariable
* @param string $pageLayoutTemplate
* @param bool $isAdminSiteAccess
*/
public function __construct(
AdminGlobalVariable $globalVariable,
$pageLayoutTemplate,
$isAdminSiteAccess = false
) {
public function __construct(AdminGlobalVariable $globalVariable, $pageLayoutTemplate)
{
$this->globalVariable = $globalVariable;
$this->pageLayoutTemplate = $pageLayoutTemplate;
$this->isAdminSiteAccess = $isAdminSiteAccess;
}

/**
* Sets if the current siteaccess will be considered as Netgen Admin UI siteaccess.
*
* @param bool $isAdminSiteAccess
*/
public function setIsAdminSiteAccess($isAdminSiteAccess = false)
{
$this->isAdminSiteAccess = (bool)$isAdminSiteAccess;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Resources/config/tags/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ services:
arguments:
- "@eztags.templating.admin_global_variable"
- "%netgen_admin_ui.tags.pagelayout%"
- "$is_admin_ui_siteaccess;netgen_admin_ui$"
# Using siteaccess aware config, so we need the lazy flag
lazy: true
calls:
- [setIsAdminSiteAccess, [$is_admin_ui_siteaccess;netgen_admin_ui$]]
tags:
- { name: kernel.event_subscriber }

0 comments on commit cf9de63

Please sign in to comment.