/** * Tests the initialization with the default configuration * * @see ConfigurationRegistry::classConstructor() */ public function testInitWithDefaultConfiguration() { ConfigurationRegistry::classConstructor(); $configuration = ConfigurationRegistry::getConfiguration(); $this->assertInstanceOf("malkusch\\bav\\DefaultConfiguration", $configuration); $this->assertNotEquals("test", $configuration->getTempDirectory()); }
/** * Shut down hook for applying the update plan. */ public function applyUpdatePlan(DataBackend $backend) { $plan = ConfigurationRegistry::getConfiguration()->getUpdatePlan(); if ($plan != null && $plan->isOutdated($backend)) { $plan->perform($backend); } }
/** * Inject the configuration. */ public function __construct(Configuration $configuration = null) { if (is_null($configuration)) { $configuration = ConfigurationRegistry::getConfiguration(); } $this->configuration = $configuration; }
/** * Inject the configuration. * * If the $configuration is null the configuration from * {@link ConfigurationRegistry::getConfiguration()} will be used. * * @see ConfigurationRegistry */ public function __construct(Configuration $configuration = null) { if (is_null($configuration)) { $configuration = ConfigurationRegistry::getConfiguration(); } $this->configuration = $configuration; $this->backend = $configuration->getDataBackendContainer()->getDataBackend(); $this->contextValidation = new ContextValidation($this->backend); }
/** * Tests automatic installation. */ public function testAutomaticUpdate() { $updatePlan = new AutomaticUpdatePlan(); $updatePlan->setNotice(false); ConfigurationRegistry::getConfiguration()->setUpdatePlan($updatePlan); $fileUtil = new FileUtil(); $container = new FileDataBackendContainer(tempnam($fileUtil->getTempDirectory(), 'bavtest')); $backend = $container->getDataBackend(); touch($backend->getFile(), strtotime("-1 year")); $this->assertTrue($updatePlan->isOutdated($backend)); $container->applyUpdatePlan($backend); $this->assertFalse($updatePlan->isOutdated($backend)); $backend->uninstall(); ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); }
/** * @param String $file The data source */ public function __construct($file = null) { $defaultFile = __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "banklist.txt"; $this->file = is_null($file) ? $defaultFile : $file; $this->encoding = ConfigurationRegistry::getConfiguration()->getEncoding(); }
<?php /** * BAV installer for the Bundesbank bank data file. * * @author Markus Malkusch <*****@*****.**> * @license WTFPL * @see DataBackend */ namespace malkusch\bav; require_once __DIR__ . "/../autoloader/autoloader.php"; try { ConfigurationRegistry::getConfiguration()->setAutomaticInstallation(false); $databack = ConfigurationRegistry::getConfiguration()->getDatabackendContainer()->getDataBackend(); $databack->install(); echo "Bundesbank file downloaded.\n"; } catch (DataBackendException $error) { die("Installation failed: {$error->getMessage()}\n"); }
#!/bin/env php <?php /** * Removes the Bundesbank file. * * @author Markus Malkusch <*****@*****.**> * @license WTFPL * @see DataBackend */ namespace malkusch\bav; require_once __DIR__ . "/../autoloader/autoloader.php"; try { $configuration = ConfigurationRegistry::getConfiguration(); $configuration->setAutomaticInstallation(false); $configuration->setUpdatePlan(null); $databack = $configuration->getDatabackendContainer()->getDataBackend(); $databack->uninstall(); echo "Bundesbank file removed.\n"; } catch (DataBackendException $error) { die("Deinstallation failed: {$error->getMessage()}\n"); }
#!/bin/env php <?php /** * BAV updater for the Bundesbank bank data file. * * @author Markus Malkusch <*****@*****.**> * @license WTFPL * @see DataBackend */ namespace malkusch\bav; require_once __DIR__ . "/../autoloader/autoloader.php"; try { ConfigurationRegistry::getConfiguration()->setUpdatePlan(null); $bav = new BAV(); $bav->update(); echo "Bundesbank file downloaded.\n"; } catch (DataBackendException $error) { die("Installation failed: {$error->getMessage()}\n"); }