Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes/Admin/Jobs
File: NotifyMcpJob.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger\Admin\Jobs;
[2] Fix | Delete
use Hostinger\Mcp\EventHandlerFactory;
[3] Fix | Delete
use Hostinger\Mcp\Handlers\EventHandler;
[4] Fix | Delete
use PHPUnit\Exception;
[5] Fix | Delete
[6] Fix | Delete
class NotifyMcpJob extends AbstractJob implements JobInterface {
[7] Fix | Delete
[8] Fix | Delete
public const JOB_NAME = 'notify_mcp';
[9] Fix | Delete
[10] Fix | Delete
private EventHandlerFactory $event_handler_factory;
[11] Fix | Delete
[12] Fix | Delete
public function __construct( ActionScheduler $action_scheduler, EventHandlerFactory $event_handler_factory ) {
[13] Fix | Delete
$this->event_handler_factory = $event_handler_factory;
[14] Fix | Delete
parent::__construct( $action_scheduler );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public function get_name(): string {
[18] Fix | Delete
return self::JOB_NAME;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function event_handler( string $event ): EventHandler {
[22] Fix | Delete
return $this->event_handler_factory->get_handler( $event );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
public function process_items( array $args = array() ): void {
[26] Fix | Delete
$handler = $this->event_handler( $args['event'] );
[27] Fix | Delete
$handler->send( $args );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
public function schedule( array $args = array() ): void {
[31] Fix | Delete
if ( $this->can_schedule( $args ) ) {
[32] Fix | Delete
$this->action_scheduler->schedule_immediate( $this->get_process_item_hook(), array( $args ) );
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public function can_schedule( $args = array() ): bool {
[37] Fix | Delete
if ( ! parent::can_schedule( $args ) ) {
[38] Fix | Delete
return false;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
try {
[42] Fix | Delete
$handler = $this->event_handler( $args['event'] );
[43] Fix | Delete
return $handler->can_send( $args );
[44] Fix | Delete
} catch ( Exception $e ) {
[45] Fix | Delete
return false;
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function