mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
Add logger
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use \Monolog\Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
@@ -31,7 +33,7 @@ class task_manager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTasks($refresh = false)
|
public function getTasks($refresh = false, Logger $logger = null)
|
||||||
{
|
{
|
||||||
if ($this->tasks && ! $refresh) {
|
if ($this->tasks && ! $refresh) {
|
||||||
return $this->tasks;
|
return $this->tasks;
|
||||||
@@ -39,6 +41,10 @@ class task_manager
|
|||||||
|
|
||||||
$core = \bootstrap::getCore();
|
$core = \bootstrap::getCore();
|
||||||
|
|
||||||
|
if ( ! $logger) {
|
||||||
|
$logger = $core['monolog'];
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
||||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
$stmt = $this->appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -55,7 +61,7 @@ class task_manager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$tasks[$row['task_id']] = new $classname($row['task_id'], $core['monolog']);
|
$tasks[$row['task_id']] = new $classname($row['task_id'], $logger);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -71,9 +77,15 @@ class task_manager
|
|||||||
* @param int $task_id
|
* @param int $task_id
|
||||||
* @return task_abstract
|
* @return task_abstract
|
||||||
*/
|
*/
|
||||||
public function getTask($task_id)
|
public function getTask($task_id, Logger $logger = null)
|
||||||
{
|
{
|
||||||
$tasks = $this->getTasks();
|
$core = \bootstrap::getCore();
|
||||||
|
|
||||||
|
if ( ! $logger) {
|
||||||
|
$logger = $core['monolog'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tasks = $this->getTasks($logger);
|
||||||
|
|
||||||
if ( ! isset($tasks[$task_id])) {
|
if ( ! isset($tasks[$task_id])) {
|
||||||
throw new Exception_NotFound('Unknown task_id ' . $task_id);
|
throw new Exception_NotFound('Unknown task_id ' . $task_id);
|
||||||
|
Reference in New Issue
Block a user