Skip to content
Open
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
.idea
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deployecommerce/module-builderio",
"version": "1.0.15",
"version": "1.1.0",
"description": "A magento 2 extensions that renders Builder.io content.",
"type": "magento2-module",
"require": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

use DeployEcommerce\BuilderIO\System\Config;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

Expand Down Expand Up @@ -55,7 +57,7 @@ public function __construct(
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
Expand All @@ -79,7 +81,7 @@ public function getAjaxConnectUrl()
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
Button::class
)->setData(
[
'id' => 'connect_button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

namespace DeployEcommerce\BuilderIO\Block\System\Config;

use Magento\Backend\Block\Template;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
use Magento\Framework\Exception\LocalizedException;

/**
Expand All @@ -19,8 +23,8 @@
* It extends the Magento Form Field and uses a custom template to render the button.
*
*/
class Content extends \Magento\Backend\Block\Template implements
\Magento\Framework\Data\Form\Element\Renderer\RendererInterface
class Content extends Template implements
RendererInterface
{
/**
* @var string
Expand All @@ -35,7 +39,7 @@ class Content extends \Magento\Backend\Block\Template implements
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
Expand All @@ -59,7 +63,7 @@ public function getAjaxSyncUrl()
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
Button::class
)->setData(
[
'id' => 'connect_button',
Expand All @@ -73,7 +77,7 @@ public function getButtonHtml()
/**
* @inheritDoc
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
public function render(AbstractElement $element)
{
return $this->_getElementHtml($element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

use DeployEcommerce\BuilderIO\System\Config;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

Expand Down Expand Up @@ -54,7 +56,7 @@ public function __construct(
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
Expand All @@ -78,7 +80,7 @@ public function getAjaxConnectUrl()
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
Button::class
)->setData(
[
'id' => 'fields_button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

use DeployEcommerce\BuilderIO\System\Config;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

Expand Down Expand Up @@ -54,7 +56,7 @@ public function __construct(
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function _getElementHtml(AbstractElement $element)
{
return $this->_toHtml();
}
Expand All @@ -78,7 +80,7 @@ public function getAjaxConnectUrl()
public function getButtonHtml()
{
$button = $this->getLayout()->createBlock(
\Magento\Backend\Block\Widget\Button::class
Button::class
)->setData(
[
'id' => 'webhook_button',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use DeployEcommerce\BuilderIO\Api\ContentPageRepositoryInterface;
use DeployEcommerce\BuilderIO\Helper\Settings;
use DeployEcommerce\BuilderIO\Model\WebhookRepository;
use DeployEcommerce\BuilderIO\Registry\CurrentPageContent;
use DeployEcommerce\BuilderIO\Service\BuilderIO\Page as PageService;
use DeployEcommerce\BuilderIO\System\Config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use DeployEcommerce\BuilderIO\Api\ContentPageRepositoryInterface;
use DeployEcommerce\BuilderIO\Helper\Settings;
use DeployEcommerce\BuilderIO\Model\WebhookRepository;
use DeployEcommerce\BuilderIO\Registry\CurrentPageContent;
use DeployEcommerce\BuilderIO\Service\BuilderIO\Page as PageService;
use Magento\Cms\Controller\Page\View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use DeployEcommerce\BuilderIO\Model\Queue\Handler\Handler;
use DeployEcommerce\BuilderIO\Api\WebhookRepositoryInterface;
use DeployEcommerce\BuilderIO\System\Config;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\CsrfAwareActionInterface;
Expand Down Expand Up @@ -145,7 +146,7 @@ public function execute()
$this->handler->execute($webhook->getWebhookId());
}

} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Dan Lewis (dan.lewis@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Throwable;

class ContentPageRepository implements ContentPageRepositoryInterface
{
Expand Down Expand Up @@ -49,7 +50,7 @@ public function save(ContentPageInterface $contentPage): ContentPageInterface
__('Could not save the webhook: %1', $exception->getMessage()),
$exception
);
} catch (\Throwable $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.')),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use DeployEcommerce\BuilderIO\Model\WebhookModel;
use DeployEcommerce\BuilderIO\Service\BuilderIO\Page as PageService;
use DeployEcommerce\BuilderIO\System\Config;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Magento\UrlRewrite\Model\UrlRewriteFactory;
use Magento\Framework\Serialize\Serializer\Json;
Expand Down Expand Up @@ -107,7 +108,7 @@ private function processPage()

try {
$contentPage = $this->contentPageRepository->findByBuilderioPageId($page['id']);
} catch (\Exception $e) {
} catch (Exception $e) {
$contentPage = $this->contentPageFactory->create();
}

Expand All @@ -133,7 +134,7 @@ private function processPage()

try {
$this->contentPageRepository->save($contentPage);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
Expand All @@ -143,7 +144,7 @@ private function deletePage()
try {
$contentPage = $this->contentPageRepository->findByBuilderioPageId($this->webhook->getBuilderioId());
$this->contentPageRepository->delete($contentPage);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

namespace DeployEcommerce\BuilderIO\Model\ResourceModel;

use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use DeployEcommerce\BuilderIO\Api\Data\ContentPageInterface;
use Magento\Framework\Stdlib\DateTime;

/**
* Class ContentPageResource
Expand Down Expand Up @@ -37,12 +39,12 @@ protected function _construct()
/**
* @inheritDoc
*/
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
protected function _beforeSave(AbstractModel $object)
{
if ($object->isObjectNew()) {
$object->setCreatedAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
$object->setCreatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
}
$object->setUpdatedAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT));
$object->setUpdatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
return parent::_beforeSave($object);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* @Author: Nathan Chick (nathan.chick@deploy.co.uk)
* @Copyright: 2024 Deploy Ecommerce (https://www.deploy.co.uk/)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Throwable;

/**
* Class WebhookRepository
Expand Down Expand Up @@ -64,7 +65,7 @@ public function save(WebhookInterface $webhook): WebhookInterface
__('Could not save the webhook: %1', $exception->getMessage()),
$exception
);
} catch (\Throwable $exception) {
} catch (Throwable $exception) {
throw new CouldNotSaveException(
__('Could not save the webhook: %1', __('Something went wrong while saving the webhook.')),
$exception
Expand Down Expand Up @@ -107,7 +108,7 @@ public function delete(WebhookInterface $webhook): void
__('Could not delete the webhook: %1', $exception->getMessage()),
$exception
);
} catch (\Throwable $exception) {
} catch (Throwable $exception) {
throw new CouldNotSaveException(
__('Could not delete the webhook: %1', __('Something went wrong while deleting the webhook.')),
$exception
Expand Down
File renamed without changes.
Binary file added src/BuilderIO/Service/.DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions Service/BuilderIO.php → src/BuilderIO/Service/BuilderIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use DeployEcommerce\BuilderIO\Helper\Settings;
use DeployEcommerce\BuilderIO\System\Config;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Response;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function getRequest(string $endpoint, array $params = [], $store_id = nul
return (string) $response->getBody()->getContents();
}

} catch (\Exception $e) {
} catch (Exception $e) {
$this->settings->logError(__("API failure %1 for endpoint %2", $e->getMessage(), $endpoint)->__toString());
return null;
}
Expand Down Expand Up @@ -98,7 +99,7 @@ public function postRequest(string $endpoint, string $body, $store_id = null): ?
return $response;
}

} catch (\Exception $e) {
} catch (Exception $e) {
$this->settings->logError(__("API failure %1 for endpoint %2", $e->getMessage(), $endpoint)->__toString());
return null;
}
Expand Down
Loading