Remove use of databox singleton

This commit is contained in:
Romain Neutron
2012-07-26 12:28:41 +02:00
parent 0deed1fc7b
commit fb95aad718
20 changed files with 56 additions and 57 deletions

View File

@@ -83,9 +83,10 @@ 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));
$appbox = \appbox::get_instance(\bootstrap::getCore());
try {
// get the records to process
$databox = databox::get_instance((int) $row['sbas_id']);
$databox = $appbox->get_databox((int) $row['sbas_id']);
} catch (Exception $e) {
$this->log(sprintf('Warning : can\' connect to sbas(%s)', $row['sbas_id']));
continue;

View File

@@ -419,7 +419,8 @@ class task_period_RecordMover extends task_appboxAbstract
protected function processOneContent(appbox $appbox, Array $row)
{
$logsql = (int) ($this->sxTaskSettings->logsql) > 0;
$dbox = databox::get_instance($row['sbas_id']);
$appbox = \appbox::get_instance(\bootstrap::getCore());
$databox = $appbox->get_databox($row['sbas_id']);
$rec = new record_adapter($row['sbas_id'], $row['record_id']);
switch ($row['action']) {
@@ -427,7 +428,7 @@ class task_period_RecordMover extends task_appboxAbstract
// change collection ?
if (array_key_exists('coll', $row)) {
$coll = collection::get_from_coll_id($dbox, $row['coll']);
$coll = collection::get_from_coll_id($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()));

View File

@@ -270,7 +270,8 @@ class task_period_archive extends task_abstract
{
$this->debug = false;
$conn = \connection::getPDOConnection();
$appbox = \appbox::get_instance(\bootstrap::getCore());
$conn = $appbox->get_connection();
$this->sxTaskSettings = simplexml_load_string($this->settings);
@@ -283,7 +284,7 @@ class task_period_archive extends task_abstract
return 'tostop';
}
$databox = \databox::get_instance($this->sbas_id);
$databox = $appbox->get_databox($this->sbas_id);
$this->TColls = array();
$collection = null;
@@ -507,8 +508,9 @@ class task_period_archive extends task_abstract
{
clearstatcache();
$appbox = \appbox::get_instance(\bootstrap::getCore());
connection::getPDOConnection();
\databox::get_instance($this->sbas_id)->get_connection();
$appbox->get_databox($this->sbas_id)->get_connection();
$path_in = p4string::delEndSlash(trim((string) ($this->sxTaskSettings->hotfolder)));
if (false === $this->filesystem->exists($path_in . "/.phrasea.xml")) {
@@ -1414,6 +1416,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());
$xpath = new DOMXPath($dom);
// grp folders stay in place
@@ -1466,7 +1469,7 @@ class task_period_archive extends task_abstract
try {
$databox = \databox::get_instance($this->sbas_id);
$databox = $appbox->get_databox($this->sbas_id);
$collection = collection::get_from_coll_id($databox, (int) $cid);
if ($captionFileName === null) {
$story = $this->createStory($collection, $path . '/' . $representationFileName, null);
@@ -1838,6 +1841,7 @@ class task_period_archive extends task_abstract
{
$ret = false;
$appbox = \appbox::get_instance(\bootstrap::getCore());
$file = $node->getAttribute('name');
$cid = $node->getAttribute('cid');
$captionFileName = $captionFileNode ? $captionFileNode->getAttribute('name') : null;
@@ -1868,7 +1872,7 @@ class task_period_archive extends task_abstract
}
try {
$databox = \databox::get_instance($this->sbas_id);
$databox = $appbox->get_databox($this->sbas_id);
$collection = collection::get_from_coll_id($databox, (int) $cid);
if ($captionFileName === null) {