| @@ 19-75 (lines=57) @@ | ||
| 16 | * @copyright 2017 Smile |
|
| 17 | * @package eXpansion\Bundle\Menu\Services\Factories |
|
| 18 | */ |
|
| 19 | class ItemChatCommandFactory implements ItemFactoryInterface |
|
| 20 | { |
|
| 21 | ||
| 22 | /** @var ChatCommandDataProvider */ |
|
| 23 | protected $chatCommandProvider; |
|
| 24 | ||
| 25 | /** @var AdminGroups */ |
|
| 26 | protected $adminGroups; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * ItemChatCommandFactory constructor. |
|
| 30 | * |
|
| 31 | * @param ChatCommandDataProvider $chatCommandProvider |
|
| 32 | */ |
|
| 33 | public function __construct(AdminGroups $adminGroups, ChatCommandDataProvider $chatCommandProvider) |
|
| 34 | { |
|
| 35 | $this->chatCommandProvider = $chatCommandProvider; |
|
| 36 | $this->adminGroups = $adminGroups; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Check if item factory supports building a certain class. |
|
| 41 | * |
|
| 42 | * @param string $class |
|
| 43 | * |
|
| 44 | * @return boolean |
|
| 45 | */ |
|
| 46 | public function supports($class) |
|
| 47 | { |
|
| 48 | return $class == ChatCommandItem::class; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Creates a new Menu item |
|
| 53 | * |
|
| 54 | * @param string $class Class of the item. |
|
| 55 | * @param string $id Id of the item |
|
| 56 | * @param string $path Path of the item |
|
| 57 | * @param string $label |
|
| 58 | * @param string $permission |
|
| 59 | * @param array $options |
|
| 60 | * |
|
| 61 | * @return ItemInterface |
|
| 62 | */ |
|
| 63 | public function build($class, $id, $path, $label, $permission, $options = []) |
|
| 64 | { |
|
| 65 | return new ChatCommandItem( |
|
| 66 | $this->chatCommandProvider, |
|
| 67 | $options['cmd'], |
|
| 68 | $id, |
|
| 69 | $path, |
|
| 70 | $label, |
|
| 71 | $this->adminGroups, |
|
| 72 | $permission |
|
| 73 | ); |
|
| 74 | } |
|
| 75 | } |
|
| @@ 19-73 (lines=55) @@ | ||
| 16 | * @copyright 2017 Smile |
|
| 17 | * @package eXpansion\Bundle\Menu\Services |
|
| 18 | */ |
|
| 19 | class ItemParentFactory implements ItemFactoryInterface |
|
| 20 | { |
|
| 21 | /** @var ItemBuilder */ |
|
| 22 | protected $itemBuilder; |
|
| 23 | ||
| 24 | /** @var AdminGroups */ |
|
| 25 | protected $adminGroups; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * ItemParentFactory constructor. |
|
| 29 | * |
|
| 30 | * @param ItemBuilder $itemBuilder |
|
| 31 | */ |
|
| 32 | public function __construct(AdminGroups $adminGroups, ItemBuilder $itemBuilder) |
|
| 33 | { |
|
| 34 | $this->itemBuilder = $itemBuilder; |
|
| 35 | $this->adminGroups = $adminGroups; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Check if item factory supports building a certain class. |
|
| 40 | * |
|
| 41 | * @param string $class |
|
| 42 | * |
|
| 43 | * @return boolean |
|
| 44 | */ |
|
| 45 | public function supports($class) |
|
| 46 | { |
|
| 47 | return $class == ParentItem::class; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Creates a new Menu item |
|
| 52 | * |
|
| 53 | * @param string $class Class of the item. |
|
| 54 | * @param string $id Id of the item |
|
| 55 | * @param string $path Path of the item |
|
| 56 | * @param string $label |
|
| 57 | * @param string $permission |
|
| 58 | * @param array $options |
|
| 59 | * |
|
| 60 | * @return ItemInterface |
|
| 61 | */ |
|
| 62 | public function build($class, $id, $path, $label, $permission, $options = []) |
|
| 63 | { |
|
| 64 | return new ParentItem( |
|
| 65 | $this->itemBuilder, |
|
| 66 | $id, |
|
| 67 | $path, |
|
| 68 | $label, |
|
| 69 | $this->adminGroups, |
|
| 70 | $permission |
|
| 71 | ); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||