Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
ActionPool Class Reference
Inheritance diagram for ActionPool:
ActionPoolInterface

Public Member Functions

 __construct (Context $context, ItemFactory $itemFactory)
 
 getToolbar ()
 
 add ($key, array $data, UiComponentInterface $component)
 
 remove ($key)
 
 update ($key, array $data)
 
 addHtmlBlock ($type, $name='', array $arguments=[])
 

Data Fields

const ACTIONS_PAGE_TOOLBAR = 'page.actions.toolbar'
 

Protected Member Functions

 createContainer ($key, UiComponentInterface $view)
 

Protected Attributes

 $context
 
 $items
 
 $itemFactory
 
 $toolbarBlock
 

Detailed Description

Class ActionPool

Definition at line 17 of file ActionPool.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Context  $context,
ItemFactory  $itemFactory 
)

Construct

Parameters
Context$context
ItemFactory$itemFactory

Definition at line 56 of file ActionPool.php.

57  {
58  $this->context = $context;
59  $this->itemFactory = $itemFactory;
60  }

Member Function Documentation

◆ add()

add (   $key,
array  $data,
UiComponentInterface  $component 
)

Add button

Parameters
string$key
array$data
UiComponentInterface$component
Returns
void

Implements ActionPoolInterface.

Definition at line 82 of file ActionPool.php.

83  {
84  $data['id'] = isset($data['id']) ? $data['id'] : $key;
85 
86  $toolbar = $this->getToolbar();
87  if ($toolbar !== false) {
88  $this->items[$key] = $this->itemFactory->create();
89  $this->items[$key]->setData($data);
90  $container = $this->createContainer($key, $component);
91  $toolbar->setChild($key, $container);
92  }
93  }
createContainer($key, UiComponentInterface $view)
Definition: ActionPool.php:144

◆ addHtmlBlock()

addHtmlBlock (   $type,
  $name = '',
array  $arguments = [] 
)

Add html block

Parameters
string$type
string$name
array$arguments
Returns
void

Implements ActionPoolInterface.

Definition at line 128 of file ActionPool.php.

129  {
130  $toolbar = $this->getToolbar();
131  $container = $this->context->getPageLayout()->createBlock($type, $name, $arguments);
132  if ($toolbar) {
133  $toolbar->setChild($name, $container);
134  }
135  }
$type
Definition: item.phtml:13
$arguments
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ createContainer()

createContainer (   $key,
UiComponentInterface  $view 
)
protected

Create button container

Parameters
string$key
UiComponentInterface$view
Returns
Container

Definition at line 144 of file ActionPool.php.

145  {
146  $container = $this->context->getPageLayout()->createBlock(
147  \Magento\Ui\Component\Control\Container::class,
148  'container-' . $view->getName() . '-' . $key,
149  [
150  'data' => [
151  'button_item' => $this->items[$key],
152  'context' => $view,
153  ]
154  ]
155  );
156 
157  return $container;
158  }

◆ getToolbar()

getToolbar ( )

Get toolbar block

Returns
bool|BlockInterface

Implements ActionPoolInterface.

Definition at line 67 of file ActionPool.php.

68  {
69  return $this->context->getPageLayout()
70  ? $this->context->getPageLayout()->getBlock(static::ACTIONS_PAGE_TOOLBAR)
71  : false;
72  }

◆ remove()

remove (   $key)

Remove button

Parameters
string$key
Returns
void

Implements ActionPoolInterface.

Definition at line 101 of file ActionPool.php.

102  {
103  unset($this->items[$key]);
104  }

◆ update()

update (   $key,
array  $data 
)

Update button

Parameters
string$key
array$data
Returns
void

Implements ActionPoolInterface.

Definition at line 113 of file ActionPool.php.

114  {
115  if (isset($this->items[$key])) {
116  $this->items[$key]->setData($data);
117  }
118  }

Field Documentation

◆ $context

$context
protected

Definition at line 29 of file ActionPool.php.

◆ $itemFactory

$itemFactory
protected

Definition at line 43 of file ActionPool.php.

◆ $items

$items
protected

Definition at line 36 of file ActionPool.php.

◆ $toolbarBlock

$toolbarBlock
protected

Definition at line 48 of file ActionPool.php.

◆ ACTIONS_PAGE_TOOLBAR

const ACTIONS_PAGE_TOOLBAR = 'page.actions.toolbar'

Actions toolbar block name

Definition at line 22 of file ActionPool.php.


The documentation for this class was generated from the following file: