Refactor Process for new paradigm

This commit is contained in:
Philipp 2021-10-24 20:43:59 +02:00
parent 0e2e488521
commit 38f70cc55a
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
14 changed files with 456 additions and 491 deletions

View file

@ -0,0 +1,38 @@
<?php
namespace Friendica\Core\Worker\Factory;
use Friendica\BaseFactory;
use Friendica\Capabilities\ICanCreateFromTableRow;
use Friendica\Core\Worker\Entity;
class Process extends BaseFactory implements ICanCreateFromTableRow
{
public function createFromTableRow(array $row): Entity\Process
{
return new Entity\Process(
$row['pid'],
$row['command'],
new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC'))
);
}
/**
* Creates a new process entry for a given PID
*
* @param int $pid
*
* @return Entity\Process
*/
public function create(int $pid): Entity\Process
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$command = basename($trace[0]['file']);
return $this->createFromTableRow([
'pid' => $pid,
'command' => $command,
]);
}
}