Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pimcore 11 compat #94

Merged
merged 11 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: make API compatible
  • Loading branch information
dkarlovi committed Sep 21, 2023
commit 307b39ef3d008b1f9d30d63f2804f18b77a190d2
2 changes: 1 addition & 1 deletion src/ProcessManagerBundle/Maintenance/CronTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(ServiceRegistry $registry, MessageBusInterface $mess
$this->messageBus = $messageBus;
}

public function execute()
public function execute(): void
{
/** @var Executable $executable */
foreach ($this->getExecutables() as $executable) {
Expand Down
2 changes: 1 addition & 1 deletion src/ProcessManagerBundle/Model/Executable.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function getById($id)
/**
* @return int
*/
public function getId()
public function getId(): string|int|null
{
return $this->id;
}
Expand Down
10 changes: 0 additions & 10 deletions src/ProcessManagerBundle/Model/ExecutableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@

interface ExecutableInterface extends ResourceInterface
{
/**
* @return int
*/
public function getId();

/**
* @param int $id
*/
public function setId($id);

/**
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion src/ProcessManagerBundle/Model/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function progress($steps = 1, $message = '')
/**
* @return int
*/
public function getId()
public function getId(): string|int|null
{
return $this->id;
}
Expand Down
5 changes: 0 additions & 5 deletions src/ProcessManagerBundle/Model/ProcessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ interface ProcessInterface extends ResourceInterface
*/
public function progress($steps = 1, $message = '');

/**
* @return int
*/
public function getId();

/**
* @param int $id
*/
Expand Down
3 changes: 2 additions & 1 deletion src/ProcessManagerBundle/Monolog/ProcessHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Monolog\Handler\AbstractHandler;
use Monolog\Logger;
use Monolog\LogRecord;

class ProcessHandler extends AbstractHandler
{
Expand All @@ -32,7 +33,7 @@ public function __construct(
$this->logProcessIntoRegularLogFile = $logProcessIntoRegularLogFile;
}

public function handle(array $record): bool
public function handle(LogRecord $record): bool
{
if (!array_key_exists('process', $record['extra'])) {
return false;
Expand Down
13 changes: 7 additions & 6 deletions src/ProcessManagerBundle/Monolog/ProcessProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use CoreShop\Component\Registry\ServiceRegistryInterface;
use Monolog\Logger;
use Monolog\LogRecord;
use ProcessManagerBundle\Logger\HandlerFactoryInterface;
use ProcessManagerBundle\Model\ProcessInterface;

Expand All @@ -31,13 +32,13 @@ public function __construct(HandlerFactoryInterface $defaultHandlerFactory, Serv
$this->registry = $registry;
}

public function __invoke(array $record): array
public function __invoke(LogRecord $record): LogRecord
{
if (!isset($record['context']['process'])) {
if (!isset($record->context['process'])) {
return $record;
}

$process = $record['context']['process'];
$process = $record->context['process'];

if (!$process instanceof ProcessInterface) {
return $process;
Expand All @@ -64,11 +65,11 @@ public function __invoke(array $record): array
$log = $this->loggers[$process->getId()];
}

$record['extra']['process'] = $process;
$record->context['process'] = $process;

unset($record['context']['process']);
unset($record->context['process']);

$log->addRecord($record['level'], $record['message'], $record['context']);
$log->addRecord($record->level, $record->message, $record->context);

return $record;
}
Expand Down