partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6732087a1d9447abdfcbd09599d319051db51fdd
parent 4af27b8e5e7b6011e1dc6552c78a14146831b3b3
Author: Felicitus <felicitus@felicitus.org>
Date:   Mon,  3 Aug 2015 17:44:03 +0200

Refactored configuration parser to the core bundle, added configuration option to disable the cronjob check

Diffstat:
Mapp/config/partkeepr.yml | 1+
Asrc/PartKeepr/CoreBundle/DependencyInjection/Configuration.php | 36++++++++++++++++++++++++++++++++++++
Msrc/PartKeepr/CoreBundle/DependencyInjection/PartKeeprCoreExtension.php | 15+++++++++++++++
Msrc/PartKeepr/CoreBundle/PartKeeprCoreBundle.php | 6+++++-
Msrc/PartKeepr/CoreBundle/Resources/config/services.xml | 1+
Msrc/PartKeepr/CoreBundle/Services/SystemService.php | 19++++++++++---------
Msrc/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js | 14+++++++-------
Dsrc/PartKeepr/ImageBundle/DependencyInjection/Configuration.php | 33---------------------------------
Dsrc/PartKeepr/ImageBundle/DependencyInjection/PartKeeprExtension.php | 35-----------------------------------
Asrc/PartKeepr/ImageBundle/DependencyInjection/PartKeeprImageExtension.php | 19+++++++++++++++++++
Msrc/PartKeepr/ImageBundle/PartKeeprImageBundle.php | 5-----
11 files changed, 94 insertions(+), 90 deletions(-)

