-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Soner Sayakci
committed
Feb 10, 2018
1 parent
ca5d2f4
commit bd69b07
Showing
9 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ function adminer_object() { | |
]); | ||
} | ||
|
||
error_reporting(0); | ||
@ini_set('display_errors', 0); | ||
|
||
include './Adminer.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="adminer.menu_subscriber" class="AdminerForShopware\Subscriber\MenuSubscriber"> | ||
<argument>%shopware.es.enabled%</argument> | ||
<tag name="shopware.event_subscriber"/> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace AdminerForShopware\Subscriber; | ||
|
||
use Enlight\Event\SubscriberInterface; | ||
|
||
/** | ||
* Class MenuSubscriber | ||
* @package AdminerForShopware\Subscriber | ||
*/ | ||
class MenuSubscriber implements SubscriberInterface | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $esEnabled; | ||
|
||
/** | ||
* MenuSubscriber constructor. | ||
* @param bool $esEnabled | ||
*/ | ||
public function __construct($esEnabled) | ||
{ | ||
$this->esEnabled = $esEnabled; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
'Enlight_Controller_Action_PostDispatch_Backend_Index' => 'onPostDispatchBackendIndex' | ||
]; | ||
} | ||
|
||
public function onPostDispatchBackendIndex(\Enlight_Event_EventArgs $args) { | ||
/** @var \Shopware_Controllers_Backend_Index $subject */ | ||
$subject = $args->getSubject(); | ||
|
||
if ($subject->Request()->getActionName() === 'menu') { | ||
$menu = $subject->View()->getAssign('menu'); | ||
|
||
foreach ($menu as &$menuItem) { | ||
foreach ($menuItem['children'] as $key => $children) { | ||
if ($children['controller'] === 'Adminer' && $children['action'] === 'elasticSearch') { | ||
if (!$this->esEnabled) { | ||
unset($menuItem['children'][$key]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$subject->View()->assign('menu', $menu); | ||
} | ||
} | ||
} |