Nested Modules And Name Conflicts

I have a few modules that contain child modules with conflicting moduleIds.


    'modules'=>array(

      'productA'=>array(

        'currentVersion'=>2,

        'modules'=>array('v1', 'v2'),

      ),

      'productB'=>array(

        'currentVersion'=>2,

        'modules'=>array('v1', 'v2'),

      ),

      'productC'=>array(

        'currentVersion'=>1,

        'modules'=>array('v1'),

      ),

      ..

    ),

If I load productA’s v2 module everything is fine, but if try to load up productB’s v2 module directly afterwards it seems to end up using productA’s v2 module (and ends up returning the wrong DataModel via getNewDataModel()).

This is the method I use in the product modules to load the correct version:


  public function getNewDataModel($version = null)

  {

    if ($version == null)

      $version = 'v' . $this->currentVersion;

    

    return $this->getModule($version)->getNewDataModel();

  }

Could this be solved by using aliases and namespaces? I would really like to retain the naming of the version modules.


	public static function createComponent($config)

	{

		if(is_string($config))

		{

			$type=$config;

			$config=array();

		}

		elseif(isset($config['class']))

		{

			$type=$config['class'];

			unset($config['class']);

		}

		else

			throw new CException(Yii::t('yii','Object configuration must be an array containing a "class" element.'));


		if(!class_exists($type,false))

			$type=Yii::import($type,true);


		if(($n=func_num_args())>1)

		{

			$args=func_get_args();

			if($n===2)

				$object=new $type($args[1]);

			elseif($n===3)

				$object=new $type($args[1],$args[2]);

			elseif($n===4)

				$object=new $type($args[1],$args[2],$args[3]);

			else

			{

				unset($args[0]);

				$class=new ReflectionClass($type);

				// Note: ReflectionClass::newInstanceArgs() is available for PHP 5.1.3+

				// $object=$class->newInstanceArgs($args);

				$object=call_user_func_array(array($class,'newInstance'),$args);

			}

		}

		else

			$object=new $type;


		foreach($config as $key=>$value)

			$object->$key=$value;


		return $object;

	}

The point at which this becomes an issue is: $object=new $type($args[1],$args[2],$args[3]);

As $type evaluates to V2Module, which both windmitigation.v2 and fourpoint.v2 have.

bump