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/cartforge.co/app/code/Amasty/Label/Model/ResourceModel/Mview/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/cartforge.co/app/code/Amasty/Label/Model/ResourceModel/Mview/StateManager.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Product Labels for Magento 2
 */

namespace Amasty\Label\Model\ResourceModel\Mview;

use Exception;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Select;

class StateManager
{
    /**
     * @var ResourceConnection
     */
    private $connection;

    public function __construct(
        ResourceConnection $connection
    ) {
        $this->connection = $connection;
    }

    public function get(string $indexer): array
    {
        $mviewTable = $this->connection->getTableName('mview_state');
        $connection = $this->connection->getConnection();

        return $connection->fetchCol(
            $connection->select()
                ->from($mviewTable)
                ->where('view_id = ?', $indexer)
                ->reset(Select::COLUMNS)
                ->columns('version_id')
                ->limit(1)
        );
    }

    public function isScheduled(string $indexer, string $tableName, int $entityId): bool
    {
        try {
            $clTable = $this->connection->getTableName($tableName);
            $connection = $this->connection->getConnection();
            $version = $this->get($indexer);
            if (empty($version)) {
                return false;
            }

            return (bool)$connection->fetchOne(
                $connection->select()
                    ->from($clTable)
                    ->where('version_id > ?', $version)
                    ->where('entity_id = ?', $entityId)
                    ->limit(1)
                    ->columns(['version_id'])
            );
        } catch (Exception $e) {
            return false;
        }
    }
}

Spamworldpro Mini