Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"magento/module-catalog": "^102.0||^103.0||^104.0"
},
"require-dev": {
"emico/code-quality": "^10.5",
"emico/code-quality": "~10.6.0",
"symfony/finder": "6.4.0"
},
"prefer-stable": true,
Expand Down
8 changes: 5 additions & 3 deletions src/Block/LandingPage/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

use Emico\AttributeLanding\Api\Data\LandingPageInterface;
use Emico\AttributeLanding\Model\LandingPageContext;
use Exception;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Psr\Log\LoggerInterface;

class Content extends Template
Expand All @@ -32,12 +34,12 @@ class Content extends Template

/**
* PageContent constructor.
* @param Template\Context $context
* @param Context $context
* @param LandingPageContext $landingPageContext
* @param FilterProvider $filterProvider
*/
public function __construct(
Template\Context $context,
Context $context,
LandingPageContext $landingPageContext,
FilterProvider $filterProvider,
LoggerInterface $logger
Expand Down Expand Up @@ -80,7 +82,7 @@ protected function getFilteredContent(string $content): string
{
try {
return $this->pageFilter->filter($content);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->critical($e->getMessage());
return '';
}
Expand Down
8 changes: 5 additions & 3 deletions src/Block/OverviewPage/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Emico\AttributeLanding\Api\LandingPageRepositoryInterface;
use Emico\AttributeLanding\Model\LandingPageContext;
use Emico\AttributeLanding\Model\Page\ImageUploader;
use Exception;
use Magento\Framework\View\Element\Template\Context;
use Magento\Theme\Block\Html\Breadcrumbs;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\Exception\LocalizedException;
Expand Down Expand Up @@ -48,15 +50,15 @@ class View extends Template

/**
* View constructor.
* @param Template\Context $context
* @param Context $context
* @param LandingPageContext $landingPageContext
* @param LandingPageRepositoryInterface $landingPageRepository
* @param ImageUploader $imageUploader
* @param FilterProvider $filterProvider
* @param LoggerInterface $logger
*/
public function __construct(
Template\Context $context,
Context $context,
LandingPageContext $landingPageContext,
LandingPageRepositoryInterface $landingPageRepository,
ImageUploader $imageUploader,
Expand Down Expand Up @@ -132,7 +134,7 @@ protected function getFilteredContent(string $content): string
{
try {
return $this->pageFilter->filter($content);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->critical($e->getMessage());
return '';
}
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Emico\AttributeLanding\Api\OverviewPageRepositoryInterface;
use Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;
use Exception;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Redirect;
use Magento\Framework\Controller\ResultInterface;
Expand Down Expand Up @@ -46,7 +47,7 @@ public function execute()

$this->messageManager->addSuccessMessage(__('You deleted the Page.'));
return $resultRedirect->setPath('*/*/');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());

return $resultRedirect->setPath('*/*/edit', ['page_id' => $id]);
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Emico\AttributeLanding\Api\Data\OverviewPageInterface;
use Emico\AttributeLanding\Api\Data\OverviewPageInterfaceFactory;
use Emico\AttributeLanding\Api\OverviewPageRepositoryInterface;
use Exception;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Api\DataObjectHelper;
Expand Down Expand Up @@ -99,7 +100,7 @@ public function execute()
return $resultRedirect->setPath('*/*/');
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
} catch (Exception $e) {
$this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the Page.'));
}

Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Adminhtml/Page/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Emico\AttributeLanding\Api\LandingPageRepositoryInterface;
use Emico\AttributeLanding\Controller\Adminhtml\Page;
use Exception;
use Magento\Backend\App\Action\Context;

class Delete extends Page
Expand Down Expand Up @@ -44,7 +45,7 @@ public function execute()

$this->messageManager->addSuccessMessage(__('You deleted the Page.'));
return $resultRedirect->setPath('*/*/');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->messageManager->addErrorMessage($e->getMessage());

return $resultRedirect->setPath('*/*/edit', ['page_id' => $id]);
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Adminhtml/Page/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Emico\AttributeLanding\Api\Data\LandingPageInterface;
use Emico\AttributeLanding\Api\Data\LandingPageInterfaceFactory;
use Emico\AttributeLanding\Api\LandingPageRepositoryInterface;
use Exception;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Redirect;
Expand Down Expand Up @@ -71,7 +72,6 @@ public function execute()
$data = $this->getRequest()->getPostValue();
$data[LandingPageInterface::STORE_ID] = (int)$data[LandingPageInterface::STORE_ID];

/** @phpstan-ignore-next-line */
if (!$data) {
return $resultRedirect->setPath('*/*/');
}
Expand Down Expand Up @@ -113,7 +113,7 @@ public function execute()
return $resultRedirect->setPath('*/*/');
} catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
} catch (Exception $e) {
$this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the Page.'));
}

Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Adminhtml/Page/UploadImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Model\Page\ImageUploader;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\ResultFactory;

class UploadImage extends \Magento\Backend\App\Action
class UploadImage extends Action
{
/**
* @var ImageUploader
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Catalog/Layer/State/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(LandingPageContext $landingPageContext, FilterHiderI
public function afterGetFilters(State $subject, $result)
{
/** @phpstan-ignore-next-line */
if (!\is_array($result) || empty($result)) {
if (!is_array($result) || empty($result)) {
return $result;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Model/LandingPageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Emico\AttributeLanding\Api\Data\LandingPageInterface;
use Emico\AttributeLanding\Api\LandingPageRepositoryInterface;
use Emico\AttributeLanding\Ui\Component\Product\Form\Categories\Options;
use Exception;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
use Emico\AttributeLanding\Api\Data\PageSearchResultsInterfaceFactory;
Expand Down Expand Up @@ -125,7 +126,7 @@ public function save(LandingPageInterface $page): LandingPageInterface
/** @phpstan-ignore-next-line */
$page->setPageId($parentLandingPage->getPageId());
$this->resource->saveLandingPageStoreData($page);
} catch (\Exception $exception) {
} catch (Exception $exception) {
throw new CouldNotSaveException(
__(
'Could not save the page: %1',
Expand Down Expand Up @@ -237,7 +238,7 @@ public function delete(LandingPageInterface $page): bool
try {
/** @var LandingPage $page */
$this->resource->delete($page);
} catch (\Exception $exception) {
} catch (Exception $exception) {
throw new CouldNotDeleteException(
__(
'Could not delete the Page: %1',
Expand Down
5 changes: 3 additions & 2 deletions src/Model/OverviewPageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Emico\AttributeLanding\Api\Data\LandingPageInterface;
use Emico\AttributeLanding\Api\Data\OverviewPageInterface;
use Emico\AttributeLanding\Api\OverviewPageRepositoryInterface;
use Exception;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SearchCriteriaInterface;
Expand Down Expand Up @@ -82,7 +83,7 @@ public function save(OverviewPageInterface $page): OverviewPageInterface
try {
/** @var LandingPage $page */
$this->resource->save($page); // @phpstan-ignore-line
} catch (\Exception $exception) {
} catch (Exception $exception) {
throw new CouldNotSaveException(
__(
'Could not save the page: %1',
Expand Down Expand Up @@ -141,7 +142,7 @@ public function delete(OverviewPageInterface $page): bool
try {
/** @var LandingPage $page */
$this->resource->delete($page); // @phpstan-ignore-line
} catch (\Exception $exception) {
} catch (Exception $exception) {
throw new CouldNotDeleteException(
__(
'Could not delete the Page: %1',
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Page/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
use Emico\AttributeLanding\Model\ResourceModel\Page\CollectionFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\App\Request\Http;
use Magento\Ui\DataProvider\AbstractDataProvider;

class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
class DataProvider extends AbstractDataProvider
{
/**
* @var array
Expand Down
2 changes: 1 addition & 1 deletion src/Model/UrlRewriteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private function shouldStripRequestPath(?string $newSuffix): bool
protected function getActiveStoreIds(UrlRewriteGeneratorInterface $landingPage): array
{
// phpcs:disable SlevomatCodingStandard.Functions.StrictCall.NonStrictComparison
if (\in_array('0', $landingPage->getStoreIds(), false) !== false) { // @phpstan-ignore-line
if (in_array('0', $landingPage->getStoreIds(), false) !== false) { // @phpstan-ignore-line
return array_map(
static function (StoreInterface $store) {
return $store->getId();
Expand Down
35 changes: 13 additions & 22 deletions src/Ui/Component/Listing/Column/PageActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,37 @@

use Magento\Catalog\Model\CategoryRepository;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Ui\Component\Listing\Columns\Column;

class PageActions extends \Magento\Ui\Component\Listing\Columns\Column
class PageActions extends Column
{
/**
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;

/**
* @var \Magento\Catalog\Model\CategoryRepository
*/
public CategoryRepository $categoryRepository; // phpcs:ignore SlevomatCodingStandard.Classes.ForbiddenPublicProperty.ForbiddenPublicProperty

public const URL_PATH_DETAILS = 'emico_attributelanding/page/details';
protected const URL_PATH_EDIT = 'emico_attributelanding/page/edit';
protected const URL_PATH_DELETE = 'emico_attributelanding/page/delete';
protected const URL_PATH_DUPLICATE = 'emico_attributelanding/page/duplicate';

/**
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param \Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param CategoryRepository $categoryRepository
* @param StoreRepositoryInterface $storeRepository
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
\Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
\Magento\Catalog\Model\CategoryRepository $categoryRepository,
public StoreRepositoryInterface $storeRepository,
\Magento\Framework\UrlInterface $urlBuilder,
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
private readonly CategoryRepository $categoryRepository,
private readonly StoreRepositoryInterface $storeRepository,
protected readonly UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
$this->categoryRepository = $categoryRepository;
$this->urlBuilder = $urlBuilder;

parent::__construct($context, $uiComponentFactory, $components, $data);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Ui/Component/Product/Form/Categories/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Emico\AttributeLanding\Ui\Component\Product\Form\Categories;

use Magento\Catalog\Ui\Component\Product\Form\Categories\Options as MagentoOptions;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Framework\App\RequestInterface;

/**
* Options tree for "Categories" field
*/
class Options extends \Magento\Catalog\Ui\Component\Product\Form\Categories\Options implements OptionSourceInterface
class Options extends MagentoOptions implements OptionSourceInterface
{
/**
* @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory
Expand Down
6 changes: 4 additions & 2 deletions src/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

declare(strict_types=1);

\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Emico_AttributeLanding',
__DIR__
);