Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Bookmark.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Ui\Component;
7 
12 
17 {
18  const NAME = 'bookmark';
19 
24 
28  protected $filterBuilder;
29 
34 
42  public function __construct(
46  array $components = [],
47  array $data = []
48  ) {
49  parent::__construct($context, $components, $data);
50  $this->bookmarkRepository = $bookmarkRepository;
51  $this->bookmarkManagement = $bookmarkManagement;
52  }
53 
59  public function getComponentName()
60  {
61  return static::NAME;
62  }
63 
69  public function prepare()
70  {
71  $namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
72  $config = [];
73  if (!empty($namespace)) {
74  $bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
76  foreach ($bookmarks->getItems() as $bookmark) {
77  if ($bookmark->isCurrent()) {
78  $config['activeIndex'] = $bookmark->getIdentifier();
79  }
80 
81  $config = array_merge_recursive($config, $bookmark->getConfig());
82  }
83  }
84 
85  $this->setData('config', array_replace_recursive($config, $this->getConfiguration()));
86 
87  parent::prepare();
88 
89  $jsConfig = $this->getConfiguration();
90  $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
91  }
92 }
$config
Definition: fraud_order.php:17
$bookmarks
Definition: bookmarks.php:10
__construct(ContextInterface $context, BookmarkRepositoryInterface $bookmarkRepository, BookmarkManagementInterface $bookmarkManagement, array $components=[], array $data=[])
Definition: Bookmark.php:42