Skip to content

Commit

Permalink
fix: Make installable on PHP 8.x (#85) (#89)
Browse files Browse the repository at this point in the history
* fix: Make installable on PHP 8.x (#85)
* chore: style fixes (#90)
  • Loading branch information
ah-net authored May 1, 2024
1 parent c1cb03a commit 40c4eee
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "emico/m2-attributelanding",
"description": "Attribute landing pages for Magento 2",
"require": {
"php": ">=8.0 <8.3",
"php": "^8.0",
"magento/module-sitemap": "^100.2||^100.4",
"magento/module-catalog": "^102.0||^103.0||^104.0"
},
Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/OverviewPage/Edit/BackButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\OverviewPage\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
Expand Down
3 changes: 2 additions & 1 deletion src/Block/Adminhtml/OverviewPage/Edit/DeleteButton.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Emico\AttributeLanding\Block\Adminhtml\OverviewPage\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class DeleteButton extends GenericButton implements ButtonProviderInterface
{

/**
* @return array
*/
Expand All @@ -22,6 +22,7 @@ public function getButtonData(): array
'sort_order' => 20,
];
}

return $data;
}

Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/OverviewPage/Edit/GenericButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\OverviewPage\Edit;

use Emico\AttributeLanding\Api\Data\LandingPageInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\OverviewPage\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
{

/**
* @return array
*/
Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/OverviewPage/Edit/SaveButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\OverviewPage\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/Page/Edit/BackButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\Page\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
Expand Down
3 changes: 2 additions & 1 deletion src/Block/Adminhtml/Page/Edit/DeleteButton.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Emico\AttributeLanding\Block\Adminhtml\Page\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class DeleteButton extends GenericButton implements ButtonProviderInterface
{

/**
* @return array
*/
Expand All @@ -22,6 +22,7 @@ public function getButtonData(): array
'sort_order' => 20,
];
}

return $data;
}

Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/Page/Edit/GenericButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\Page\Edit;

use Emico\AttributeLanding\Api\Data\LandingPageInterface;
Expand Down
2 changes: 0 additions & 2 deletions src/Block/Adminhtml/Page/Edit/SaveAndContinueButton.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\Page\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
{

/**
* @return array
*/
Expand Down
1 change: 0 additions & 1 deletion src/Block/Adminhtml/Page/Edit/SaveButton.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Block\Adminhtml\Page\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/Adminhtml/OverviewPage.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml;

use Magento\Backend\App\Action;
Expand All @@ -9,10 +8,12 @@

abstract class OverviewPage extends Action
{
const ADMIN_MENU_RESOURCE = 'Emico_AttributeLanding::overviewpage_management';
public const ADMIN_MENU_RESOURCE = 'Emico_AttributeLanding::overviewpage_management';

/**
* @param Context $context
*
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod.Found
*/
public function __construct(
Context $context
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/Delete.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;

use Emico\AttributeLanding\Api\OverviewPageRepositoryInterface;
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/Adminhtml/OverviewPage/Edit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;

use Emico\AttributeLanding\Api\Data\OverviewPageInterfaceFactory;
Expand Down Expand Up @@ -80,7 +79,9 @@ public function execute()
$id ? __('Edit overview page') : __('New overview page')
);

$resultPage->getConfig()->getTitle()->prepend($id ? __('Edit overview page %1', $landingPage->getPageId()) : __('New overview page'));
$resultPage->getConfig()->getTitle()->prepend(
$id ? __('Edit overview page %1', $landingPage->getPageId()) : __('New overview page')
);

return $resultPage;
}
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/Index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;

use Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/NewAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;

use Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/OverviewPage/Save.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\OverviewPage;

use Emico\AttributeLanding\Api\Data\OverviewPageInterface;
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Adminhtml/Page.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml;

use Magento\Backend\App\Action;

abstract class Page extends Action
{
const ADMIN_MENU_RESOURCE = 'Emico_AttributeLanding::page_management';
public const ADMIN_MENU_RESOURCE = 'Emico_AttributeLanding::page_management';

/**
* Init page
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/Page/Delete.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Api\LandingPageRepositoryInterface;
Expand Down
4 changes: 1 addition & 3 deletions src/Controller/Adminhtml/Page/Duplicate.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Api\Data\LandingPageInterface;
Expand Down Expand Up @@ -78,11 +77,10 @@ public function execute()
$this->messageManager->addNoticeMessage('Your page has been duplicated');
$this->messageManager->addWarningMessage('Do not forget to change the URL path');
return $resultRedirect->setPath('*/*/edit', ['page_id' => $newLandingPage->getId()]);

} catch (NoSuchEntityException $exception) {
$this->messageManager->addErrorMessage(__('This Page no longer exists.'));

return $resultRedirect->setPath('*/*/');
}
}
}
}
5 changes: 3 additions & 2 deletions src/Controller/Adminhtml/Page/Edit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Api\Data\LandingPageInterfaceFactory;
Expand Down Expand Up @@ -81,7 +80,9 @@ public function execute()
$id ? __('Edit page') : __('New page')
);

