mirror of
https://github.com/friendica/friendica
synced 2025-04-26 05:10:11 +00:00
Refactor Process for new paradigm
This commit is contained in:
parent
0e2e488521
commit
38f70cc55a
14 changed files with 456 additions and 491 deletions
38
src/Core/Worker/Factory/Process.php
Normal file
38
src/Core/Worker/Factory/Process.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue