Action.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Ui\Component;
  7. use Magento\Framework\View\Element\UiComponent\ContextInterface;
  8. /**
  9. * Class Action
  10. */
  11. class Action extends AbstractComponent
  12. {
  13. const NAME = 'action';
  14. /**
  15. * @var array|\JsonSerializable
  16. */
  17. protected $actions;
  18. /**
  19. * @param ContextInterface $context
  20. * @param array $components
  21. * @param array $data
  22. * @param array|\JsonSerializable $actions
  23. */
  24. public function __construct(
  25. ContextInterface $context,
  26. array $components = [],
  27. array $data = [],
  28. $actions = null
  29. ) {
  30. parent::__construct($context, $components, $data);
  31. $this->actions = $actions;
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. public function prepare()
  37. {
  38. if (!empty($this->actions)) {
  39. $this->setData('config', array_replace_recursive(['actions' => $this->actions], $this->getConfiguration()));
  40. }
  41. parent::prepare();
  42. }
  43. /**
  44. * Get component name
  45. *
  46. * @return string
  47. */
  48. public function getComponentName()
  49. {
  50. return static::NAME;
  51. }
  52. }