diff --git a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php index 2fc03e4b70..cddc280389 100644 --- a/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php +++ b/lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php @@ -51,7 +51,7 @@ class BuildMissingSubdefs extends Command { if ($input->getOption('verbose')) { $handler = new StreamHandler('php://stdout'); - $this->container['phraseanet.core']['monolog']->pushHandler($handler); + $this->container['monolog']->pushHandler($handler); } $start = microtime(true); @@ -98,8 +98,8 @@ class BuildMissingSubdefs extends Command } if ($todo) { - $record->generate_subdefs($databox, $this->container['phraseanet.core']['monolog'], array($subdef->get_name())); - $this->container['phraseanet.core']['monolog']->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); + $record->generate_subdefs($databox, $this->container, array($subdef->get_name())); + $this->container['monolog']->addInfo("generate " . $subdef->get_name() . " for record " . $record->get_record_id()); $n ++; } } @@ -109,11 +109,11 @@ class BuildMissingSubdefs extends Command } } - $this->container['phraseanet.core']['monolog']->addInfo($n . " subdefs done"); + $this->container['monolog']->addInfo($n . " subdefs done"); $stop = microtime(true); $duration = $stop - $start; - $this->container['phraseanet.core']['monolog']->addInfo(sprintf("process took %s, (%f sd/s.)", $this->getFormattedDuration($duration), round($n / $duration, 3))); + $this->container['monolog']->addInfo(sprintf("process took %s, (%f sd/s.)", $this->getFormattedDuration($duration), round($n / $duration, 3))); return; } diff --git a/lib/Alchemy/Phrasea/Command/Command.php b/lib/Alchemy/Phrasea/Command/Command.php index 9404614285..2e1d30e405 100644 --- a/lib/Alchemy/Phrasea/Command/Command.php +++ b/lib/Alchemy/Phrasea/Command/Command.php @@ -56,7 +56,7 @@ abstract class Command extends SymfoCommand public function checkSetup() { if ($this->requireSetup()) { - if ($this->container['phraseanet.core'] && ! $this->container['phraseanet.core']->getConfiguration()->isInstalled()) { + if (!$this->container['phraseanet.configuration']->isInstalled()) { throw new \RuntimeException('Phraseanet must be set-up'); } } @@ -71,7 +71,7 @@ abstract class Command extends SymfoCommand if ($input->getOption('verbose')) { $handler = new StreamHandler('php://stdout'); - $this->container['phraseanet.core']['monolog']->pushHandler($handler); + $this->container['monolog']->pushHandler($handler); } return $this->doExecute($input, $output); diff --git a/lib/Alchemy/Phrasea/Command/CreateCollection.php b/lib/Alchemy/Phrasea/Command/CreateCollection.php index 569ed5ff34..b7f8d6eb5a 100644 --- a/lib/Alchemy/Phrasea/Command/CreateCollection.php +++ b/lib/Alchemy/Phrasea/Command/CreateCollection.php @@ -72,6 +72,6 @@ class CreateCollection extends Command } } - \User_Adapter::reset_sys_admins_rights(); + \User_Adapter::reset_sys_admins_rights($this->container); } } diff --git a/lib/Alchemy/Phrasea/Command/RecordAdd.php b/lib/Alchemy/Phrasea/Command/RecordAdd.php index 262300a15d..6fbb32ba65 100644 --- a/lib/Alchemy/Phrasea/Command/RecordAdd.php +++ b/lib/Alchemy/Phrasea/Command/RecordAdd.php @@ -69,7 +69,7 @@ class RecordAdd extends Command throw new \InvalidArgumentException(sprintf('File %s does not exists', $file)); } - $media = $this->container['phraseanet.core']['mediavorus']->guess(new \SplFileInfo($file)); + $media = $this->container['mediavorus']->guess($file); $dialog = $this->getHelperSet()->get('dialog'); @@ -87,15 +87,15 @@ class RecordAdd extends Command if ($input->getOption('in-place') !== '1') { $originalName = pathinfo($file, PATHINFO_BASENAME); $tempfile = tempnam(sys_get_temp_dir(), 'addrecord') . '.' . pathinfo($file, PATHINFO_EXTENSION); - $this->container['phraseanet.core']['monolog']->addInfo(sprintf('copy file from `%s` to temporary `%s`', $file, $tempfile)); + $this->container['monolog']->addInfo(sprintf('copy file from `%s` to temporary `%s`', $file, $tempfile)); $this->container['filesystem']->copy($file, $tempfile, true); $file = $tempfile; - $media = $this->container['phraseanet.core']['mediavorus']->guess(new \SplFileInfo($file)); + $media = $this->container['mediavorus']->guess($file); } $file = new File($media, $collection, $originalName); $session = new LazaretSession(); - $this->container['phraseanet.core']['EM']->persist($session); + $this->container['EM']->persist($session); $forceBehavior = null; @@ -118,7 +118,7 @@ class RecordAdd extends Command $elementCreated = $element; }; - $this->container['phraseanet.core']['border-manager']->process($session, $file, $callback, $forceBehavior); + $this->container['border-manager']->process($session, $file, $callback, $forceBehavior); if ($elementCreated instanceof \record_adapter) { $output->writeln( @@ -133,7 +133,7 @@ class RecordAdd extends Command } if ($tempfile) { - $this->container['phraseanet.core']['monolog']->addInfo(sprintf('Remove temporary file `%s`', $tempfile)); + $this->container['monolog']->addInfo(sprintf('Remove temporary file `%s`', $tempfile)); $this->container['filesystem']->remove($tempfile); } diff --git a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php index c8a3546b0a..df47e155a0 100644 --- a/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php +++ b/lib/Alchemy/Phrasea/Command/RescanTechnicalDatas.php @@ -84,7 +84,7 @@ class RescanTechnicalDatas extends Command foreach ($rs as $row) { $record = $databox->get_record($row['record_id']); - $record->insertTechnicalDatas(); + $record->insertTechnicalDatas($this->getService('mediavorus')); unset($record); $output->write("\r" . $n . " records done"); $n ++; diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php index 3ded7ce870..0d125d027a 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step31.php @@ -123,16 +123,16 @@ class Step31 implements DatasUpgraderInterface $uuid = \uuid::generate_v4(); try { - $media = $this->app['phraseanet.core']['mediavorus']->guess(new \SplFileInfo($pathfile)); + $media = $this->app['mediavorus']->guess($pathfile); $collection = \collection::get_from_coll_id($databox, (int) $record['coll_id']); $file = new File($media, $collection); $uuid = $file->getUUID(true, true); $sha256 = $file->getSha256(); - $this->app['phraseanet.core']['monolog']->addInfo(sprintf("Upgrading record %d with uuid %s", $record['record_id'], $uuid)); + $this->app['monolog']->addInfo(sprintf("Upgrading record %d with uuid %s", $record['record_id'], $uuid)); } catch (\Exception $e) { - $this->app['phraseanet.core']['monolog']->addError(sprintf("Uuid upgrade for record %s failed", $record['record_id'])); + $this->app['monolog']->addError(sprintf("Uuid upgrade for record %s failed", $record['record_id'])); } $sql = 'UPDATE record SET uuid = :uuid, sha256 = :sha256 WHERE record_id = :record_id'; diff --git a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php index fe0133b16c..055e5a55d1 100644 --- a/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php +++ b/lib/Alchemy/Phrasea/Command/Upgrade/Step35.php @@ -76,22 +76,22 @@ class Step35 implements DatasUpgraderInterface $stmt->execute(array(':record_id' => $row['record_id'])); try { - $record = new \record_adapter($databox->get_sbas_id(), $row['record_id']); + $record = new \record_adapter($app, $databox->get_sbas_id(), $row['record_id']); } catch (\Exception $e) { - $this->app['phraseanet.core']['monolog']->addError(sprintf("Unable to load record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $record->get_sbas_id(), $e->getMessage())); + $this->app['monolog']->addError(sprintf("Unable to load record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $record->get_sbas_id(), $e->getMessage())); continue; } try { $this->updateMetadatas($record, $row['xml']); } catch (Exception $e) { - $this->app['phraseanet.core']['monolog']->addError(sprintf("Error while upgrading metadatas for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage())); + $this->app['monolog']->addError(sprintf("Error while upgrading metadatas for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage())); } try { $record->set_binary_status($row['status']); } catch (Exception $e) { - $this->app['phraseanet.core']['monolog']->addError(sprintf("Error while upgrading status for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage())); + $this->app['monolog']->addError(sprintf("Error while upgrading status for record %d on databox %d : %s", $record->get_record_id(), $record->get_sbas_id(), $e->getMessage())); } unset($record); } diff --git a/tests/Alchemy/Phrasea/Command/UpgradeDBDatasTest.php b/tests/Alchemy/Phrasea/Command/UpgradeDBDatasTest.php index 7dc4b6eeec..0f49e55986 100644 --- a/tests/Alchemy/Phrasea/Command/UpgradeDBDatasTest.php +++ b/tests/Alchemy/Phrasea/Command/UpgradeDBDatasTest.php @@ -3,6 +3,8 @@ namespace Alchemy\Phrasea\Command; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Command\Upgrade\Step31; +use Alchemy\Phrasea\Command\Upgrade\Step35; class UpgradeDBDatasTest extends \PHPUnit_Framework_TestCase { @@ -38,7 +40,7 @@ class UpgradeDBDatasTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array(), $this->object->getUpgrades()); $upgrades = array( - new Upgrade\Step31(new Application()) + new Step31(new Application()) ); $this->object->setUpgrades($upgrades); $this->assertEquals($upgrades, $this->object->getUpgrades()); @@ -51,12 +53,12 @@ class UpgradeDBDatasTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(array(), $this->object->getUpgrades()); - $step31 = new Upgrade\Step31(new Application()); + $step31 = new Step31(new Application()); $this->object->addUpgrade($step31); $this->assertEquals(array($step31), $this->object->getUpgrades()); - $step35 = new Upgrade\Step35(new Application()); + $step35 = new Step35(new Application()); $this->object->addUpgrade($step35); $this->assertEquals(array($step31, $step35), $this->object->getUpgrades());