Skip to content

Commit

Permalink
Merge pull request #2 from magento/2.0-develop
Browse files Browse the repository at this point in the history
Merge changes from origin repo
  • Loading branch information
Hazel Joie Caquicla authored Jul 29, 2020
2 parents 2378b4d + 2a58311 commit 8da2d13
Show file tree
Hide file tree
Showing 147 changed files with 1,190 additions and 535 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

use Magento\AdobeImsApi\Api\ConfigInterface;
use Magento\AdobeStockClientApi\Api\ClientInterface;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace Magento\AdobeStockAdminUi\Controller\Adminhtml\System\Config;

use Magento\AdobeStockClientApi\Api\ClientInterface;
use Magento\AdobeImsApi\Api\ConfigInterface;
use Magento\AdobeStockClientApi\Api\ClientInterface;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
Expand Down
1 change: 0 additions & 1 deletion AdobeStockAsset/Model/AssetRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\IntegrationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Psr\Log\LoggerInterface;
Expand Down
6 changes: 3 additions & 3 deletions AdobeStockAsset/Model/CategoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

namespace Magento\AdobeStockAsset\Model;

use Magento\AdobeStockAssetApi\Model\Category\Command\SaveInterface;
use Magento\AdobeStockAssetApi\Model\Category\Command\LoadByIdInterface;
use Magento\AdobeStockAssetApi\Model\Category\Command\DeleteByIdInterface;
use Magento\AdobeStockAsset\Model\ResourceModel\Category\Collection as CategoryCollection;
use Magento\AdobeStockAsset\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\AdobeStockAssetApi\Api\CategoryRepositoryInterface;
use Magento\AdobeStockAssetApi\Api\Data\CategoryInterface;
use Magento\AdobeStockAssetApi\Api\Data\CategorySearchResultsInterface;
use Magento\AdobeStockAssetApi\Api\Data\CategorySearchResultsInterfaceFactory;
use Magento\AdobeStockAssetApi\Model\Category\Command\DeleteByIdInterface;
use Magento\AdobeStockAssetApi\Model\Category\Command\LoadByIdInterface;
use Magento\AdobeStockAssetApi\Model\Category\Command\SaveInterface;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
Expand Down
3 changes: 1 addition & 2 deletions AdobeStockAsset/Model/GetAssetById.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@

namespace Magento\AdobeStockAsset\Model;

use Magento\AdobeStockAssetApi\Api\GetAssetByIdInterface;
use Magento\AdobeStockAssetApi\Api\GetAssetListInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\Document;
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\AdobeStockAssetApi\Api\GetAssetByIdInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\NotFoundException;

