Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
71d5282
Refactor constructors and constants in AdminActivityLog controllers
lucafuser Dec 14, 2025
bb7accf
Refactor ClearLog class in AdminActivityLog module
lucafuser Dec 14, 2025
11c523a
Refactor Benchmark class in AdminActivityLog module
lucafuser Dec 14, 2025
9f06d0a
Refactor and enhance type safety across AdminActivityLog module
lucafuser Dec 14, 2025
2a9c045
Add explicit return type declarations in collection constructors
lucafuser Dec 14, 2025
06c7d1d
Add explicit `void` return type to resource model constructors
lucafuser Dec 14, 2025
9978e77
Add explicit type declarations across AdminActivityLog module
lucafuser Dec 14, 2025
8cb18ca
Add explicit type declarations for improved type safety in Processor …
lucafuser Dec 14, 2025
544d428
Add type declarations and improve type safety in Data helper
lucafuser Dec 14, 2025
987a220
Add type casting to enhance type safety in Revert controller
lucafuser Dec 14, 2025
544a19b
Add type declarations and improve method signatures in Status model
lucafuser Dec 14, 2025
9bfc9c9
Improve type safety and constructor design in ActivityLogListing
lucafuser Dec 14, 2025
e6c1e3c
Remove redundant PHPDoc in Selector block
lucafuser Dec 14, 2025
56f66e7
Remove redundant PHPDoc and improve method structure in Observers
lucafuser Dec 14, 2025
4460e14
Refactor Observers for improved type safety and readability
lucafuser Dec 14, 2025
4e12ea3
Refactor Action plugin for improved type safety and encapsulation
lucafuser Dec 14, 2025
60b4866
Refactor Delete plugin for improved type safety and readability
lucafuser Dec 14, 2025
44d76f2
Refactor Auth plugin to improve type safety and encapsulation
lucafuser Dec 14, 2025
e8afd31
Rename plugin classes for better consistency and clarity
lucafuser Dec 14, 2025
57ad91c
Refactor column classes for improved type safety and clarity
lucafuser Dec 14, 2025
c7c79c8
Remove redundant PHPDoc comments from resource models and collections
lucafuser Dec 14, 2025
7bde740
Improve type safety and modernize TrackField helper
lucafuser Dec 14, 2025
682034c
Enhance type safety and simplify SystemConfig model
lucafuser Dec 14, 2025
90e6afc
Refactor ThemeConfig for improved type safety and maintainability
lucafuser Dec 14, 2025
21cd2b8
Refactor ModelInterface for improved type safety
lucafuser Dec 14, 2025
f7cac1a
CS-fix
lucafuser Dec 14, 2025
6150f32
Add explicit return type to initActivity method in AdminActivityLog
lucafuser Dec 14, 2025
a38edc9
Add nullable return types to version methods in Browser helper
lucafuser Dec 14, 2025
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
11 changes: 6 additions & 5 deletions Api/Activity/ModelInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@
interface ModelInterface
{
/**
* Get old data
* @param DataObject $model
* @return mixed
*/
public function getOldData(DataObject $model);

/**
* Get edit data
* @param DataObject $model
* @param $fieldArray
* @return mixed
* @param array<string, string> $fieldArray
* @return array{}|array<string, array{
* old_value: string,
* new_value: string
* }>
*/
public function getEditData(DataObject $model, $fieldArray);
public function getEditData(DataObject $model, array $fieldArray);
}
52 changes: 27 additions & 25 deletions Block/Adminhtml/ActivityLogListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Framework\Json\Helper\Data as JsonHelper;
use MageOS\AdminActivityLog\Api\ActivityRepositoryInterface;
use MageOS\AdminActivityLog\Helper\Browser;

