Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:novius-os/core into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien Drouyer committed Jun 26, 2012
2 parents 200ac9d + 43a8aea commit 17cddb0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
48 changes: 39 additions & 9 deletions framework/classes/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ protected function prepare_config($old_metadata, $new_metadata)
// Load current data
$data_path = APPPATH.'data'.DS.'config'.DS;
$config = array();
foreach (array('templates', 'enhancers', 'launchers', 'models_url_enhanced') as $section)
foreach (array('templates', 'enhancers', 'launchers', 'models_url_enhanced', 'app_dependencies') as $section)
{
\Config::load($data_path.$section.'.php', 'data::'.$section);
$config[$section] = \Config::get('data::'.$section, true);
$config[$section] = \Config::get('data::'.$section, array());
}

foreach (array('templates', 'enhancers', 'launchers') as $section)
Expand Down Expand Up @@ -247,15 +247,17 @@ protected function prepare_config($old_metadata, $new_metadata)
}

// Check duplicate templates
if (!empty($added['templates'])) {
if (!empty($added['templates']))
{
$duplicates = array_intersect_key($config['templates'], $added['templates']);
if (count($duplicates) > 0)
{
throw new \Exception(count($duplicates).' templates from this application have the same name that in your local configuration: '.implode(', ', array_keys($duplicates)));
}
}

if (!empty($removed['templates'])) {
if (!empty($removed['templates']))
{
// Check template usage in the page
$pages = Model_Page::find('all', array('where' => array(array('page_template', 'IN', array_keys($removed['templates'])))));
if (count($pages) > 0)
Expand All @@ -265,7 +267,8 @@ protected function prepare_config($old_metadata, $new_metadata)
}

// Check duplicate launchers
if (!empty($added['launchers'])) {
if (!empty($added['launchers']))
{
$duplicates = array_intersect_key($config['launchers'], $added['launchers']);
if (count($duplicates) > 0)
{
Expand All @@ -274,7 +277,8 @@ protected function prepare_config($old_metadata, $new_metadata)
}

// Check duplicate enhancers
if (!empty($added['enhancers'])) {
if (!empty($added['enhancers']))
{
$duplicates = array_intersect_key($config['enhancers'], $added['enhancers']);
if (count($duplicates) > 0)
{
Expand All @@ -285,7 +289,6 @@ protected function prepare_config($old_metadata, $new_metadata)
// Update actual configuration
foreach (array('templates', 'enhancers', 'launchers') as $section)
{

// Update
$updated = array_intersect_key($new_metadata[$section], $old_metadata[$section]);
foreach ($updated as $k => $v)
Expand All @@ -310,8 +313,35 @@ protected function prepare_config($old_metadata, $new_metadata)
{
foreach ($enhancer['models_url_enhanced'] as $model)
{
$remove = array_search($key, $config['models_url_enhanced'][$model]);
unset($config['models_url_enhanced'][$model][$remove]);
foreach (array_keys($config['models_url_enhanced'][$model], $key) as $remove)
{
unset($config['models_url_enhanced'][$model][$remove]);
}
}
}

$old_dependency = \Arr::get($old_metadata, 'extends', '');
$new_dependency = \Arr::get($new_metadata, 'extends', '');

if ($old_dependency != $new_dependency)
{
// Add new dependency
if ($new_dependency != '')
{
if (empty($config['app_dependencies'][$new_dependency]))
{
$config['app_dependencies'][$new_dependency] = array();
}
$config['app_dependencies'][$new_dependency][] = $this->folder;
}

// Remove old dependency
if (!empty($config['app_dependencies'][$old_dependency]))
{
foreach (array_keys($config['app_dependencies'][$old_dependency], $this->folder) as $key)
{
unset($config['app_dependencies'][$old_dependency][$key]);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions framework/classes/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ protected static function getLocation() {
protected static function loadConfiguration($module_name, $file_name) {
\Config::load($module_name.'::'.$file_name, true);
$config = \Config::get($module_name.'::'.$file_name);
\Config::load(APPPATH.'data'.DS.'config'.DS.'app_dependencies.php', true);
$dependencies = \Config::get(APPPATH.'data'.DS.'config'.DS.'app_dependencies.php', array());
\Config::load(APPPATH.'data'.DS.'config'.DS.'app_dependencies.php', 'data::app_dependencies');
$dependencies = \Config::get('data::app_dependencies', array());

if (!empty($dependencies[$module_name])) {
foreach ($dependencies[$module_name] as $dependency) {
Expand Down
8 changes: 4 additions & 4 deletions framework/classes/fuel/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public static function load($module, $path = null)
}

// Load dependent applications
Config::load(APPPATH.'data'.DS.'config'.DS.'app_dependencies.php', true);
$dependencies = Config::get('app_dependencies', array());
Config::load(APPPATH.'data'.DS.'config'.DS.'app_dependencies.php', 'data::app_dependencies');
$dependencies = Config::get('data::app_dependencies', array());
if (!empty($dependencies[$module])) {
foreach ($dependencies[$module] as $module) {
static::load($module);
foreach ($dependencies[$module] as $dependence) {
static::load($dependence);
}
}
}
Expand Down

0 comments on commit 17cddb0

Please sign in to comment.