diff --git a/app/config/partkeepr.yml b/app/config/partkeepr.yml @@ -1,5 +1,6 @@ partkeepr: image_cache_directory: %kernel.cache_dir%/imagecache/ + cronjob_check: false directories: iclogo: %kernel.root_dir%/../data/images/iclogo/ temp: %kernel.root_dir%/../data/temp/ diff --git a/src/PartKeepr/CoreBundle/DependencyInjection/Configuration.php b/src/PartKeepr/CoreBundle/DependencyInjection/Configuration.php @@ -0,0 +1,36 @@ +<?php +namespace PartKeepr\CoreBundle\DependencyInjection; + +use Symfony\Component\Config\Definition\Builder\TreeBuilder; +use Symfony\Component\Config\Definition\ConfigurationInterface; + +class Configuration implements ConfigurationInterface +{ + /** + * {@inheritdoc} + */ + public function getConfigTreeBuilder() + { + $treeBuilder = new TreeBuilder(); + $rootNode = $treeBuilder->root('partkeepr'); + + $rootNode-> + children() + ->scalarNode('image_cache_directory') + ->cannotBeEmpty() + ->isRequired() + ->info('The image cache directory') + ->end() + ->arrayNode('directories') + ->prototype('scalar') + ->end() + ->end() + ->booleanNode('cronjob_check') + ->defaultTrue() + ->info('Whether the system should check if cronjobs are running or not') + ->end() + ->end(); + + return $treeBuilder; + } +} diff --git a/src/PartKeepr/CoreBundle/DependencyInjection/PartKeeprCoreExtension.php b/src/PartKeepr/CoreBundle/DependencyInjection/PartKeeprCoreExtension.php @@ -19,7 +19,22 @@ class PartKeeprCoreExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { + $configuration = new Configuration(); + $config = $this->processConfiguration($configuration, $configs); + + $container->setParameter('partkeepr.cronjob_check', $config['cronjob_check']); + $container->setParameter('partkeepr.image_cache_directory', $config['image_cache_directory']); + + foreach ($config["directories"] as $key => $value) { + $container->setParameter("partkeepr.directories.".$key, $value); + } + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); } + + public function getAlias() + { + return "partkeepr"; + } } diff --git a/src/PartKeepr/CoreBundle/PartKeeprCoreBundle.php b/src/PartKeepr/CoreBundle/PartKeeprCoreBundle.php @@ -1,9 +1,13 @@ <?php namespace PartKeepr\CoreBundle; +use PartKeepr\CoreBundle\DependencyInjection\PartKeeprCoreExtension; use Symfony\Component\HttpKernel\Bundle\Bundle; class PartKeeprCoreBundle extends Bundle { - + public function getContainerExtension() + { + return new PartKeeprCoreExtension(); + } } diff --git a/src/PartKeepr/CoreBundle/Resources/config/services.xml b/src/PartKeepr/CoreBundle/Resources/config/services.xml @@ -7,6 +7,7 @@ <services> <service id="partkeepr_systemservice" class="PartKeepr\CoreBundle\Services\SystemService"> <argument type="service" id="doctrine"/> + <argument type="service" id="service_container"/> </service> </services> diff --git a/src/PartKeepr/CoreBundle/Services/SystemService.php b/src/PartKeepr/CoreBundle/Services/SystemService.php @@ -10,18 +10,21 @@ use PartKeepr\CronLogger\CronLoggerManager; use PartKeepr\PartKeepr; use PartKeepr\Util\Configuration; use Doctrine\ORM\Version as ORMVersion; -use Doctrine\DBAL\Version as DBLAVersion; +use Doctrine\DBAL\Version as DBALVersion; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerAware; -class SystemService +class SystemService extends ContainerAware { /** * @var EntityManager */ private $entityManager; - public function __construct(Registry $doctrine) + public function __construct(Registry $doctrine, Container $container) { $this->entityManager = $doctrine->getManager(); + $this->setContainer($container); } /** @@ -37,7 +40,7 @@ class SystemService $aData = array(); $aData[] = new SystemInformationRecord("Doctrine ORM", ORMVersion::VERSION, "Libraries"); - $aData[] = new SystemInformationRecord("Doctrine DBAL", DBLAVersion::VERSION, "Libraries"); + $aData[] = new SystemInformationRecord("Doctrine DBAL", DBALVersion::VERSION, "Libraries"); $aData[] = new SystemInformationRecord("PHP Version", phpversion(), "System"); @@ -83,15 +86,13 @@ class SystemService */ public function getSystemStatus() { - - if (Configuration::getOption("partkeepr.cronjobs.disablecheck", false) === true) { + if ($this->container->getParameter("partkeepr.cronjob_check")) { + $inactiveCronjobs = CronLoggerManager::getInstance()->getInactiveCronjobs(); + } else { // Skip cronjob tests $inactiveCronjobs = array(); - } else { - $inactiveCronjobs = CronLoggerManager::getInstance()->getInactiveCronjobs(); } - return array( "inactiveCronjobCount" => count($inactiveCronjobs), "inactiveCronjobs" => $inactiveCronjobs, diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js b/src/PartKeepr/FrontendBundle/Resources/public/js/PartKeepr.js @@ -215,7 +215,7 @@ Ext.application({ { model: 'PartKeepr.FootprintBundle.Entity.Footprint', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.siPrefixStore = Ext.create("Ext.data.Store", @@ -229,35 +229,35 @@ Ext.application({ { model: 'PartKeepr.DistributorBundle.Entity.Distributor', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.manufacturerStore = Ext.create("Ext.data.Store", { model: 'PartKeepr.ManufacturerBundle.Entity.Manufacturer', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.partUnitStore = Ext.create("Ext.data.Store", { model: 'PartKeepr.PartBundle.Entity.PartMeasurementUnit', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.unitStore = Ext.create("Ext.data.Store", { model: 'PartKeepr.UnitBundle.Entity.Unit', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.userStore = Ext.create("Ext.data.Store", { model: 'PartKeepr.AuthBundle.Entity.User.User', pageSize: 99999999, - autoLoad: false + autoLoad: true }); this.tipOfTheDayStore = Ext.create("Ext.data.Store", @@ -350,7 +350,7 @@ Ext.application({ return this.distributorStore; }, getDefaultPartUnit: function () { - return this.partUnitStore.findRecord("default", true); + return this.partUnitStore.findRecord("isDefault", true); }, getUserStore: function () { return this.userStore; diff --git a/src/PartKeepr/ImageBundle/DependencyInjection/Configuration.php b/src/PartKeepr/ImageBundle/DependencyInjection/Configuration.php @@ -1,33 +0,0 @@ -<?php -namespace PartKeepr\ImageBundle\DependencyInjection; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - - -/** - * This is the class that validates and merges configuration from your app/config files - * - * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} - */ -class Configuration implements ConfigurationInterface -{ - /** - * {@inheritdoc} - */ - public function getConfigTreeBuilder() - { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('partkeepr'); - - $rootNode-> - children() - ->scalarNode('image_cache_directory')->cannotBeEmpty()->isRequired()->info('The image cache directory')->end() - ->arrayNode('directories') - ->prototype('scalar')->end() - ->end() - ->end(); - - return $treeBuilder; - } -} diff --git a/src/PartKeepr/ImageBundle/DependencyInjection/PartKeeprExtension.php b/src/PartKeepr/ImageBundle/DependencyInjection/PartKeeprExtension.php @@ -1,34 +0,0 @@ -<?php -namespace PartKeepr\ImageBundle\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\Loader; - -class PartKeeprExtension extends Extension -{ - /** - * {@inheritDoc} - */ - public function load(array $configs, ContainerBuilder $container) - { - $configuration = new Configuration(); - $config = $this->processConfiguration($configuration, $configs); - - $container->setParameter('partkeepr.image_cache_directory', $config['image_cache_directory']); - - foreach ($config["directories"] as $key => $value) { - $container->setParameter("partkeepr.directories.".$key, $value); - } - - $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.xml'); - - } - - public function getAlias() - { - return "partkeepr"; - } -}- \ No newline at end of file diff --git a/src/PartKeepr/ImageBundle/DependencyInjection/PartKeeprImageExtension.php b/src/PartKeepr/ImageBundle/DependencyInjection/PartKeeprImageExtension.php @@ -0,0 +1,19 @@ +<?php +namespace PartKeepr\ImageBundle\DependencyInjection; + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Loader; + +class PartKeeprImageExtension extends Extension +{ + /** + * {@inheritDoc} + */ + public function load(array $configs, ContainerBuilder $container) + { + $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('services.xml'); + } +} diff --git a/src/PartKeepr/ImageBundle/PartKeeprImageBundle.php b/src/PartKeepr/ImageBundle/PartKeeprImageBundle.php @@ -1,13 +1,8 @@ <?php namespace PartKeepr\ImageBundle; -use PartKeepr\ImageBundle\DependencyInjection\PartKeeprExtension; use Symfony\Component\HttpKernel\Bundle\Bundle; class PartKeeprImageBundle extends Bundle { - public function getContainerExtension() - { - return new PartKeeprExtension(); - } }