Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MassEnable.php
Go to the documentation of this file.
1 <?php
7 
11 use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
12 
17 {
23  const ADMIN_RESOURCE = 'Magento_Cms::save';
24 
28  protected $filter;
29 
33  protected $collectionFactory;
34 
40  public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
41  {
42  $this->filter = $filter;
43  $this->collectionFactory = $collectionFactory;
44  parent::__construct($context);
45  }
46 
53  public function execute()
54  {
55  $collection = $this->filter->getCollection($this->collectionFactory->create());
56 
57  foreach ($collection as $item) {
58  $item->setIsActive(true);
59  $item->save();
60  }
61 
62  $this->messageManager->addSuccessMessage(
63  __('A total of %1 record(s) have been enabled.', $collection->getSize())
64  );
65 
67  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
68  return $resultRedirect->setPath('*/*/');
69  }
70 }
__()
Definition: __.php:13
__construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
Definition: MassEnable.php:40