Skip to content

Commit

Permalink
Drop support for PHP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Oct 30, 2023
1 parent c0626f6 commit dba9c17
Show file tree
Hide file tree
Showing 47 changed files with 605 additions and 1,133 deletions.
19 changes: 0 additions & 19 deletions Api/Data/LogInterface.php

This file was deleted.

47 changes: 17 additions & 30 deletions Console/Command/CleanCommand.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
<?php
/*
* Copyright © Ghost Unicorns snc. All rights reserved.
* See LICENSE for license details.
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/

declare(strict_types=1);

namespace GhostUnicorns\WebapiLogs\Console\Command;
namespace Opengento\WebapiLogger\Console\Command;

use GhostUnicorns\WebapiLogs\Model\Clean;
use Magento\Framework\Console\Cli;
use Magento\Framework\Exception\LocalizedException;
use Opengento\WebapiLogger\Model\Clean;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CleanCommand extends Command
{
/**
* @var Clean
*/
private $clean;

/**
* @param Clean $clean
* @param string $name
*/
public function __construct(
Clean $clean,
string $name = 'webapilogs:clean'
) {
$this->clean = $clean;
parent::__construct($name);
public function __construct(private Clean $clean)
{
parent::__construct('webapilogs:clean');
}

/**
* @inheritDoc
*/
protected function configure()
protected function configure(): void
{
$this->setDescription('WebapiLogs Cleaner');
$this->setDescription('WebapiLogger Cleaner');
parent::configure();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @throws \Exception
* @throws LocalizedException
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->clean->execute();
$this->clean->clean();

return Cli::RETURN_SUCCESS;
}
}
60 changes: 13 additions & 47 deletions Controller/Adminhtml/Reports/Delete.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,39 @@
<?php
/*
* Copyright © Ghost Unicorns snc. All rights reserved.
* See LICENSE for license details.
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/

declare(strict_types=1);

namespace GhostUnicorns\WebapiLogs\Controller\Adminhtml\Reports;
namespace Opengento\WebapiLogger\Controller\Adminhtml\Reports;

use Exception;
use GhostUnicorns\WebapiLogs\Model\Log\Logger;
use GhostUnicorns\WebapiLogs\Model\Clean;
use Magento\Framework\Controller\Result\Redirect;
use Opengento\WebapiLogger\Model\Clean;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\App\Action\HttpGetActionInterface;

class Delete extends Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
*/
const ADMIN_RESOURCE = 'GhostUnicorns_WebapiLogs::reports_webapilogs';
public const ADMIN_RESOURCE = 'Opengento_WebapiLogger::reports_webapilogs';

/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* @var Clean
*/
private $clean;

/**
* @var Logger
*/
private $logger;

/**
* @param Context $context
* @param PageFactory $resultPageFactory
* @param LogCollectionFactory $logCollectionFactory
* @param Logger $logger
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
Clean $clean,
Logger $logger
private Clean $clean
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
$this->clean = $clean;
$this->logger = $logger;
}

/**
* @inheritDoc
*/
public function execute()
public function execute(): Redirect
{
try {
$this->clean->cleanAll();
} catch (Exception $exception) {
$this->logger->error(__('Cant delete webapi log because of error: %1', $exception->getMessage()));
} catch (Exception $e) {
$this->messageManager->addExceptionMessage($e);
}

$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('*/*/index', ['_current' => true]);
return $this->resultRedirectFactory->create()->setPath('*/*/index', ['_current' => true]);
}
}
36 changes: 10 additions & 26 deletions Controller/Adminhtml/Reports/Detail.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
<?php
/*
* Copyright © Ghost Unicorns snc. All rights reserved.
* See LICENSE for license details.
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/

declare(strict_types=1);

namespace GhostUnicorns\WebapiLogs\Controller\Adminhtml\Reports;
namespace Opengento\WebapiLogger\Controller\Adminhtml\Reports;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;

class Detail extends Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
*/
const ADMIN_RESOURCE = 'GhostUnicorns_WebapiLogs::reports_webapilogs';
public const ADMIN_RESOURCE = 'Opengento_WebapiLogger::reports_webapilogs';

/**
* @var bool|PageFactory
*/
protected $resultPageFactory = false;

/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
private PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}

/**
* @return Page|ResultInterface
*/
public function execute()
public function execute(): Page
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('GhostUnicorns_WebapiLogs::reports');
$resultPage->setActiveMenu('Opengento_WebapiLogger::reports');
$resultPage->getConfig()->getTitle()->prepend(__('Webapi REST api logs'));

return $resultPage;
}
}
36 changes: 10 additions & 26 deletions Controller/Adminhtml/Reports/Index.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,36 @@
<?php
/*
* Copyright © Ghost Unicorns snc. All rights reserved.
* See LICENSE for license details.
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/

declare(strict_types=1);

namespace GhostUnicorns\WebapiLogs\Controller\Adminhtml\Reports;
namespace Opengento\WebapiLogger\Controller\Adminhtml\Reports;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;

class Index extends Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
*/
const ADMIN_RESOURCE = 'GhostUnicorns_WebapiLogs::reports_webapilogs';
public const ADMIN_RESOURCE = 'Opengento_WebapiLogger::reports_webapilogs';

/**
* @var bool|PageFactory
*/
protected $resultPageFactory = false;

/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
private PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}

/**
* @return Page|ResultInterface
*/
public function execute()
public function execute(): Page
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('GhostUnicorns_WebapiLogs::reports');
$resultPage->setActiveMenu('Opengento_WebapiLogger::reports');
$resultPage->getConfig()->getTitle()->prepend(__('Webapi REST api logs'));

return $resultPage;
}
}
32 changes: 10 additions & 22 deletions Cron/CleanCron.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
<?php
/*
* Copyright © Ghost Unicorns snc. All rights reserved.
* See LICENSE for license details.
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/

declare(strict_types=1);

namespace GhostUnicorns\WebapiLogs\Cron;
namespace Opengento\WebapiLogger\Cron;

use Exception;
use GhostUnicorns\WebapiLogs\Model\Clean;
use Magento\Framework\Exception\LocalizedException;
use Opengento\WebapiLogger\Model\Clean;

class CleanCron
{
/**
* @var Clean
*/
private $clean;

/**
* @param Clean $clean
*/
public function __construct(
Clean $clean
) {
$this->clean = $clean;
}
public function __construct(private Clean $clean) {}

/**
* @throws Exception
* @throws LocalizedException
*/
public function execute()
public function execute(): void
{
$this->clean->execute();
$this->clean->clean();
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Ghost Unicorns snc di Ugolini Riccardo e Argentiero Danilo
Copyright (c) OpenGento

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit dba9c17

Please sign in to comment.