From ca9ad22cf831955bac6a6b59a08629047b6b5cc1 Mon Sep 17 00:00:00 2001 From: Brandon Bishop Date: Mon, 1 Dec 2025 15:27:17 +0000 Subject: [PATCH 1/2] fix --- Model/WebhookModel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/WebhookModel.php b/Model/WebhookModel.php index fb93e06..b695fa9 100644 --- a/Model/WebhookModel.php +++ b/Model/WebhookModel.php @@ -61,8 +61,8 @@ public function __construct( Context $context, Registry $registry, private Json $json, - AbstractResource $resource = null, - AbstractDb $resourceCollection = null, + ?AbstractResource $resource = null, + ?AbstractDb $resourceCollection = null, array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); From 9ea8308a728dab4d937edde4df9fd01054f76e79 Mon Sep 17 00:00:00 2001 From: Brandon Bishop Date: Mon, 1 Dec 2025 15:41:58 +0000 Subject: [PATCH 2/2] linting --- .gitignore | 1 + Block/System/Config/Connect.php | 3 +-- Block/System/Config/Fields.php | 2 +- Block/System/Config/Webhook.php | 2 +- Controller/Adminhtml/Config/WebhooksAjax.php | 2 +- Helper/Settings.php | 4 ++-- Model/Config/Source/Pages.php | 10 ++++++++-- Model/ContentPageRepository.php | 9 ++++----- Model/PageUrlRewriteGenerator.php | 2 +- Model/Queue/Handler/Handler.php | 7 ++++++- Plugin/Magento/Store/Model/PathConfig.php | 4 ++-- System/Config.php | 1 + 12 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Block/System/Config/Connect.php b/Block/System/Config/Connect.php index bd5e432..af8c224 100644 --- a/Block/System/Config/Connect.php +++ b/Block/System/Config/Connect.php @@ -42,11 +42,10 @@ public function __construct( private Config $config, array $data = [], ?SecureHtmlRenderer $secureRenderer = null - ){ + ) { parent::__construct($context, $data, $secureRenderer); } - /** * Return element html * diff --git a/Block/System/Config/Fields.php b/Block/System/Config/Fields.php index de33c02..4d1144f 100644 --- a/Block/System/Config/Fields.php +++ b/Block/System/Config/Fields.php @@ -42,7 +42,7 @@ public function __construct( private Config $config, array $data = [], ?SecureHtmlRenderer $secureRenderer = null - ){ + ) { parent::__construct($context, $data, $secureRenderer); } diff --git a/Block/System/Config/Webhook.php b/Block/System/Config/Webhook.php index f802339..12595cd 100644 --- a/Block/System/Config/Webhook.php +++ b/Block/System/Config/Webhook.php @@ -42,7 +42,7 @@ public function __construct( private Config $config, array $data = [], ?SecureHtmlRenderer $secureRenderer = null - ){ + ) { parent::__construct($context, $data, $secureRenderer); } diff --git a/Controller/Adminhtml/Config/WebhooksAjax.php b/Controller/Adminhtml/Config/WebhooksAjax.php index 1ee261d..f168059 100644 --- a/Controller/Adminhtml/Config/WebhooksAjax.php +++ b/Controller/Adminhtml/Config/WebhooksAjax.php @@ -88,7 +88,7 @@ public function execute() $counter = 0; foreach ($data['data']['models'] as $model) { - if($this->config->getFallbackEditor($store)) { + if ($this->config->getFallbackEditor($store)) { $preview_url = self::FALLBACK_EDITOR_URL; } else { $preview_url = $this->config->getStoreUrl($store) . 'builderio/preview/page?model=' . $model['name']; diff --git a/Helper/Settings.php b/Helper/Settings.php index 32e9967..5f13464 100644 --- a/Helper/Settings.php +++ b/Helper/Settings.php @@ -34,10 +34,10 @@ public function __construct( * Log an error message. * * @param string $message - * @param $resource + * @param mixed $resource * @return void */ - public function logError(string $message = "", $resource = null): void + public function logError(string $message = "", mixed $resource = null): void { $this->logger->error( self::LOG_PREFIX . diff --git a/Model/Config/Source/Pages.php b/Model/Config/Source/Pages.php index c5129c7..80e371f 100644 --- a/Model/Config/Source/Pages.php +++ b/Model/Config/Source/Pages.php @@ -18,10 +18,16 @@ */ class Pages implements OptionSourceInterface { + /** + * Pages constructor. + * + * @param ContentPageRepository $contentPageRepository + * @param SearchCriteriaBuilder $searchCriteriaBuilder + */ public function __construct( private ContentPageRepository $contentPageRepository, private SearchCriteriaBuilder $searchCriteriaBuilder - ){ + ) { } /** @@ -35,7 +41,7 @@ public function toOptionArray() $searchCriteria = $this->searchCriteriaBuilder->create(); $pages = $this->contentPageRepository->getList($searchCriteria); - if($pages->getTotalCount()) { + if ($pages->getTotalCount()) { $items = $pages->getItems(); foreach ($items as $page) { $options[] = ['value' => $page->getId(), 'label' => $page->getTitle()]; diff --git a/Model/ContentPageRepository.php b/Model/ContentPageRepository.php index fc545bb..351a2d1 100644 --- a/Model/ContentPageRepository.php +++ b/Model/ContentPageRepository.php @@ -50,11 +50,10 @@ public function save(ContentPageInterface $contentPage): ContentPageInterface $exception ); } catch (\Throwable $exception) { - // todo fix the exception handling -// throw new CouldNotSaveException( -// __('Could not save the webhook: %1', __('Something went wrong while saving the ContentPage.')), -// $exception -// ); + throw new CouldNotSaveException( + __('Could not save the content page: %1', $exception->getMessage()), + $exception + ); } return $contentPage; diff --git a/Model/PageUrlRewriteGenerator.php b/Model/PageUrlRewriteGenerator.php index 85964de..28ee1e8 100644 --- a/Model/PageUrlRewriteGenerator.php +++ b/Model/PageUrlRewriteGenerator.php @@ -23,7 +23,7 @@ class PageUrlRewriteGenerator /** * Entity type code */ - const ENTITY_TYPE = 'builderio-page'; + public const ENTITY_TYPE = 'builderio-page'; /** * Page model diff --git a/Model/Queue/Handler/Handler.php b/Model/Queue/Handler/Handler.php index 18631cf..7e0a361 100644 --- a/Model/Queue/Handler/Handler.php +++ b/Model/Queue/Handler/Handler.php @@ -99,7 +99,7 @@ private function processPage() $api = PageService::API_HTML_PAGE_ENDPOINT; // Check if the URL contains a widget if it does use the Qwik API - if( str_contains($this->webhook->getWebhookData(), "{{widget") ) { + if (str_contains($this->webhook->getWebhookData(), "{{widget")) { $api = PageService::API_QWIK_PAGE_ENDPOINT; } @@ -138,6 +138,11 @@ private function processPage() } } + /** + * Delete the page associated with the webhook. + * + * @return void + */ private function deletePage() { try { diff --git a/Plugin/Magento/Store/Model/PathConfig.php b/Plugin/Magento/Store/Model/PathConfig.php index 950f4a9..284169e 100644 --- a/Plugin/Magento/Store/Model/PathConfig.php +++ b/Plugin/Magento/Store/Model/PathConfig.php @@ -44,9 +44,9 @@ public function afterGetDefaultPath(PathConfigMagento $subject, string $result): $store = $this->storeManager->getStore(); $value = $this->config->isCmsHomepageEnabled($store->getId()); - if($value) { + if ($value) { $page_id = $this->config->getCmsHomepage($store->getId()); - if($page_id) { + if ($page_id) { return 'builderio/view/index/id/' . $page_id; } } diff --git a/System/Config.php b/System/Config.php index 1c5dc9b..c62b59a 100644 --- a/System/Config.php +++ b/System/Config.php @@ -238,6 +238,7 @@ public function getMappedWorkspaceFromStore($storeId = null) /** * Check if the Builder.io integration is enabled. * + * @param null|int|string $storeId * @return bool */ public function isCmsHomepageEnabled($storeId = null)