Skip to content

Commit

Permalink
reformat source
Browse files Browse the repository at this point in the history
  • Loading branch information
dangscaleflex committed Feb 19, 2024
1 parent 101303d commit f4a4b77
Show file tree
Hide file tree
Showing 37 changed files with 292 additions and 238 deletions.
5 changes: 3 additions & 2 deletions Block/Adminhtml/Firerobot.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class Firerobot extends Template
*/
public function __construct(
Template\Context $context,
FilerobotConfig $fileRobotConfig
) {
FilerobotConfig $fileRobotConfig
)
{
parent::__construct($context);
$this->fileRobotConfig = $fileRobotConfig;
}
Expand Down
15 changes: 8 additions & 7 deletions Block/Adminhtml/Product/Helper/Form/Gallery/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ class Content extends \Magento\Backend\Block\Widget
* @param JsonHelper|null $jsonHelper
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
FileRobotConfig $fileRobotConfig,
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null,
Database $fileStorageDatabase = null,
?JsonHelper $jsonHelper = null
) {
FileRobotConfig $fileRobotConfig,
ImageUploadConfigDataProvider $imageUploadConfigDataProvider = null,
Database $fileStorageDatabase = null,
?JsonHelper $jsonHelper = null
)
{
$this->fileRobotConfig = $fileRobotConfig;
$this->_jsonEncoder = $jsonEncoder;
$this->_mediaConfig = $mediaConfig;
Expand Down
3 changes: 2 additions & 1 deletion Block/System/Config/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function __construct(
Context $context,
FilerobotConfig $fileRobotConfig,
array $data = []
) {
)
{
parent::__construct($context, $data);
$this->fileRobotConfig = $fileRobotConfig;
}
Expand Down
14 changes: 7 additions & 7 deletions Helper/Filerobot.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class Filerobot
* @param ProductImageHelper $imageHelper
*/
public function __construct(
ProductRepositoryInterface $productRepository,
FilerobotConfig $filerobotConfig,
ProductImageHelper $imageHelper
ProductRepositoryInterface $productRepository,
FilerobotConfig $filerobotConfig,
ProductImageHelper $imageHelper
)
{
$this->productRepositoty = $productRepository;
Expand Down Expand Up @@ -64,11 +64,11 @@ public function getProductImageById($productId, string $imageType = 'image')
*/
public function buildImageBySize($url, $width, $height)
{
$url = parse_url($url);
$url = parse_url($url);
parse_str($url['query'], $query);
$query['width'] = $width;
$query['width'] = $width;
$query['height'] = $height;
$url['query'] = http_build_query($query);
return $url['scheme'].'://'.$url['host'].$url['path'].'?'.$url['query'];
$url['query'] = http_build_query($query);
return $url['scheme'] . '://' . $url['host'] . $url['path'] . '?' . $url['query'];
}
}
3 changes: 2 additions & 1 deletion Model/FilerobotConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class FilerobotConfig
*/
public function __construct(
ScopeConfigInterface $scopeConfig
) {
)
{
$this->scopeConfig = $scopeConfig;
}

Expand Down
3 changes: 2 additions & 1 deletion Model/Product/Gallery/CreateHandlerOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public function __construct(
\Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb,
FilerobotConfig $fileRobotConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager = null
) {
)
{
$this->metadata = $metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
$this->attributeRepository = $attributeRepository;
$this->resourceModel = $resourceModel;
Expand Down
3 changes: 2 additions & 1 deletion Model/Product/Gallery/UpdateHandlerOverride.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function __construct(
Database $fileStorageDb,
StoreManagerInterface $storeManager = null,
?AttributeValue $attributeValue = null
) {
)
{
parent::__construct(
$metadataPool,
$attributeRepository,
Expand Down
5 changes: 3 additions & 2 deletions Model/Wysiwyg/Filerobot.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class Filerobot
*/
public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepo,
FilerobotConfig $fileRobotConfig
) {
FilerobotConfig $fileRobotConfig
)
{
$this->fileRobotConfig = $fileRobotConfig;
$this->assetRepo = $assetRepo;
}
Expand Down
3 changes: 2 additions & 1 deletion Observer/ChangeTemplateObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class ChangeTemplateObserver implements ObserverInterface

public function __construct(
FilerobotConfig $fileRobotConfig
) {
)
{
$this->fileRobotConfig = $fileRobotConfig;
}

Expand Down
19 changes: 10 additions & 9 deletions Observer/ConfigChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
class ConfigChange implements ObserverInterface
{

/** @var RequestInterface */
/** @var RequestInterface */
protected $request;

/** @var WriterInterface */
/** @var WriterInterface */
protected $writer;

/** @var \Magento\Framework\HTTP\Client\Curl $curl */
protected $curl;

public function __construct(
RequestInterface $request,
WriterInterface $writer,
RequestInterface $request,
WriterInterface $writer,
\Magento\Framework\HTTP\Client\Curl $curl
) {
$this->curl = $curl;
$this->writer = $writer;
)
{
$this->curl = $curl;
$this->writer = $writer;
$this->request = $request;
}

Expand All @@ -35,8 +36,8 @@ public function execute(EventObserver $observer)
$params = $this->request->getParams('groups');
$fields = $params['groups']['general']['fields'];

$token = $fields['token']['value'];
$templateId = $fields['template_id']['value'];
$token = $fields['token']['value'];
$templateId = $fields['template_id']['value'];

$status = $this->verifySetting($token, $templateId);

Expand Down
35 changes: 18 additions & 17 deletions Override/ImageResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,20 @@ class ImageResize extends ParentImageResize
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
State $appState,
MediaConfig $imageConfig,
ProductImage $productImage,
ImageFactory $imageFactory,
ParamsBuilder $paramsBuilder,
ViewConfig $viewConfig,
AssertImageFactory $assertImageFactory,
State $appState,
MediaConfig $imageConfig,
ProductImage $productImage,
ImageFactory $imageFactory,
ParamsBuilder $paramsBuilder,
ViewConfig $viewConfig,
AssertImageFactory $assertImageFactory,
ThemeCustomizationConfig $themeCustomizationConfig,
ThemeCollection $themeCollection,
Filesystem $filesystem,
FileStorageDatabase $fileStorageDatabase = null,
StoreManagerInterface $storeManager = null
) {
ThemeCollection $themeCollection,
Filesystem $filesystem,
FileStorageDatabase $fileStorageDatabase = null,
StoreManagerInterface $storeManager = null
)
{
$this->appState = $appState;
$this->imageConfig = $imageConfig;
$this->productImage = $productImage;
Expand Down Expand Up @@ -270,7 +271,7 @@ private function getViewImages(array $themes): array
$images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE);
foreach ($images as $imageId => $imageData) {
foreach ($stores as $store) {
$data = $this->paramsBuilder->build($imageData, (int) $store->getId());
$data = $this->paramsBuilder->build($imageData, (int)$store->getId());
$uniqIndex = $this->getUniqueImageIndex($data);
$data['id'] = $imageId;
$viewImages[$uniqIndex] = $data;
Expand All @@ -281,7 +282,6 @@ private function getViewImages(array $themes): array
}



/**
* Get unique image index.
*
Expand Down Expand Up @@ -361,12 +361,13 @@ private function resize(array $imageParams, string $originalImagePath, string $o
* @param string $mediaStorageFilename
*/
private function generateResizedImage(
array $imageParams,
array $imageParams,
string $originalImagePath,
string $imageAssetPath,
bool $usingDbAsStorage,
bool $usingDbAsStorage,
string $mediaStorageFilename
) {
)
{
$image = $this->makeImage($originalImagePath, $imageParams);

if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
Expand Down
21 changes: 11 additions & 10 deletions Plugin/AddImageToGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@

class AddImageToGallery
{
/** @var FilerobotConfig */
/** @var FilerobotConfig */
protected $fileRobotConfig;

/** @var ProductRepositoryInterface */
/** @var ProductRepositoryInterface */
protected $productRepository;

/** @var Image */
/** @var Image */
protected $imageHelper;

/** @var Filerobot */
/** @var Filerobot */
protected $filerobotHelper;

/**
* @param FilerobotConfig $fileRobotConfig
*/
public function __construct(
FilerobotConfig $fileRobotConfig,
FilerobotConfig $fileRobotConfig,
ProductRepositoryInterface $productRepository,
Image $imageHelper,
Filerobot $filerobotHelper
) {
Image $imageHelper,
Filerobot $filerobotHelper
)
{
$this->fileRobotConfig = $fileRobotConfig;
$this->productRepository = $productRepository;
$this->imageHelper = $imageHelper;
Expand All @@ -43,7 +44,7 @@ public function afterGetGalleryImages(Gallery $gallery, $images)
if ($this->fileRobotConfig->isFilerobot($image->getData('file'))) {
$url = $image->getData('file');
$entityId = $image->getData('entity_id') ? $image->getData('entity_id') : $image->getData('row_id');
$product = $this->productRepository->getById($entityId);
$product = $this->productRepository->getById($entityId);
if ($product) {
$thumbImageSize = $this->imageHelper->init($product, 'product_thumbnail_image');
$baseImageSize = $this->imageHelper->init($product, 'product_base_image');
Expand All @@ -53,7 +54,7 @@ public function afterGetGalleryImages(Gallery $gallery, $images)

$image->setData('url', $url);
$image->setData('small_image_url', $thumbnailUrl);
$image->setData('medium_image_url',$url);
$image->setData('medium_image_url', $url);
$image->setData('large_image_url', $url);
}
}
Expand Down
13 changes: 7 additions & 6 deletions Plugin/AfterGetImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
class AfterGetImage
{

/** @var Image */
/** @var Image */
protected $imageHelper;

/** @var FilerobotConfig */
/** @var FilerobotConfig */
protected FilerobotConfig $fileRobotConfig;

/** @var Filerobot */
/** @var Filerobot */
protected $filerobotHelper;


Expand All @@ -27,9 +27,10 @@ class AfterGetImage
*/
public function __construct(
FilerobotConfig $fileRobotConfig,
Image $imageHelper,
Filerobot $filerobotHelper
) {
Image $imageHelper,
Filerobot $filerobotHelper
)
{
$this->imageHelper = $imageHelper;
$this->fileRobotConfig = $fileRobotConfig;
$this->filerobotHelper = $filerobotHelper;
Expand Down
3 changes: 2 additions & 1 deletion Plugin/AfterGetImageUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class AfterGetImageUrl
*/
public function __construct(
FilerobotConfig $fileRobotConfig
) {
)
{
$this->fileRobotConfig = $fileRobotConfig;
}

Expand Down
19 changes: 10 additions & 9 deletions Plugin/Checkout/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

class Image
{
/** @var ProductRepositoryInterface */
/** @var ProductRepositoryInterface */
protected ProductRepositoryInterface $productRepository;

/** @var FilerobotConfig */
/** @var FilerobotConfig */
protected FilerobotConfig $fileRobotConfig;

/** @var \Magento\Catalog\Helper\Image */
protected $imageHelper;

/** @var Filerobot */
/** @var Filerobot */
protected $filerobotHelper;

/**
Expand All @@ -29,11 +29,12 @@ class Image
*/
public function __construct(
ProductRepositoryInterface $productRepository,
FilerobotConfig $fileRobotConfig,
ImageHelper $imageHelper,
Filerobot $filerobotHelper
FilerobotConfig $fileRobotConfig,
ImageHelper $imageHelper,
Filerobot $filerobotHelper

) {
)
{
$this->fileRobotConfig = $fileRobotConfig;
$this->productRepository = $productRepository;
$this->imageHelper = $imageHelper;
Expand All @@ -55,8 +56,8 @@ public function afterGetImage($item, $result)
$images = $product->getMediaAttributeValues();
if (!empty($images) && $images['thumbnail'] && $this->fileRobotConfig->isFilerobot($images['thumbnail'])) {
$result->setImageUrl($this->filerobotHelper->buildImageBySize($images['thumbnail'],
$thumbImageSize->getWidth(),
$thumbImageSize->getHeight()));
$thumbImageSize->getWidth(),
$thumbImageSize->getHeight()));
}
}
return $result;
Expand Down
Loading

0 comments on commit f4a4b77

Please sign in to comment.