Skip to content

Commit

Permalink
[AdminBundle] - Fix MultiDomainAdminTwigExtension::switchedHostIsCurr…
Browse files Browse the repository at this point in the history
…ent() (#1715)

[AdminBundle] Check identical with ====

[AdminBundle] Get rid of old array syntax

[AdminBundle] remove another old array syntax replace with []

[AdminBundle] Add extra line at the end of file

[AdminBundle] Remove even more old array() stuff :-P

[AdminBundle] Extra line before closing tag

[AdminBundle] optimise array_merge with global leading backslash

[AdminBundle] - Tweak docblock, remove unwanted backslash

[MultiDomainBundle] Fix docblocks for method
  • Loading branch information
delboy1978uk authored and sandergo90 committed Mar 28, 2018
1 parent 66d4272 commit 99a3bb5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
41 changes: 24 additions & 17 deletions src/Kunstmaan/AdminBundle/Twig/MultiDomainAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
namespace Kunstmaan\AdminBundle\Twig;

use Kunstmaan\AdminBundle\Helper\DomainConfigurationInterface;
use Twig_Environment;
use Twig_Extension;
use Twig_SimpleFunction;

class MultiDomainAdminTwigExtension extends \Twig_Extension
class MultiDomainAdminTwigExtension extends Twig_Extension
{
/**
* @var DomainConfigurationInterface
Expand All @@ -24,37 +27,35 @@ public function __construct(DomainConfigurationInterface $domainConfiguration)
*/
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('multidomain_widget', array($this, 'renderWidget'), array('needs_environment' => true, 'is_safe' => array('html'))),
new \Twig_SimpleFunction('is_multidomain_site', array($this, 'isMultiDomainSite')),
new \Twig_SimpleFunction('get_switched_host', array($this, 'getSwitchedHost')),
new \Twig_SimpleFunction('switched_host_is_current', array($this, 'switchedHostIsCurrent')),
);
return [
new Twig_SimpleFunction('multidomain_widget', [$this, 'renderWidget'], ['needs_environment' => true, 'is_safe' => ['html']]),
new Twig_SimpleFunction('is_multidomain_site', [$this, 'isMultiDomainSite']),
new Twig_SimpleFunction('get_switched_host', [$this, 'getSwitchedHost']),
new Twig_SimpleFunction('switched_host_is_current', [$this, 'switchedHostIsCurrent']),
];
}

/**
* Render multidomain switcher widget.
*
* @param \Twig_Environment $env
* @param array $locales The locales
* @param Twig_Environment $env
* @param string $route The route
* @param array $parameters The route parameters
*
* @return string
*/
public function renderWidget(\Twig_Environment $env, $route, array $parameters = array())
public function renderWidget(Twig_Environment $env, $route, array $parameters = [])
{
$template = $env->loadTemplate(
"@KunstmaanAdmin/MultiDomainAdminTwigExtension/widget.html.twig"
);

return $template->render(
array_merge(
$parameters,
array(
\array_merge(
$parameters, [
'hosts' => $this->getAdminDomainHosts(),
'route' => $route
)
]
)
);
}
Expand All @@ -70,23 +71,29 @@ public function isMultiDomainSite()
}

/**
* @return string
* @return array|null
*/
public function getSwitchedHost()
{
return $this->domainConfiguration->getHostSwitched();
}

/**
* @return string
* @return bool
*/
public function switchedHostIsCurrent()
{
return $this->domainConfiguration->getHost() == $this->getSwitchedHost()['host'];
$hostInfo = $this->getSwitchedHost();
return $this->domainConfiguration->getHost() === $hostInfo['host'];
}

/**
* @return array
*/
public function getAdminDomainHosts()
{
return $this->domainConfiguration->getHosts();
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ protected function getHostOverride()
}

/**
* @return string|null
* @return array
*/
public function getHostSwitched()
{
Expand Down

0 comments on commit 99a3bb5

Please sign in to comment.