Skip to content

Commit

Permalink
Added Config::implement() 3rd parameter to pass custom configuration …
Browse files Browse the repository at this point in the history
…data to support external classes configuration in compressed versions
  • Loading branch information
vitalyiegorov committed Dec 18, 2014
1 parent f0e0dae commit cd98b8a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ class Config
/**
* Assign configuration data to a module object
*
* @param string $moduleID Module identifier
* @param string $moduleID Module identifier
* @param mixed $module Pointer to a module instance to be configured
* @param array $configuration Collection of key => value configuration parameters
*/
public static function implement($moduleID, & $module)
public static function implement($moduleID, & $module, & $configuration = null)
{
// Pointer to module configuration
$configuration = & self::$data[$moduleID];
// If external configuration is not passed
if (!isset($configuration)) {
// Pointer to module configuration
$configuration = & self::$data[$moduleID];
}

// If module configuration loaded - set module params
if (isset($configuration)) {
Expand Down
14 changes: 10 additions & 4 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,16 @@ private function _setArray( $array, $viewprefix = null )
public function __set( $field, $value = NULL )
{
// This is object
if( is_object( $field ))
{
// If iModuleViewable implementor is passed
if( in_array( ns_classname('iModuleViewable','samson\core'), class_implements($field )) ) $this->_setObject( $field, $value );
if (is_object($field)) {
$implements = class_implements($field);
// If iModuleViewable implements is passed
if(
// TODO: Remove old interface support in future
in_array(ns_classname('iModuleViewable','samson\core'), $implements)
|| in_array(AutoLoader::className('IViewSettable','samson\core'), $implements)
) {
$this->_setObject( $field, $value );
}
}
// If array is passed
else if( is_array( $field ) ) $this->_setArray( $field, $value );
Expand Down

0 comments on commit cd98b8a

Please sign in to comment.