diff --git a/library/Class/DigitalResource/Batch.php b/library/Class/DigitalResource/Batch.php new file mode 100644 index 0000000000000000000000000000000000000000..a28357b3b937f5c2c90d0bf54badfbc49b852728 --- /dev/null +++ b/library/Class/DigitalResource/Batch.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_DigitalResource_Batch extends Class_Batch_RessourceNumerique{ + + public static function getName() { + $path = array_reverse(explode('/', dirname((new ReflectionClass(static::class))->getFileName()))); + return array_shift($path); + } + + + protected function _getService() { + $config = Class_DigitalResource_Config::getInstance(static::getName()); + $service = $config->getService(); + return new $service; + } + + + public function isEnabled() { + $config = Class_DigitalResource_Config::getInstance(static::getName()); + return $config->isEnabled(); + } +} diff --git a/library/Class/DigitalResource/Config.php b/library/Class/DigitalResource/Config.php index e8b967af36ca68994687256768ad8d63593584be..59e3aac680a1cc755475d60afdc6f58c8343354c 100644 --- a/library/Class/DigitalResource/Config.php +++ b/library/Class/DigitalResource/Config.php @@ -32,10 +32,10 @@ class Class_DigitalResource_Config extends Class_Entity { } - public static function getInstance() { + public static function getInstance($plugin = '') { return static::$_instance = static::$_instance ? static::$_instance - : (new Class_DigitalResource())->configFor(static::getName()); + : (new Class_DigitalResource())->configFor($plugin ? $plugin : static::getName()); } diff --git a/library/digital_resources/Assimil/Batch.php b/library/digital_resources/Assimil/Batch.php index 80f871cee63df64653dcb9c54890f73163a04cdd..d212dd6d6187e26cbf09d8249c7edabb6505b0c6 100644 --- a/library/digital_resources/Assimil/Batch.php +++ b/library/digital_resources/Assimil/Batch.php @@ -20,13 +20,4 @@ */ -class Assimil_Batch extends Class_Batch_RessourceNumerique{ - protected function _getService() { - return new Assimil_Service(); - } - - - public function isEnabled() { - return Assimil_Config::getInstance()->isEnabled(); - } -} +class Assimil_Batch extends Class_DigitalResource_Batch {} diff --git a/library/digital_resources/Assimil/tests/AssimilTest.php b/library/digital_resources/Assimil/tests/AssimilTest.php index e4803ba9648c128786564458acda46787e94789f..e4ed9493b9234a9fe77ebe28c6d63f189185a237 100644 --- a/library/digital_resources/Assimil/tests/AssimilTest.php +++ b/library/digital_resources/Assimil/tests/AssimilTest.php @@ -136,6 +136,14 @@ class AssimilActivatedAdminTest extends Admin_AbstractControllerTestCase { } + /** @test */ + public function batchAssimilShouldBePresent() { + $this->dispatch('/admin/batch', true); + $this->assertXPathContentContains('//tbody//tr//td', + Class_Batch::getBatchLibelle('Assimil_Batch')); + } + + /** @test */ public function userGroupPermissionsShouldContainsAssimil() { $this->dispatch('admin/usergroup/edit/id/1', true);