Skip to content

Commit

Permalink
extract menu section & change translations
Browse files Browse the repository at this point in the history
  • Loading branch information
bartektw committed May 24, 2021
1 parent db10ffd commit a289c35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
29 changes: 14 additions & 15 deletions src/Menu/AdminMenuListener.php → src/Menu/FraudPreventionMenuBuilder.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,59 @@
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
* another great project.
* You can find more information about us on https://bitbag.shop and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusBlacklistPlugin\Menu;

use Knp\Menu\ItemInterface;
use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent;

final class AdminMenuListener
final class FraudPreventionMenuBuilder
{
public const AUTOMATIC_BLACKLISTING_CONFIGURATION_TYPE_MENU_KEY = 'automatic_blacklisting_configuration';

public const BLACKLISTING_RULE_TYPE_MENU_KEY = 'blacklisting_rule';

public const FRAUD_SUSPICION_TYPE_MENU_KEY = 'fraud_suspicion';

public function addAdminMenuItems(MenuBuilderEvent $event): void
public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
{
$menu = $event->getMenu();
$this->addToCatalogMenu($menu);
}
$menu = $menuBuilderEvent->getMenu();

private function addToCatalogMenu(ItemInterface $menu): void
{
$salesMenu = $menu->getChild('sales');
$rootMenuItem = $menu
->addChild('bitbag_fraud_prevention')
->setLabel('bitbag_sylius_blacklist_plugin.ui.fraud_prevention')
;

$salesMenu
$rootMenuItem
->addChild(self::BLACKLISTING_RULE_TYPE_MENU_KEY, [
'route' => 'bitbag_sylius_blacklist_plugin_admin_blacklisting_rule_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.blacklisting_rules')
->setLabelAttribute('icon', 'hand paper')
;

$salesMenu
$rootMenuItem
->addChild(self::AUTOMATIC_BLACKLISTING_CONFIGURATION_TYPE_MENU_KEY, [
'route' => 'bitbag_sylius_blacklist_plugin_admin_automatic_blacklisting_configuration_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.automatic_blacklisting_configurations')
->setLabelAttribute('icon', 'microchip')
;

$salesMenu
$rootMenuItem
->addChild(self::FRAUD_SUSPICION_TYPE_MENU_KEY, [
'route' => 'bitbag_sylius_blacklist_plugin_admin_fraud_suspicion_index',
])
->setLabel('bitbag_sylius_blacklist_plugin.ui.fraud_suspicions')
->setLabelAttribute('icon', 'exclamation triangle')
;

$salesMenu
$rootMenuItem
->addChild(self::AUTOMATIC_BLACKLISTING_CONFIGURATION_TYPE_MENU_KEY, [
'route' => 'bitbag_sylius_blacklist_plugin_admin_automatic_blacklisting_configuration_index',
])
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/services/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<service id="bitbag.sylius_blacklist_plugin.menu.admin_menu_listener" class="BitBag\SyliusBlacklistPlugin\Menu\AdminMenuListener">
<tag name="kernel.event_listener" event="sylius.menu.admin.main" method="addAdminMenuItems"/>
<service id="bitbag.sylius_blacklist_plugin.menu.admin_menu_listener" class="BitBag\SyliusBlacklistPlugin\Menu\FraudPreventionMenuBuilder">
<tag name="kernel.event_listener" event="sylius.menu.admin.main" method="buildMenu"/>
</service>
<service id="bitbag.sylius_blacklist_plugin.menu.admin_order_show_menu_listener" class="BitBag\SyliusBlacklistPlugin\Menu\AdminOrderShowMenuListener">
<argument type="service" id="bitbag_sylius_blacklist_plugin.repository.fraud_suspicion"/>
Expand Down
7 changes: 4 additions & 3 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bitbag_sylius_blacklist_plugin:
ui:
blacklisting_rules: Manual blacklisting rule
fraud_suspicions: Fraud suspicion
blacklisting_rules: Blacklisting rules
fraud_suspicions: Fraud suspicions
manage_blacklisting_rules: Manage blacklisting rules
manage_fraud_suspicions: Manage fraud suspicions
edit_fraud_suspicion: Edit fraud suspicion
Expand All @@ -18,7 +18,7 @@ bitbag_sylius_blacklist_plugin:
mark_suspicious: Mark suspicious
mark_blacklisted: Mark blacklisted
mark_neutral: Mark neutral
automatic_blacklisting_configurations: Auto-blacklisting config
automatic_blacklisting_configurations: Auto-block rules
configure_automatic_blacklisting_configurations: Configure auto-blacklisitng
new_automatic_blacklisting_configuration: Add new automatic blacklisting configuration
edit_automatic_blacklisting_configuration: Edit automatic blacklisting configuration
Expand All @@ -36,6 +36,7 @@ bitbag_sylius_blacklist_plugin:
status: Status
auto_generated: Auto generated
manually_added: Manually added
fraud_prevention: Fraud prevention
form:
blacklisting_rule:
name: Rule name
Expand Down

0 comments on commit a289c35

Please sign in to comment.