- WIP on Task scheduling interface
This commit is contained in:
parent
586f2344df
commit
5a737c06c4
|
@ -45,7 +45,7 @@ namespace Negundo\Client {
|
|||
|
||||
namespace {
|
||||
if (! function_exists('ntask') ) {
|
||||
function ntask(string $message, ? string $title = null, ? array $data = null) {
|
||||
function ntask(string $message, ? string $title = null, ? array $data = null, ? Negundo\Client\Task\StatusEnum $status = null) {
|
||||
foreach (\Negundo\Client\Task::$instances as $instance) {
|
||||
$sent = $instance->newReport($message, $title, $data);
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Negundo\Client\Task;
|
||||
|
||||
enum StatusEnum : string
|
||||
{
|
||||
case Completed = "completed";
|
||||
case Failed = "failed";
|
||||
case Warning = "warning";
|
||||
}
|
|
@ -26,12 +26,19 @@ class Curl implements TransportInterface {
|
|||
|
||||
$exec = curl_exec($ch);
|
||||
|
||||
if ( ( false === $exec ) && $this->throwErrors ) {
|
||||
$code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||
|
||||
if ($this->throwErrors) {
|
||||
if ( false === $exec) {
|
||||
$errno = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
|
||||
throw new CurlException(implode(PHP_EOL, array_filter([ curl_error($ch) , static::CURL_ERROR[$errno] ?? null ])), $errno);
|
||||
}
|
||||
elseif ($code >= 400) {
|
||||
throw new \Exception(sprintf("HTTP code received : $code with page content : %s", $exec));
|
||||
}
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class TaskHandler {
|
|||
$this->dataManipulator->run($post);
|
||||
}
|
||||
|
||||
$post['data'] = json_encode($post['data'] ?? null);
|
||||
$post['data'] = json_encode($post['data'] ?? null, JSON_INVALID_UTF8_IGNORE);
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue