Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ services:
class: "%avanzu_admin_theme.extension.class%"
tags:
- { name: twig.extension }
arguments: ['%avanzu_admin_theme.options%', '%kernel.environment%', "@avanzu_admin_theme.admin_router"]
arguments: ['@avanzu_admin_theme.context_helper', '%kernel.environment%', "@avanzu_admin_theme.admin_router"]

avanzu_admin_theme.context_helper:
class: "%avanzu_admin_theme.context_helper.class%"
arguments:
- "%avanzu_admin_theme.options%"
- "@avanzu_admin_theme.admin_router"

Avanzu\AdminThemeBundle\Helper\ContextHelper:
alias: avanzu_admin_theme.context_helper


20 changes: 13 additions & 7 deletions Twig/AvanzuAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@

namespace Avanzu\AdminThemeBundle\Twig;

use Avanzu\AdminThemeBundle\Helper\ContextHelper;
use Avanzu\AdminThemeBundle\Routing\RouteAliasCollection;

class AvanzuAdminExtension extends \Twig_Extension
{
protected $options;
/**
* @var ContextHelper
*/
protected $context;
/**
* @var string
*/
protected $env;
/**
* @var RouteAliasCollection
Expand All @@ -20,14 +27,13 @@ class AvanzuAdminExtension extends \Twig_Extension

/**
* AvanzuAdminExtension constructor.
*
* @param $options
* @param $env
* @param ContextHelper $contextHelper
* @param $env
* @param RouteAliasCollection $aliasRouter
*/
public function __construct($options, $env, RouteAliasCollection $aliasRouter)
public function __construct(ContextHelper $contextHelper, $env, RouteAliasCollection $aliasRouter)
{
$this->options = $options;
$this->context = $contextHelper;
$this->env = $env;
$this->aliasRouter = $aliasRouter;
}
Expand All @@ -43,7 +49,7 @@ public function getFilters()
public function bodyClass($classes = '')
{
$classList = [$classes];
$options = $this->options;
$options = $this->context->getOptions();

if(isset($options['skin'])) $classList[] = $options['skin'];
if(isset($options['fixed_layout']) && true == $options['fixed_layout']) $classList[] = 'fixed';
Expand Down