Expand All @@ -25,31 +27,31 @@
*/
class ActivityLogListing extends Template
{
/**
* Path to template file in theme.
* @var string
*/
protected $_template = 'MageOS_AdminActivityLog::log_listing.phtml';

/**
* ActivityLogListing constructor.
* @param Context $context
* @param ActivityRepositoryInterface $activityRepository
* @param Browser $browser
*/
public function __construct(
Context $context,
protected readonly ActivityRepositoryInterface $activityRepository,
protected readonly Browser $browser
protected readonly Browser $browser,
Context $context,
array $data = [],
?JsonHelper $jsonHelper = null,
?DirectoryHelper $directoryHelper = null
) {
parent::__construct($context);
parent::__construct($context, $data, $jsonHelper, $directoryHelper);
}

/**
* Get admin activity log listing
* @return array
*
* @return null|array<int, array{
* entity_id: string,
* activity_id: string,
* field_name: string,
* old_value: string,
* new_value: string
* }>
*/
public function getLogListing()
public function getLogListing(): ?array
{
$id = $this->getRequest()->getParam('id');
$data = $this->activityRepository->getActivityLog($id);
Expand All @@ -58,9 +60,9 @@ public function getLogListing()

/**
* Get admin activity details
* @return array
* @return array<string, string>
*/
public function getAdminDetails()
public function getAdminDetails(): array
{
$id = $this->getRequest()->getParam('id');
$activity = $this->activityRepository->getActivityById($id);
Expand All @@ -69,14 +71,14 @@ public function getAdminDetails()
$this->browser->setUserAgent($activity->getUserAgent());
$browser = $this->browser->__toString();

$logData = [];
$logData['username'] = $activity->getUsername();
$logData['module'] = $activity->getModule();
$logData['name'] = $activity->getName();
$logData['fullaction'] = $activity->getFullaction();
$logData['browser'] = $browser;
$logData['date'] = $activity->getUpdatedAt();
return $logData;
return [
'username' => $activity->getUsername(),
'module' => $activity->getModule(),
'name' => $activity->getName(),
'fullaction' => $activity->getFullaction(),
'browser' => $browser,
'date' => $activity->getUpdatedAt()
];
}

public function getActivityRepository(): ActivityRepositoryInterface
Expand Down
1 change: 0 additions & 1 deletion Block/Adminhtml/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Selector extends Template
{
/**
* Revert Activity Log action URL
* @return string
*/
public function getRevertUrl(): string
{
Expand Down
13 changes: 2 additions & 11 deletions Controller/Adminhtml/Activity/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,16 @@
*/
class Index extends Action
{
/**
* @var string
*/
public const ADMIN_RESOURCE = 'MageOS_AdminActivityLog::activity';
public const string ADMIN_RESOURCE = 'MageOS_AdminActivityLog::activity';

/**
* Index constructor.
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
protected readonly PageFactory $resultPageFactory
private readonly PageFactory $resultPageFactory
) {
parent::__construct($context);
}

/**
* Index action
* @return Page
*/
public function execute()
Expand Down
16 changes: 3 additions & 13 deletions Controller/Adminhtml/Activity/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,20 @@
*/
class Log extends Action
{
/**
* Log constructor.
* @param Context $context
* @param RawFactory $resultRawFactory
* @param LayoutFactory $layoutFactory
*/
public function __construct(
Context $context,
protected readonly RawFactory $resultRawFactory,
protected readonly LayoutFactory $layoutFactory
private readonly RawFactory $resultRawFactory,
private readonly LayoutFactory $layoutFactory
) {
parent::__construct($context);
}

/**
* view action
* @return Raw
*/
public function execute()
{
$content = $this->layoutFactory->create()
->createBlock(
ActivityLogListing::class
);
$content = $this->layoutFactory->create()->createBlock(ActivityLogListing::class);

/** @var Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
Expand Down
13 changes: 3 additions & 10 deletions Controller/Adminhtml/Activity/Revert.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,22 @@
*/
class Revert extends Action
{
/**
* Revert constructor.
* @param Context $context
* @param JsonFactory $resultJsonFactory
* @param Processor $processor
*/
public function __construct(
Context $context,
protected readonly JsonFactory $resultJsonFactory,
protected readonly Processor $processor
private readonly JsonFactory $resultJsonFactory,
private readonly Processor $processor
) {
parent::__construct($context);
}

/**
* Revert action
* @return Json
*/
public function execute()
{
$activityId = $this->getRequest()->getParam('id');

$result = $this->processor->revertActivity($activityId);
$result = $this->processor->revertActivity((int)$activityId);

$json = $this->resultJsonFactory->create();
$json->setData($result);
Expand Down
10 changes: 1 addition & 9 deletions Controller/Adminhtml/Login/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@
*/
class Index extends Action
{
/**
* @var string
*/
public const ADMIN_RESOURCE = 'MageOS_AdminActivityLog::login_activity';
public const string ADMIN_RESOURCE = 'MageOS_AdminActivityLog::login_activity';

/**
* Index constructor.
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
protected readonly PageFactory $resultPageFactory
Expand Down
11 changes: 1 addition & 10 deletions Cron/ClearLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ class ClearLog
{
/**
* Default date format
* @var string
*/
protected const DATE_FORMAT = 'Y-m-d H:i:s';
protected const string DATE_FORMAT = 'Y-m-d H:i:s';

/**
* ClearLog constructor.
* @param LoggerInterface $logger
* @param DateTime $dateTime
* @param Helper $helper
* @param ActivityRepositoryInterface $activityRepository
* @param LoginRepositoryInterface $loginRepository
*/
public function __construct(
protected readonly LoggerInterface $logger,
protected readonly DateTime $dateTime,
Expand Down
21 changes: 5 additions & 16 deletions Helper/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,13 @@ class Benchmark extends AbstractHelper
/**
* @var String[] Start time of execution
*/
private $startTime = [];
private array $startTime = [];

/**
* @var String[] End time of execution
*/
private $endTime = [];
private array $endTime = [];

/**
* Benchmark constructor.
* @param Context $context
* @param LoggerInterface $logger
*/
public function __construct(
Context $context,
protected LoggerInterface $logger
Expand All @@ -54,10 +49,8 @@ public function __construct(

/**
* log info about start time in millisecond
* @param $method
* @return void
*/
public function start($method): void
public function start(string $method): void
{
$this->reset($method);
if (self::BENCHMARK_ENABLE) {
Expand All @@ -70,10 +63,8 @@ public function start($method): void

/**
* log info about end time and time diiference in millisecond
* @param $method
* @return void
*/
public function end($method): void
public function end(string $method): void
{
if (self::BENCHMARK_ENABLE) {
$this->endTime[$method] = round(microtime(true) * 1000);
Expand All @@ -89,10 +80,8 @@ public function end($method): void

/**
* Reset start time and end time
* @param $method
* @return void
*/
public function reset($method): void
public function reset(string $method): void
{
$this->startTime[$method] = 0;
$this->endTime[$method] = 0;
Expand Down
Loading