Skip to content

Commit

Permalink
Merge pull request #3 from magmodules/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
  • Loading branch information
Marvin-Magmodules authored Apr 25, 2024
2 parents 6c9fbe1 + eee1a34 commit 816df6e
Show file tree
Hide file tree
Showing 58 changed files with 1,384 additions and 1,748 deletions.
39 changes: 36 additions & 3 deletions Api/Log/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,54 @@
interface RepositoryInterface
{

/**
* Limit stream size to 100 lines
*/
public const STREAM_DEFAULT_LIMIT = 100;

/**
* Log file path pattern
*/
public const LOG_FILE = '%s/log/messagebird-%s.log';

/**
* Add record to error log
*
* @param string $type
* @param mixed $data
*
*/
public function addErrorLog(string $type, $data);
public function addErrorLog(string $type, $data): void;

/**
* Add record to debug log
*
* @param string $type
* @param mixed $data
*/
public function addDebugLog(string $type, $data): void;

/**
* Add record to log
*
* @param string $type
* @param mixed $data
*/
public function addLog(string $type, $data): void;

/**
* Returns path of logfile
*
* @param string $type
* @return string
*/
public function getLogFilePath(string $type): ?string;

/**
* Return log entries as sorted array
*
* @param string $path
* @param int|null $limit
* @return array|null
*/
public function addDebugLog(string $type, $data);
public function getLogEntriesAsArray(string $path, ?int $limit = null): ?array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magmodules\MessageBird\Block\Adminhtml\MessageBird;
namespace Magmodules\MessageBird\Block\Adminhtml\Design;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magmodules\MessageBird\Block\Adminhtml\MessageBird;
namespace Magmodules\MessageBird\Block\Adminhtml\Design;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
Expand All @@ -26,8 +26,8 @@ public function render(AbstractElement $element): string
$html = '<tr id="row_' . $element->getHtmlId() . '">';
$html .= ' <td class="label"></td>';
$html .= ' <td class="value">';
$html .= ' <div class="magmodules-messagebird-heading-block">' . $element->getData('label') . '</div>';
$html .= ' <div class="magmodules-messagebird-heading-comment">' . $element->getData('comment') . '</div>';
$html .= ' <div class="mm-ui-heading-block">' . $element->getData('label') . '</div>';
$html .= ' <div class="mm-ui-heading-comment">' . $element->getData('comment') . '</div>';
$html .= ' </td>';
$html .= ' <td></td>';
$html .= '</tr>';
Expand Down
18 changes: 9 additions & 9 deletions Block/Adminhtml/System/Config/Button/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ public function getApiCheckUrl()
}

/**
* @return mixed
* @return string
*/
public function getButtonHtml()
public function getButtonHtml(): string
{
$buttonData = ['id' => 'messagebird-button_credentials', 'label' => __('Check Credentials')];
try {
$button = $this->getLayout()->createBlock(
Button::class
)->setData($buttonData);
return $button->toHtml();
return $this->getLayout()
->createBlock(Button::class)
->setData([
'id' => 'mm-ui-button_credentials',
'label' => __('Check Credentials')
])->toHtml();
} catch (Exception $e) {
$this->logger->addErrorLog('LocalizedException', $e->getMessage());
return false;
return '';
}
}
}
94 changes: 0 additions & 94 deletions Block/Adminhtml/System/Config/Button/DebugCheck.php

This file was deleted.

95 changes: 0 additions & 95 deletions Block/Adminhtml/System/Config/Button/ErrorCheck.php

This file was deleted.

74 changes: 74 additions & 0 deletions Block/Adminhtml/System/Config/Button/Log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* Copyright © Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magmodules\MessageBird\Block\Adminhtml\System\Config\Button;

use Exception;
use Magento\Backend\Block\Widget\Button;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magmodules\MessageBird\Api\Log\RepositoryInterface as LogRepository;

/**
* Log check button class
*/
class Log extends Field
{

/**
* @var string
*/
protected $_template = 'Magmodules_MessageBird::system/config/button/log.phtml';

/**
* @param AbstractElement $element
*
* @return string
*/
public function render(AbstractElement $element): string
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}

/**
* @param AbstractElement $element
*
* @return string
*/
public function _getElementHtml(AbstractElement $element): string
{
return $this->_toHtml();
}

/**
* @param string $type
* @return string
*/
public function getDownloadUrl(string $type): string
{
return $this->getUrl('messagebird/log/stream', ['type' => $type]);
}

/**
* @param string $type
* @return string
*/
public function getButtonHtml(string $type): string
{
try {
return $this->getLayout()
->createBlock(Button::class)
->setData([
'id' => 'mm-ui-button_' . $type,
'label' => __('Show last %1 %2 log records', LogRepository::STREAM_DEFAULT_LIMIT, $type)
])->toHtml();
} catch (Exception $e) {
return '';
}
}
}
Loading

0 comments on commit 816df6e

Please sign in to comment.