diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php
index c7bb66ab61..39f5b0e6f7 100755
--- a/lib/classes/task/Scheduler.class.php
+++ b/lib/classes/task/Scheduler.class.php
@@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Application;
use Monolog\Logger;
@@ -46,20 +47,13 @@ class task_Scheduler
return $this;
}
- protected static function get_connection()
- {
- return appbox::get_instance(\bootstrap::getCore())->get_connection();
- }
-
/**
* @throws Exception if scheduler is already running
* @todo doc all possible exception
*/
public function run()
{
-
- $appbox = appbox::get_instance(\bootstrap::getCore());
- $registry = $appbox->get_registry();
+ $registry = $this->dependencyContainer['phraseanet.registry'];
//prevent scheduler to fail if GV_cli is not provided
if ( ! is_executable($registry->get('GV_cli'))) {
@@ -115,7 +109,7 @@ class task_Scheduler
$this->log(sprintf("running scheduler with method %s", $this->method));
- $conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
+ $conn = $this->dependencyContainer['phraseanet.appbox']->get_connection();
$taskPoll = array(); // the poll of tasks
@@ -124,10 +118,10 @@ class task_Scheduler
$sql = "UPDATE sitepreff SET schedstatus='started'";
$conn->exec($sql);
- $task_manager = new task_manager($appbox);
+ $task_manager = new task_manager($this->dependencyContainer);
// set every 'auto-start' task to start
- foreach ($task_manager->getTasks($this->dependencyContainer) as $task) {
+ foreach ($task_manager->getTasks() as $task) {
if ($task->isActive()) {
if ( ! $task->getPID()) {
/* @var $task task_abstract */
@@ -161,7 +155,7 @@ class task_Scheduler
sleep(1);
}
try {
- $conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
+ $conn = $this->dependencyContainer['phraseanet.appbox']->get_connection();
} catch (ErrorException $e) {
$ping = false;
}
@@ -214,7 +208,7 @@ class task_Scheduler
$taskPoll[$tkey]["todel"] = true;
}
- foreach ($task_manager->getTasks($this->dependencyContainer, true) as $task) {
+ foreach ($task_manager->getTasks(true) as $task) {
$tkey = "t_" . $task->getID();
$status = $task->getState();
diff --git a/lib/classes/task/abstract.class.php b/lib/classes/task/abstract.class.php
index 1ae76efa96..bb7cfdbc0b 100755
--- a/lib/classes/task/abstract.class.php
+++ b/lib/classes/task/abstract.class.php
@@ -107,12 +107,12 @@ abstract class task_abstract
$this->taskid = (integer) $taskid;
- phrasea::use_i18n(Session_Handler::get_locale());
+ phrasea::use_i18n($this->dependencyContainer['locale']);
$this->launched_by = array_key_exists("REQUEST_URI", $_SERVER) ? self::LAUCHED_BY_BROWSER : self::LAUCHED_BY_COMMANDLINE;
try {
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) {
$this->log($e->getMessage());
$this->log(("Warning : abox connection lost, restarting in 10 min."));
@@ -163,7 +163,7 @@ abstract class task_abstract
public function getState()
{
static $stmt = NULL;
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
if ( ! $stmt) {
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -225,7 +225,7 @@ abstract class task_abstract
throw new Exception_InvalidArgument(sprintf('unknown status `%s`', $status));
}
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET status = :status WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -241,7 +241,7 @@ abstract class task_abstract
*/
public function setActive($active)
{
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET active = :active WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -261,7 +261,7 @@ abstract class task_abstract
public function setTitle($title)
{
$title = strip_tags($title);
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET name = :title WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -289,7 +289,7 @@ abstract class task_abstract
throw new Exception_InvalidArgument('Bad XML');
}
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET settings = :settings WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -309,7 +309,7 @@ abstract class task_abstract
*/
public function resetCrashCounter()
{
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET crashed = 0 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -336,7 +336,7 @@ abstract class task_abstract
*/
public function incrementCrashCounter()
{
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET crashed = crashed + 1 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -402,7 +402,7 @@ abstract class task_abstract
$this->runner = $runner;
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET runner = :runner WHERE task_id = :taskid';
$params = array(
@@ -432,14 +432,13 @@ abstract class task_abstract
public function delete()
{
if ( ! $this->getPID()) { // do not delete a running task
- $conn = connection::getPDOConnection();
- $registry = registry::get_instance();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = "DELETE FROM task2 WHERE task_id = :task_id";
$stmt = $conn->prepare($sql);
$stmt->execute(array(':task_id' => $this->getID()));
$stmt->closeCursor();
- $lock_file = $registry->get('GV_RootPath') . 'tmp/locks/task_' . $this->getID() . '.lock';
+ $lock_file = __DIR__ . '/../../../tmp/locks/task_' . $this->getID() . '.lock';
@unlink($lock_file);
}
}
@@ -449,7 +448,7 @@ abstract class task_abstract
*/
public function setLastExecTime()
{
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET last_exec_time=NOW() WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
$stmt->execute(array(':taskid' => $this->getID()));
@@ -463,7 +462,7 @@ abstract class task_abstract
*/
public function getLastExecTime()
{
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'SELECT last_exec_time FROM task2 WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
@@ -558,9 +557,7 @@ abstract class task_abstract
*/
private function getLockfilePath()
{
- $core = \bootstrap::getCore();
-
- $lockdir = $core->getRegistry()->get('GV_RootPath') . 'tmp/locks/';
+ $lockdir = $this->dependencyContainer['phraseanet.registry']->get('GV_RootPath') . 'tmp/locks/';
$lockfilePath = ($lockdir . 'task_' . $this->getID() . '.lock');
return $lockfilePath;
@@ -849,9 +846,7 @@ abstract class task_abstract
$tid = $app['phraseanet.appbox']->get_connection()->lastInsertId();
- $core = \bootstrap::getCore();
-
- return new $class_name($tid, $app, $core['monolog']);
+ return new $class_name($tid, $app, $app['monolog']);
}
public function getUsage()
@@ -885,7 +880,7 @@ abstract class task_abstract
$p = ($todo > 0) ? ((100 * $done) / $todo) : -1;
try {
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
$sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid';
$stmt = $conn->prepare($sql);
$stmt->execute(array(
diff --git a/lib/classes/task/appboxAbstract.class.php b/lib/classes/task/appboxAbstract.class.php
index 04d5918050..a3f4c77aec 100755
--- a/lib/classes/task/appboxAbstract.class.php
+++ b/lib/classes/task/appboxAbstract.class.php
@@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
+
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -28,7 +30,7 @@ abstract class task_appboxAbstract extends task_abstract
$this->running = TRUE;
while ($this->running) {
try {
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) {
$this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -71,7 +73,7 @@ abstract class task_appboxAbstract extends task_abstract
break;
}
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
try {
$this->loadSettings(simplexml_load_string($row['settings']));
} catch (Exception $e) {
diff --git a/lib/classes/task/databoxAbstract.class.php b/lib/classes/task/databoxAbstract.class.php
index 37de46085e..db4decf3ee 100755
--- a/lib/classes/task/databoxAbstract.class.php
+++ b/lib/classes/task/databoxAbstract.class.php
@@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
+
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -32,7 +34,7 @@ abstract class task_databoxAbstract extends task_abstract
$this->running = TRUE;
while ($this->running) {
try {
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (PDOException $e) {
$this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -81,9 +83,9 @@ abstract class task_databoxAbstract extends task_abstract
}
$this->sbas_id = (int) $row['sbas_id'];
- $this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
+ $this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id, $app));
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
try {
// get the records to process
$databox = $appbox->get_databox((int) $row['sbas_id']);
diff --git a/lib/classes/task/manager.class.php b/lib/classes/task/manager.class.php
index c8502c4c4e..a0104a616d 100755
--- a/lib/classes/task/manager.class.php
+++ b/lib/classes/task/manager.class.php
@@ -9,7 +9,8 @@
* file that was distributed with this source code.
*/
-use \Monolog\Logger;
+use Alchemy\Phrasea\Core\Configuration;
+use Monolog\Logger;
use Alchemy\Phrasea\Application;
/**
@@ -24,12 +25,12 @@ class task_manager
const STATE_STARTED = 'started';
const STATE_TOSTOP = 'tostop';
- protected $appbox;
+ protected $app;
protected $tasks;
- public function __construct(appbox &$appbox)
+ public function __construct(Application $app)
{
- $this->appbox = $appbox;
+ $this->app = $app;
return $this;
}
@@ -68,18 +69,16 @@ class task_manager
public function getTasks($refresh = false, Logger $logger = null)
{
- if ($this->tasks && ! $refresh) {
+ if ($this->tasks && !$refresh) {
return $this->tasks;
}
- $core = \bootstrap::getCore();
-
- if ( ! $logger) {
- $logger = $core['monolog'];
+ if (!$logger) {
+ $logger = $this->app['monolog'];
}
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
- $stmt = $this->appbox->get_connection()->prepare($sql);
+ $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -90,11 +89,11 @@ class task_manager
$row['pid'] = NULL;
$classname = $row['class'];
- if ( ! class_exists($classname)) {
+ if (!class_exists($classname)) {
continue;
}
try {
- $tasks[$row['task_id']] = new $classname($row['task_id'], $app, $logger);
+ $tasks[$row['task_id']] = new $classname($row['task_id'], $this->app, $logger);
} catch (Exception $e) {
}
@@ -110,17 +109,15 @@ class task_manager
* @param int $task_id
* @return task_abstract
*/
- public function getTask(Application $app, $task_id, Logger $logger = null)
+ public function getTask($task_id, Logger $logger = null)
{
- $core = \bootstrap::getCore();
-
- if ( ! $logger) {
- $logger = $core['monolog'];
+ if (!$logger) {
+ $logger = $this->app['monolog'];
}
- $tasks = $this->getTasks($app, false, $logger);
+ $tasks = $this->getTasks(false, $logger);
- if ( ! isset($tasks[$task_id])) {
+ if (!isset($tasks[$task_id])) {
throw new Exception_NotFound('Unknown task_id ' . $task_id);
}
@@ -145,11 +142,11 @@ class task_manager
self::STATE_TOSTOP
);
- if ( ! in_array($status, $av_status))
+ if (!in_array($status, $av_status))
throw new Exception(sprintf('unknown status `%s` ', $status));
$sql = "UPDATE sitepreff SET schedstatus = :schedstatus, schedqtime=NOW()";
- $stmt = $this->appbox->get_connection()->prepare($sql);
+ $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute(array(':schedstatus' => $status));
$stmt->closeCursor();
@@ -158,19 +155,17 @@ class task_manager
public function getSchedulerState()
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
-
$sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay
, schedqtime AS updated_on
, schedstatus AS status FROM sitepreff";
- $stmt = $this->appbox->get_connection()->prepare($sql);
+ $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();
$ret = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$pid = NULL;
- $lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
+ $lockdir = $this->app['phraseanet.registry']->get('GV_RootPath') . 'tmp/locks/';
if (($schedlock = fopen($lockdir . 'scheduler.lock', 'a+')) != FALSE) {
if (flock($schedlock, LOCK_EX | LOCK_NB) === FALSE) {
// already locked : running !
@@ -190,7 +185,7 @@ class task_manager
if ($pid === NULL && $ret['status'] !== 'stopped') {
// auto fix
- $this->appbox->get_connection()->exec('UPDATE sitepreff SET schedstatus=\'stopped\'');
+ $this->app['phraseanet.appbox']->get_connection()->exec('UPDATE sitepreff SET schedstatus=\'stopped\'');
$ret['status'] = 'stopped';
}
$ret['pid'] = $pid;
@@ -200,17 +195,17 @@ class task_manager
public static function getAvailableTasks()
{
- $registry = registry::get_instance();
- $taskdir = array($registry->get('GV_RootPath') . "lib/classes/task/period/"
- , $registry->get('GV_RootPath') . "config/classes/task/period/"
+ $taskdir = array(
+ __DIR__ . "/period/",
+ __DIR__ . "/../../../config/classes/task/period/",
);
$tasks = array();
foreach ($taskdir as $path) {
if (($hdir = @opendir($path)) != FALSE) {
$max = 9999;
- while (($max -- > 0) && (($file = readdir($hdir)) !== false)) {
- if ( ! is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") {
+ while (($max-- > 0) && (($file = readdir($hdir)) !== false)) {
+ if (!is_file($path . '/' . $file) || substr($file, 0, 1) == "." || substr($file, -10) != ".class.php") {
continue;
}
diff --git a/lib/classes/task/period/RecordMover.class.php b/lib/classes/task/period/RecordMover.class.php
index 5b8de24c75..e7005960d2 100644
--- a/lib/classes/task/period/RecordMover.class.php
+++ b/lib/classes/task/period/RecordMover.class.php
@@ -8,6 +8,8 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
+
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -445,7 +447,7 @@ class task_period_RecordMover extends task_appboxAbstract
}
try {
- $connbas = connection::getPDOConnection($task['sbas_id']);
+ $connbas = connection::getPDOConnection($this->dependencyContainer, $task['sbas_id']);
} catch (Exception $e) {
$this->log(sprintf("can't connect sbas %s", $task['sbas_id']));
continue;
@@ -457,7 +459,7 @@ class task_period_RecordMover extends task_appboxAbstract
$tmp = array('sbas_id' => $task['sbas_id'], 'record_id' => $row['record_id'], 'action' => $task['action']);
- $rec = new record_adapter($task['sbas_id'], $row['record_id']);
+ $rec = new record_adapter($this->dependencyContainer, $task['sbas_id'], $row['record_id']);
switch ($task['action']) {
case 'UPDATE':
@@ -500,16 +502,16 @@ class task_period_RecordMover extends task_appboxAbstract
protected function processOneContent(appbox $appbox, Array $row)
{
$logsql = (int) ($this->sxTaskSettings->logsql) > 0;
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
$databox = $appbox->get_databox($row['sbas_id']);
- $rec = new record_adapter($row['sbas_id'], $row['record_id']);
+ $rec = new record_adapter($this->dependencyContainer, $row['sbas_id'], $row['record_id']);
switch ($row['action']) {
case 'UPDATE':
// change collection ?
if (array_key_exists('coll', $row)) {
- $coll = collection::get_from_coll_id($databox, $row['coll']);
+ $coll = collection::get_from_coll_id($this->dependencyContainer, $databox, $row['coll']);
$rec->move_to_collection($coll, $appbox);
if ($logsql) {
$this->log(sprintf("on sbas %s move rid %s to coll %s \n", $row['sbas_id'], $row['record_id'], $coll->get_coll_id()));
@@ -572,7 +574,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/
private function calcSQL($sxtask, $playTest = false)
{
- $appbox = appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
$sbas_id = (int) ($sxtask['sbas_id']);
@@ -741,7 +743,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/
private function calcWhere($sbas_id, &$sxtask)
{
- $connbas = connection::getPDOConnection($sbas_id);
+ $connbas = connection::getPDOConnection($this->dependencyContainer, $sbas_id);
$tw = array();
$join = '';
@@ -845,7 +847,7 @@ class task_period_RecordMover extends task_appboxAbstract
*/
private function playTest($sbas_id, $sql)
{
- $connbas = connection::getPDOConnection($sbas_id);
+ $connbas = connection::getPDOConnection($this->dependencyContainer, $sbas_id);
$result = array('rids' => array(), 'err' => '', 'n' => null);
$result['n'] = $connbas->query('SELECT COUNT(*) AS n FROM (' . $sql . ') AS x')->fetchColumn();
diff --git a/lib/classes/task/period/apibridge.class.php b/lib/classes/task/period/apibridge.class.php
index 2ac704fc91..140f45cf95 100755
--- a/lib/classes/task/period/apibridge.class.php
+++ b/lib/classes/task/period/apibridge.class.php
@@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
+
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -72,8 +74,8 @@ class task_period_apibridge extends task_appboxAbstract
protected function processOneContent(appbox $appbox, Array $row)
{
try {
- $account = Bridge_Account::load_account($appbox, $row['account_id']);
- $element = new Bridge_Element($appbox, $account, $row['id']);
+ $account = Bridge_Account::load_account($this->dependencyContainer, $row['account_id']);
+ $element = new Bridge_Element($this->dependencyContainer, $account, $row['id']);
$this->log("process " . $element->get_id() . " with status " . $element->get_status());
@@ -138,7 +140,6 @@ class task_period_apibridge extends task_appboxAbstract
*/
protected function update_element(Bridge_Element &$element)
{
- $Core = bootstrap::getCore();
$account = $element->get_account();
$connector_status = $account->get_api()->get_element_status($element);
@@ -167,7 +168,7 @@ class task_period_apibridge extends task_appboxAbstract
, 'sbas_id' => $element->get_record()->get_sbas_id()
, 'record_id' => $element->get_record()->get_record_id()
);
- $events_mngr = $Core['events-manager'];
+ $events_mngr = $this->dependencyContainer['events-manager'];
$events_mngr->trigger('__BRIDGE_UPLOAD_FAIL__', $params);
break;
diff --git a/lib/classes/task/period/archive.class.php b/lib/classes/task/period/archive.class.php
index be9dcd226c..6e616593c1 100755
--- a/lib/classes/task/period/archive.class.php
+++ b/lib/classes/task/period/archive.class.php
@@ -8,6 +8,7 @@
* file that was distributed with this source code.
*/
+use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Metadata\Tag as PhraseaTag;
use Alchemy\Phrasea\Border\Attribute as BorderAttribute;
use MediaVorus\MediaVorus;
@@ -196,7 +197,7 @@ class task_period_archive extends task_abstract
*/
public function getInterfaceHTML()
{
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
ob_start();
?>
@@ -260,13 +261,13 @@ class task_period_archive extends task_abstract
{
$this->debug = false;
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
$conn = $appbox->get_connection();
$this->sxTaskSettings = simplexml_load_string($this->settings);
$base_id = (int) ($this->sxTaskSettings->base_id);
- $this->sbas_id = \phrasea::sbasFromBas($base_id);
+ $this->sbas_id = \phrasea::sbasFromBas($this->dependencyContainer, $base_id);
if ( ! $this->sbas_id) {
$this->log('base_id unknown');
@@ -349,7 +350,7 @@ class task_period_archive extends task_abstract
$loop = 0;
while ($this->running) {
try {
- $conn = connection::getPDOConnection();
+ $conn = connection::getPDOConnection($this->dependencyContainer);
} catch (Exception $e) {
$this->log($e->getMessage());
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
@@ -497,8 +498,8 @@ class task_period_archive extends task_abstract
{
clearstatcache();
- $appbox = \appbox::get_instance(\bootstrap::getCore());
- connection::getPDOConnection();
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
+ connection::getPDOConnection($this->dependencyContainer);
$appbox->get_databox($this->sbas_id)->get_connection();
$path_in = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder)));
@@ -1407,7 +1408,7 @@ class task_period_archive extends task_abstract
*/
private function archiveGrp(\DOMDocument $dom, \DOMElement $node, $path, $path_archived, $path_error, array &$nodesToDel)
{
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
$xpath = new DOMXPath($dom);
// grp folders stay in place
@@ -1432,7 +1433,7 @@ class task_period_archive extends task_abstract
// if the .grp does not have a representative doc, let's use a generic file
if ( ! ($rep = $node->getAttribute('grp_representation'))) {
- $registry = registry::get_instance();
+ $registry = $this->dependencyContainer['phraseanet.registry'];
try {
$this->dependencyContainer['filesystem']->copy(p4string::addEndSlash($registry->get('GV_RootPath')) . 'www/skins/icons/substitution/regroup_doc.png', $genericdoc = ($path . '/group.jpg'), true);
@@ -1461,7 +1462,7 @@ class task_period_archive extends task_abstract
try {
$databox = $appbox->get_databox($this->sbas_id);
- $collection = collection::get_from_coll_id($databox, (int) $cid);
+ $collection = collection::get_from_coll_id($this->dependencyContainer, $databox, (int) $cid);
if ($captionFileName === null) {
$story = $this->createStory($collection, $path . '/' . $representationFileName, null);
} else {
@@ -1614,20 +1615,19 @@ class task_period_archive extends task_abstract
$stat1 = '0';
}
- $core = \bootstrap::getCore();
- $media = $core['mediavorus']->guess(new \SplFileInfo($pathfile));
+ $media = $this->dependencyContainer['mediavorus']->guess($pathfile);
$databox = $collection->get_databox();
$metadatasStructure = $databox->get_meta_structure();
- $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getEntity()->getMetadatas());
+ $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile));
if ($captionStatus) {
- $status = databox_status::operation_or($status, $captionStatus);
+ $status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
}
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
@@ -1635,11 +1635,11 @@ class task_period_archive extends task_abstract
$metas = $this->bagToArray($metadatasStructure, $metadatas);
- $story = record_adapter::createStory($collection);
- $story->substitute_subdef('document', $media, $this->dependencyContainer['filesystem'], $core['media-alchemyst'], $core['mediavorus']);
+ $story = record_adapter::createStory($this->dependencyContainer, $collection);
+ $story->substitute_subdef('document', $media, $this->dependencyContainer);
$story->set_metadatas($metas, true);
- $story->set_binary_status(databox_status::operation_or($stat0, $stat1));
+ $story->set_binary_status(databox_status::operation_or($this->dependencyContainer, $stat0, $stat1));
$story->rebuild_subdefs();
$story->reindex();
@@ -1678,29 +1678,28 @@ class task_period_archive extends task_abstract
$stat1 = '0';
}
- $core = \bootstrap::getCore();
- $status = databox_status::operation_or($stat0, $stat1);
+ $status = databox_status::operation_or($this->dependencyContainer, $stat0, $stat1);
- $media = $core['mediavorus']->guess(new \SplFileInfo($pathfile));
+ $media = $this->dependencyContainer['mediavorus']->guess($pathfile);
$databox = $collection->get_databox();
$metadatasStructure = $databox->get_meta_structure();
- $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getEntity()->getMetadatas());
+ $metadatas = $this->getIndexByFieldName($metadatasStructure, $media->getMetadatas());
if ($captionFile !== null && true === $this->dependencyContainer['filesystem']->exists($captionFile)) {
$caption = $this->readXMLForDatabox($metadatasStructure, $captionFile);
$captionStatus = $this->parseStatusBit(simplexml_load_file($captionFile));
if ($captionStatus) {
- $status = databox_status::operation_or($status, $captionStatus);
+ $status = databox_status::operation_or($this->dependencyContainer, $status, $captionStatus);
}
$metadatas = $this->mergeForDatabox($metadatasStructure, $metadatas, $caption);
}
$file = new \Alchemy\Phrasea\Border\File($media, $collection);
- $file->addAttribute(new BorderAttribute\Status($status));
+ $file->addAttribute(new BorderAttribute\Status($this->dependencyContainer, $status));
$file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfFilepath(), new \PHPExiftool\Driver\Value\Mono($media->getFile()->getRealPath()))));
$file->addAttribute(new BorderAttribute\Metadata(new Metadata(new PhraseaTag\TfDirname(), new \PHPExiftool\Driver\Value\Mono(dirname($media->getFile()->getRealPath())))));
@@ -1714,7 +1713,7 @@ class task_period_archive extends task_abstract
}
if ($grp_rid) {
- $file->addAttribute(new BorderAttribute\Story(new record_adapter($databox->get_sbas_id(), $grp_rid)));
+ $file->addAttribute(new BorderAttribute\Story(new record_adapter($this->dependencyContainer, $databox->get_sbas_id(), $grp_rid)));
}
$record = null;
@@ -1723,7 +1722,7 @@ class task_period_archive extends task_abstract
$record = $element;
};
- $core['border-manager']->process($this->getLazaretSession(), $file, $postProcess, $force);
+ $this->dependencyContainer['border-manager']->process($this->getLazaretSession(), $file, $postProcess, $force);
return $record;
}
@@ -1828,11 +1827,11 @@ class task_period_archive extends task_abstract
* @param integer $grp_rid
* @param array $nodesToDel out, filled with files to delete
*/
- private function archiveFileAndCaption(\DOMDOcument$dom, \DOMElement $node, \DOMElement $captionFileNode = null, $path, $path_archived, $path_error, $grp_rid, array &$nodesToDel)
+ private function archiveFileAndCaption(\DOMDocument $dom, \DOMElement $node, \DOMElement $captionFileNode = null, $path, $path_archived, $path_error, $grp_rid, array &$nodesToDel)
{
$ret = false;
- $appbox = \appbox::get_instance(\bootstrap::getCore());
+ $appbox = $this->dependencyContainer['phraseanet.appbox'];
$file = $node->getAttribute('name');
$cid = $node->getAttribute('cid');
$captionFileName = $captionFileNode ? $captionFileNode->getAttribute('name') : null;
@@ -1864,7 +1863,7 @@ class task_period_archive extends task_abstract
try {
$databox = $appbox->get_databox($this->sbas_id);
- $collection = collection::get_from_coll_id($databox, (int) $cid);
+ $collection = collection::get_from_coll_id($this->dependencyContainer, $databox, (int) $cid);
if ($captionFileName === null) {
$record = $this->createRecord($collection, $path . '/' . $file, null, $grp_rid);
@@ -2043,12 +2042,10 @@ class task_period_archive extends task_abstract
return $this->lazaretSession;
}
- $core = \bootstrap::getCore();
-
$lazaretSession = new \Entities\LazaretSession();
- $core['EM']->persist($lazaretSession);
- $core['EM']->flush();
+ $this->dependencyContainer['EM']->persist($lazaretSession);
+ $this->dependencyContainer['EM']->flush();
$this->lazaretSession = $lazaretSession;
diff --git a/lib/classes/task/period/cindexer.class.php b/lib/classes/task/period/cindexer.class.php
index 32b5cd13b6..9a88f84bdc 100755
--- a/lib/classes/task/period/cindexer.class.php
+++ b/lib/classes/task/period/cindexer.class.php
@@ -435,7 +435,7 @@ class task_period_cindexer extends task_abstract
$args_nopwd[] = '--run';
}
- $registry = registry::get_instance();
+ $registry = $this->dependencyContainer['phraseanet.registry'];
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
$this->new_status = NULL; // new status to set at the end
diff --git a/lib/classes/task/period/emptyColl.class.php b/lib/classes/task/period/emptyColl.class.php
index 4b4bb56c45..37902c42ed 100755
--- a/lib/classes/task/period/emptyColl.class.php
+++ b/lib/classes/task/period/emptyColl.class.php
@@ -48,7 +48,7 @@ class task_period_emptyColl extends task_appboxAbstract
return array();
}
- $collection = collection::get_from_base_id($this->base_id);
+ $collection = collection::get_from_base_id($this->dependencyContainer, $this->base_id);
$this->total_records = $collection->get_record_amount();
$collection->empty_collection(200);
$this->records_done += $this->total_records;
diff --git a/lib/classes/task/period/ftp.class.php b/lib/classes/task/period/ftp.class.php
index 563b0c7c45..0a230fd0d9 100755
--- a/lib/classes/task/period/ftp.class.php
+++ b/lib/classes/task/period/ftp.class.php
@@ -250,7 +250,7 @@ class task_period_ftp extends task_appboxAbstract
$sql = "SELECT id FROM ftp_export WHERE crash>=nbretry
AND date < :date";
- $params = array(':date' => phraseadate::format_mysql(new DateTime('-30 days')));
+ $params = array(':date' => $this->dependencyContainer['date-formatter']->format_mysql(new DateTime('-30 days')));
$stmt = $conn->prepare($sql);
$stmt->execute($params);
@@ -404,8 +404,8 @@ class task_period_ftp extends task_appboxAbstract
$subdef = $file['subdef'];
try {
- $sbas_id = phrasea::sbasFromBas($base_id);
- $record = new record_adapter($sbas_id, $record_id);
+ $sbas_id = phrasea::sbasFromBas($this->dependencyContainer, $base_id);
+ $record = new record_adapter($this->dependencyContainer, $sbas_id, $record_id);
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
@@ -464,12 +464,12 @@ class task_period_ftp extends task_appboxAbstract
$stmt = $conn->prepare($sql);
$stmt->execute(array(':file_id' => $file['id']));
$stmt->closeCursor();
- $this->logexport($appbox->get_session(), $record, $obj, $ftpLog);
+ $this->logexport($record, $obj, $ftpLog);
} catch (Exception $e) {
$state .= $line = sprintf(_('task::ftp:File "%1$s" (record %2$s) de la base "%3$s"' .
' (Export du Document) : Transfert cancelled (le document n\'existe plus)')
, basename($localfile), $record_id
- , phrasea::sbas_names(phrasea::sbasFromBas($base_id))) . "\n
";
+ , phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $base_id), $app)) . "\n
";
$this->logger->addDebug($line);
@@ -601,7 +601,7 @@ class task_period_ftp extends task_appboxAbstract
public function send_mails(appbox $appbox, $id)
{
$conn = $appbox->get_connection();
- $registry = registry::get_instance();
+ $registry = $this->dependencyContainer['phraseanet.registry'];
$sql = 'SELECT filename, base_id, record_id, subdef, error, done'
. ' FROM ftp_export_elements WHERE ftp_export_id = :export_id';
@@ -620,13 +620,13 @@ class task_period_ftp extends task_appboxAbstract
$transferts[] =
'