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/vendor/magento/module-adobe-stock-client/Model/Client/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-adobe-stock-client/Model/Client/Files.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\AdobeStockClient\Model\Client;

use AdobeStock\Api\Request\Files as FilesRequest;
use AdobeStock\Api\Response\Files as FilesResponse;
use Magento\AdobeImsApi\Api\ConfigInterface as ImsConfig;
use Magento\AdobeImsApi\Api\GetAccessTokenInterface;
use Magento\AdobeStockClient\Model\ConnectionFactory;
use Magento\AdobeStockClient\Model\FilesRequestFactory;
use Magento\AdobeStockClientApi\Api\Client\FilesInterface;
use Magento\AdobeStockClientApi\Api\ConfigInterface as ClientConfig;
use Magento\Framework\Exception\IntegrationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Locale\ResolverInterface as LocaleResolver;
use Psr\Log\LoggerInterface;

/**
 * Used for retrieving files information from Adobe Stock API
 */
class Files implements FilesInterface
{
    /**
     * @var ImsConfig
     */
    private $imsConfig;

    /**
     * @var ClientConfig
     */
    private $clientConfig;

    /**
     * @var LocaleResolver
     */
    private $localeResolver;

    /**
     * @var GetAccessTokenInterface
     */
    private $getAccessToken;

    /**
     * @var ConnectionFactory
     */
    private $connectionFactory;

    /**
     * @var FilesRequestFactory
     */
    private $requestFilesFactory;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * Files constructor.
     *
     * @param ImsConfig $imsConfig
     * @param ClientConfig $clientConfig
     * @param LocaleResolver $localeResolver
     * @param GetAccessTokenInterface $getAccessToken
     * @param ConnectionFactory $connectionFactory
     * @param FilesRequestFactory $requestFilesFactory
     * @param LoggerInterface $logger
     */
    public function __construct(
        ImsConfig $imsConfig,
        ClientConfig $clientConfig,
        LocaleResolver $localeResolver,
        GetAccessTokenInterface $getAccessToken,
        ConnectionFactory $connectionFactory,
        FilesRequestFactory $requestFilesFactory,
        LoggerInterface $logger
    ) {
        $this->imsConfig = $imsConfig;
        $this->clientConfig = $clientConfig;
        $this->localeResolver = $localeResolver;
        $this->getAccessToken = $getAccessToken;
        $this->connectionFactory = $connectionFactory;
        $this->requestFilesFactory = $requestFilesFactory;
        $this->logger = $logger;
    }

    /**
     * @inheritdoc
     */
    public function execute(array $ids, array $columns, string $locale = null): array
    {
        if (empty($ids)) {
            throw new IntegrationException(__('Files ids can not be empty.'));
        }

        $locale = $locale ?? $this->localeResolver->getLocale();
        $client = $this->connectionFactory->create(
            $this->imsConfig->getApiKey(),
            $this->clientConfig->getProductName(),
            $this->clientConfig->getTargetEnvironment()
        );

        $requestFiles = $this->requestFilesFactory->create();
        $requestFiles->setIds($ids)
            ->setLocale($locale)
            ->setResultColumns($columns);

        try {
            $response = $client->getFiles($requestFiles, $this->getAccessToken->execute());
        } catch (\Exception $exception) {
            $this->logger->error($exception);
            throw new LocalizedException(__('Could not retrieve files information.'), $exception);
        }

        return array_map(
            function ($file) {
                return (array) $file;
            },
            $response->getFiles()
        );
    }
}

Spamworldpro Mini