/**
* Service for getting asset by content id
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockAsset/Model/GetAssetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

use Magento\AdobeStockAssetApi\Api\GetAssetListInterface;
use Magento\AdobeStockClientApi\Api\ClientInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Api\Search\SearchCriteriaInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\UrlInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Magento\AdobeStockAsset\Model\ResourceModel\Asset\Command;

use Magento\AdobeStockAssetApi\Model\Asset\Command\DeleteByIdInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\AdobeStockAssetApi\Model\Asset\Command\DeleteByIdInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Magento\AdobeStockAsset\Model\ResourceModel\Category\Command;

use Magento\AdobeStockAssetApi\Model\Category\Command\DeleteByIdInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\AdobeStockAssetApi\Model\Category\Command\DeleteByIdInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down
4 changes: 2 additions & 2 deletions AdobeStockAsset/Model/ResourceModel/Category/Command/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Magento\AdobeStockAsset\Model\ResourceModel\Category\Command;

use Magento\AdobeStockAssetApi\Model\Category\Command\SaveInterface;
use Magento\AdobeStockAssetApi\Api\Data\CategoryInterface;
use Magento\AdobeStockAsset\Model\ResourceModel\Command\InsertIgnore;
use Magento\AdobeStockAssetApi\Api\Data\CategoryInterface;
use Magento\AdobeStockAssetApi\Model\Category\Command\SaveInterface;
use Magento\Framework\Reflection\DataObjectProcessor;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Magento\AdobeStockAsset\Model\ResourceModel\Creator\Command;

use Magento\AdobeStockAssetApi\Model\Creator\Command\DeleteByIdInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\AdobeStockAssetApi\Model\Creator\Command\DeleteByIdInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down
4 changes: 2 additions & 2 deletions AdobeStockAsset/Model/ResourceModel/Creator/Command/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Magento\AdobeStockAsset\Model\ResourceModel\Creator\Command;

use Magento\AdobeStockAssetApi\Model\Creator\Command\SaveInterface;
use Magento\AdobeStockAssetApi\Api\Data\CreatorInterface;
use Magento\AdobeStockAsset\Model\ResourceModel\Command\InsertIgnore;
use Magento\AdobeStockAssetApi\Api\Data\CreatorInterface;
use Magento\AdobeStockAssetApi\Model\Creator\Command\SaveInterface;
use Magento\Framework\Reflection\DataObjectProcessor;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Magento\AdobeStockAsset\Test\Integration\Model;

use Magento\AdobeStockAssetApi\Api\CreatorRepositoryInterface;
use Magento\AdobeStockAssetApi\Api\Data\AssetInterface;
use Magento\AdobeStockAssetApi\Api\Data\AssetSearchResultsInterface;
use Magento\AdobeStockAssetApi\Api\Data\CreatorInterface;
use Magento\AdobeStockAssetApi\Api\Data\CreatorInterfaceFactory;
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockAsset/Test/_files/category_rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
declare(strict_types=1);

use Magento\TestFramework\Helper\Bootstrap;
use Magento\AdobeStockAssetApi\Api\CategoryRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();

Expand Down
2 changes: 1 addition & 1 deletion AdobeStockAsset/Test/_files/creator_rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
declare(strict_types=1);

use Magento\TestFramework\Helper\Bootstrap;
use Magento\AdobeStockAssetApi\Api\CreatorRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();

Expand Down
2 changes: 1 addition & 1 deletion AdobeStockAssetApi/Api/GetAssetListInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace Magento\AdobeStockAssetApi\Api;

use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Api\Search\SearchCriteriaInterface;
use Magento\Framework\Api\Search\SearchResultInterface;

/**
* Service for getting asset list filtered by search criteria
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockClient/Model/LicenseConfirmation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace Magento\AdobeStockClient\Model;

use Magento\AdobeStockClientApi\Api\Data\LicenseConfirmationInterface;
use Magento\AdobeStockClientApi\Api\Data\LicenseConfirmationExtensionInterface;
use Magento\AdobeStockClientApi\Api\Data\LicenseConfirmationInterface;
use Magento\Framework\Model\AbstractExtensibleModel;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Magento\AdobeStockClient\Model;

use AdobeStock\Api\Models\SearchParameters;
use Magento\AdobeStockClient\Model\SearchParameterProviderInterface;
use Magento\Framework\Api\SearchCriteriaInterface;

/**
Expand Down
4 changes: 2 additions & 2 deletions AdobeStockClient/Model/StockFileToDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use AdobeStock\Api\Models\StockFile;
use Exception;
use Magento\Framework\Api\AttributeValue;
use Magento\Framework\Api\Search\DocumentFactory;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\Search\Document;
use Magento\Framework\Api\Search\DocumentFactory;
use Magento\Framework\Exception\IntegrationException;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Phrase;
use Psr\Log\LoggerInterface;

Expand Down
4 changes: 2 additions & 2 deletions AdobeStockClient/Test/Unit/Model/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
namespace Magento\AdobeStockClient\Test\Unit\Model;

use AdobeStock\Api\Models\LicenseEntitlement;
use AdobeStock\Api\Models\LicensePurchaseOptions;
use AdobeStock\Api\Models\LicenseEntitlementQuota;
use AdobeStock\Api\Models\LicensePurchaseOptions;
use AdobeStock\Api\Models\StockFile;
use AdobeStock\Api\Request\License;
use AdobeStock\Api\Response\License as ResponseLicense;
use AdobeStock\Api\Request\LicenseFactory as LicenseRequestFactory;
use AdobeStock\Api\Response\License as ResponseLicense;
use AdobeStock\Api\Response\SearchFiles as SearchFilesResponse;
use Magento\AdobeStockClient\Model\Client;
use Magento\AdobeStockClient\Model\ConnectionWrapper;
Expand Down
6 changes: 3 additions & 3 deletions AdobeStockClient/Test/Unit/Model/ConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Magento\AdobeStockClient\Test\Unit\Model;

use PHPUnit\Framework\TestCase;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\AdobeStockClient\Model\ConnectionFactory;
use AdobeStock\Api\Client\AdobeStock;
use Magento\AdobeStockClient\Model\ConnectionFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\TestCase;

/**
* Test for search parameters provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Magento\AdobeStockClient\Test\Unit\Model;

use AdobeStock\Api\Models\SearchParameters;
use Magento\AdobeStockClient\Model\SearchParametersProviderComposite;
use Magento\AdobeStockClient\Model\SearchParameterProviderInterface;
use Magento\AdobeStockClient\Model\SearchParametersProviderComposite;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockClientApi/Api/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

use Magento\AdobeStockClientApi\Api\Data\LicenseConfirmationInterface;
use Magento\AdobeStockClientApi\Api\Data\UserQuotaInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Api\Search\SearchCriteriaInterface;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\IntegrationException;
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockImage/Model/Extract/Keywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Magento\AdobeStockImage\Model\Extract;

use Magento\MediaGalleryApi\Api\Data\KeywordInterface;
use Magento\Framework\Api\Search\Document;
use Magento\MediaGalleryApi\Api\Data\KeywordInterface;
use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory;

/**
Expand Down
3 changes: 2 additions & 1 deletion AdobeStockImage/Model/Extract/MediaGalleryAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Magento\AdobeStockImage\Model\Extract;

use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\Framework\Api\Search\Document;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;

/**
Expand Down Expand Up @@ -51,6 +51,7 @@ public function convert(Document $document, array $additionalData = []): AssetIn
return $this->assetFactory->create([
'path' => $assetData['path'],
'title' => $assetData['title'],
'description' => $assetData['description'],
'width' => $assetData['width'],
'height' => $assetData['height'],
'size' => $assetData['size'],
Expand Down
2 changes: 1 addition & 1 deletion AdobeStockImage/Model/GetRelatedImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

use Magento\AdobeStockImageApi\Api\GetImageListInterface;
use Magento\AdobeStockImageApi\Api\GetRelatedImagesInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\Document;
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface;

Expand Down
1 change: 0 additions & 1 deletion AdobeStockImage/Model/SaveImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\LocalizedException;
use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface;
use Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface;
use Psr\Log\LoggerInterface;

/**
Expand Down
44 changes: 42 additions & 2 deletions AdobeStockImage/Model/SaveMediaGalleryAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
namespace Magento\AdobeStockImage\Model;

use Magento\AdobeStockImage\Model\Extract\MediaGalleryAsset as DocumentToMediaGalleryAsset;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\Search\Document;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\MediaGalleryApi\Api\SaveAssetsInterface;
use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface;
use Magento\MediaGallerySynchronizationApi\Model\GetContentHashInterface;
use Magento\Framework\Exception\FileSystemException;

/**
* Process save action of the media gallery asset.
Expand All @@ -31,6 +33,11 @@ class SaveMediaGalleryAsset
*/
private $documentToMediaGalleryAsset;