$resultPage->getConfig()->getTitle()->prepend($id ? __('Edit page %1', $landingPage->getPageId()) : __('New page'));
$resultPage->getConfig()->getTitle()->prepend(
$id ? __('Edit page %1', $landingPage->getPageId()) : __('New page')
);

return $resultPage;
}
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/Page/Index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Controller\Adminhtml\Page;
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Adminhtml/Page/NewAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Controller\Adminhtml\Page;
Expand Down
8 changes: 6 additions & 2 deletions src/Controller/Adminhtml/Page/Save.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Emico\AttributeLanding\Controller\Adminhtml\Page;

use Emico\AttributeLanding\Api\Data\LandingPageInterface;
Expand Down Expand Up @@ -111,17 +110,20 @@ public function execute()
/**
* @param LandingPageInterface $landingPage
* @param array $data
*
* phpcs:disable Magento2.Security.InsecureFunction.FoundWithAlternative
*/
protected function hydrateLandingPage(LandingPageInterface $landingPage, array $data)
{
if (!isset($data[LandingPageInterface::OVERVIEW_PAGE_IMAGE])) {
$data[LandingPageInterface::OVERVIEW_PAGE_IMAGE] = null;
} elseif (isset($data[LandingPageInterface::OVERVIEW_PAGE_IMAGE][0]['file'])) {
$data[LandingPageInterface::OVERVIEW_PAGE_IMAGE] = $data[LandingPageInterface::OVERVIEW_PAGE_IMAGE][0]['file'];
$data[LandingPageInterface::OVERVIEW_PAGE_IMAGE] =
$data[LandingPageInterface::OVERVIEW_PAGE_IMAGE][0]['file'];
} else {
unset($data[LandingPageInterface::OVERVIEW_PAGE_IMAGE]);
}

$filterAttributes = $data[LandingPageInterface::FILTER_ATTRIBUTES] ?? [];
$filterAttributes = $this->sanitizeFilterAttributes($filterAttributes);
$landingPage->setFilterAttributes(serialize($filterAttributes));
Expand All @@ -148,8 +150,10 @@ protected function sanitizeFilterAttributes(array $filterAttributes): array
unset($filterAttribute[$field]);
}
}

$sanitizedAttributes[] = $filterAttribute;
}

return $sanitizedAttributes;
}
}
4 changes: 2 additions & 2 deletions src/Controller/Adminhtml/Page/UploadImage.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @author Bram Gerritsen <bgerritsen@emico.nl>
* @copyright (c) Emico B.V. 2017
Expand All @@ -22,7 +23,6 @@ class UploadImage extends \Magento\Backend\App\Action
/**
* UploadImage constructor.
* @param Context $context
* @param LoggerInterface $logger
* @param ImageUploader $imageUploader
*/
public function __construct(
Expand All @@ -45,4 +45,4 @@ public function execute()
$resultJson->setData($result);
return $resultJson;
}
}
}

0 comments on commit 40c4eee

Please sign in to comment.