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/Webkul/PrivateShop/Model/Queue/Config/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Webkul/PrivateShop/Model/Queue/Config/Config.php
<?php
/**
 * Webkul Software
 *
 * @category  Webkul
 * @package   Webkul_PrivateShop
 * @author    Webkul Software Private Limited
 * @copyright Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
namespace Webkul\PrivateShop\Model\Queue\Config;

use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Config\CacheInterface;

class Config extends \Magento\Framework\Config\Data implements \Webkul\PrivateShop\Api\Config\ConfigInterface
{
    /**
     * @var ObjectManagerInterface
     */
    protected $objectManager;
    
    /**
     * @param ObjectManagerInterface $objectManager
     * @param Reader $reader
     * @param CacheInterface $cache
     * @param string $cacheId
     */
    public function __construct(
        ObjectManagerInterface $objectManager,
        Reader $reader,
        CacheInterface $cache,
        $cacheId = 'wk_mq_config'
    ) {
        $this->objectManager = $objectManager;
        
        parent::__construct($reader, $cache, $cacheId);
    }
    
    /**
     * Return the list of a specific property given a path
     *
     * @param  mixed $path
     * @param  string $prop
     * @return array
     */
    protected function getPropertyList($path, $prop = 'name')
    {
        return array_map(function ($item) use ($prop) {
            return $item[$prop];
        }, $this->get($path, []));
    }
    
    /**
     * Function to get item by property
     *
     * @param mixed $path
     * @param mixed $value
     * @param string $prop
     * @return array $item
     */
    protected function getItemByProperty($path, $value, $prop = 'name')
    {
        $items = $this->get($path, []);

        foreach ($items as $item) {
            if ($item[$prop] !== $value) {
                continue;
            }
            
            return $item;
        }
        
        // Throw exception if a value is not found
        throw new \Magento\Framework\Exception\LocalizedException(__(
            'Element with %1 "%1" not found in %1 list',
            $prop,
            $value,
            $path
        ));
    }
    
    /**
     * Return the list of configured brokers
     *
     * @return string[]
     */
    public function getBrokerNames()
    {
        return $this->getPropertyList('brokers');
    }
    
    /**
     * Return an instance of the given broker
     *
     * @param mixed $name
     * @param mixed $queueName
     * @return \Webkul\PrivateShop\Api\BrokerInstance
     */
    public function getBrokerInstance($name, $queueName = null)
    {
        $config = $this->getItemByProperty('brokers', $name);
        
        return $this->objectManager->create(
            $config['implementationInstance'],
            ['queueName' => $queueName]
        );
    }
    
    /**
     * Return the list of configured queues
     *
     * @return string[]
     */
    public function getQueueNames()
    {
        return $this->getPropertyList('queues');
    }
    
    /**
     * Return the queue broker code
     *
     * @param string $name
     * @return string
     */
    public function getQueueBroker($name)
    {
        $config = $this->getItemByProperty('queues', $name);
        
        return $config['broker'];
    }
    
    /**
     * Return an instance of the queue broker
     *
     * @param mixed $name
     * @return \Webkul\PrivateShop\Api\BrokerInstance
     */
    public function getQueueBrokerInstance($name)
    {
        return $this->getBrokerInstance(
            $this->getQueueBroker($name),
            $name
        );
    }
    
    /**
     * Return an instance of the queue consumer
     *
     * @param mixed $name
     * @return \Webkul\PrivateShop\Api\ConsumerInstance
     */
    public function getQueueConsumerInstance($name)
    {
        $config = $this->getItemByProperty('queues', $name);
        
        return $this->objectManager->create(
            $config['consumerInterface']
        );
    }
    
    /**
     * Return an the queue message schema
     *
     * @param mixed $name
     * @return mixed
     */
    public function getQueueMessageSchema($name)
    {
        $config = $this->getItemByProperty('queues', $name);
        
        return $config['messageSchema'];
    }
}

Spamworldpro Mini