/**
* @var AttributeValueFactory
*/
private $attributeValueFactory;

/**
* @var GetContentHashInterface
*/
Expand All @@ -41,22 +48,33 @@ class SaveMediaGalleryAsset
*/
private $fileSystem;

/**
* @var ExtractMetadataInterface
*/
private $extractMetadata;

/**
* @param SaveAssetsInterface $saveMediaAsset
* @param DocumentToMediaGalleryAsset $documentToMediaGalleryAsset
* @param GetContentHashInterface $getContentHash
* @param Filesystem $fileSystem
* @param ExtractMetadataInterface $extractMetadata
* @param AttributeValueFactory $attributeValueFactory
*/
public function __construct(
SaveAssetsInterface $saveMediaAsset,
DocumentToMediaGalleryAsset $documentToMediaGalleryAsset,
GetContentHashInterface $getContentHash,
Filesystem $fileSystem
Filesystem $fileSystem,
ExtractMetadataInterface $extractMetadata,
AttributeValueFactory $attributeValueFactory
) {
$this->saveMediaAsset = $saveMediaAsset;
$this->documentToMediaGalleryAsset = $documentToMediaGalleryAsset;
$this->getContentHash = $getContentHash;
$this->fileSystem = $fileSystem;
$this->extractMetadata = $extractMetadata;
$this->attributeValueFactory = $attributeValueFactory;
}

/**
Expand All @@ -79,13 +97,35 @@ public function execute(Document $document, string $destinationPath): void
'hash' => $this->hashImageContent($destinationPath)
];

$document = $this->setDescriptionField($document, $destinationPath);
$mediaGalleryAsset = $this->documentToMediaGalleryAsset->convert($document, $additionalData);
$this->saveMediaAsset->execute([$mediaGalleryAsset]);
} catch (\Exception $exception) {
throw new CouldNotSaveException(__('Could not save media gallery asset.'), $exception);
}
}

/**
* Set description from file metadata
*
* @param Document $document
* @param string $destinationPath
*/
private function setDescriptionField(Document $document, string $destinationPath): Document
{
$customAttributes = $document->getCustomAttributes();
$mediaDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::MEDIA);
$metadata = $this->extractMetadata->execute($mediaDirectory->getAbsolutePath($destinationPath));
$attribute = $this->attributeValueFactory->create();

$attribute->setAttributeCode('description');
$attribute->setValue($metadata->getDescription());
$customAttributes['description'] = $attribute;
$document->setCustomAttributes($customAttributes);

return $document;
}

/**
* Calculates saved image file size.
*
Expand Down
Loading

0 comments on commit 8da2d13

Please sign in to comment.