-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5460 from magento-tsg-csl3/2.4-develop-pr17
[TSG-CSL3] For 2.4 (pr17)
- Loading branch information
Showing
34 changed files
with
1,356 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/code/Magento/AsynchronousOperations/Model/OperationRepositoryInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\AsynchronousOperations\Model; | ||
|
||
use Magento\AsynchronousOperations\Api\Data\OperationInterface; | ||
|
||
/** | ||
* Repository interface to create operation | ||
*/ | ||
interface OperationRepositoryInterface | ||
{ | ||
/** | ||
* Create operation by topic, parameters and group ID | ||
* | ||
* @param string $topicName | ||
* @param array $entityParams | ||
* format: array( | ||
* '<arg1-name>' => '<arg1-value>', | ||
* '<arg2-name>' => '<arg2-value>', | ||
* ) | ||
* @param string $groupId | ||
* @param int $operationId | ||
* @return OperationInterface | ||
*/ | ||
public function create($topicName, $entityParams, $groupId, $operationId): OperationInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Category; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\UrlInterface; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
/** | ||
* Category Image Service | ||
*/ | ||
class Image | ||
{ | ||
private const ATTRIBUTE_NAME = 'image'; | ||
/** | ||
* @var FileInfo | ||
*/ | ||
private $fileInfo; | ||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* Initialize dependencies. | ||
* | ||
* @param FileInfo $fileInfo | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct( | ||
FileInfo $fileInfo, | ||
StoreManagerInterface $storeManager | ||
) { | ||
$this->fileInfo = $fileInfo; | ||
$this->storeManager = $storeManager; | ||
} | ||
/** | ||
* Resolve category image URL | ||
* | ||
* @param Category $category | ||
* @param string $attributeCode | ||
* @return string | ||
* @throws LocalizedException | ||
*/ | ||
public function getUrl(Category $category, string $attributeCode = self::ATTRIBUTE_NAME): string | ||
{ | ||
$url = ''; | ||
$image = $category->getData($attributeCode); | ||
if ($image) { | ||
if (is_string($image)) { | ||
$store = $this->storeManager->getStore(); | ||
$mediaBaseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA); | ||
if ($this->fileInfo->isBeginsWithMediaDirectoryPath($image)) { | ||
$relativePath = $this->fileInfo->getRelativePathToMediaDirectory($image); | ||
$url = rtrim($mediaBaseUrl, '/') . '/' . ltrim($relativePath, '/'); | ||
} elseif (substr($image, 0, 1) !== '/') { | ||
$url = rtrim($mediaBaseUrl, '/') . '/' . ltrim(FileInfo::ENTITY_MEDIA_PATH, '/') . '/' . $image; | ||
} else { | ||
$url = $image; | ||
} | ||
} else { | ||
throw new LocalizedException( | ||
__('Something went wrong while getting the image url.') | ||
); | ||
} | ||
} | ||
return $url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.