Skip to content

Commit

Permalink
add action to the store grid
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Apr 21, 2017
1 parent ba0e8d4 commit 791a1d4
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions Ui/Component/Stores/Grid/Column/Actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* mc-magento2 Magento Component
*
* @category Ebizmarts
* @package mc-magento2
* @author Ebizmarts Team <info@ebizmarts.com>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 4/5/17 11:19 AM
* @file: Actions.php
*/
namespace Ebizmarts\MailChimp\Ui\Component\Stores\Grid\Column;

use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\UrlInterface;

/**
* Class ProductActions
*/
class Actions extends Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;

/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
$storeId = $this->context->getFilterParam('store_id');

foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['edit'] = [
'href' => $this->urlBuilder->getUrl(
'mailchimp/stores/edit',
['id' => $item['id']]
),
'label' => __('Edit'),
'hidden' => false,
];
}
}

return $dataSource;
}
}

0 comments on commit 791a1d4

Please sign in to comment.