All pastes #765786 Raw Edit

Unbenannt

public text v1 · immutable
·published 2007-11-08 10:46 UTC
rendered paste body
<?php

class a
{
	private $items = array();
	
	public function __construct()
	{
		$this->setItems();
	}
	
	private function setItems()
	{
		$items = array(
						0 => 'c',
						1 => 'd',
				 );
		foreach ( $items as $k => $v )
		{
			$class = b::getInstance( $v );
			
			
			
			$this->items[ $k ] = $class;
		}
	}
	
}

class b
{
	private $anchecstor = null;
	
	public function __construct()
	{
		
	}
	
	static public function getInstance( $type )
	{
		$classname = 'lib_item_' . $type;
		
		if ( $itemclass = new $classname( ) )
		{
			return $itemclass;
		}
	}

	/* want to remove...*/
	public function setAnchestor( $obj )
	{
		$this->anchstor = $obj;
	}
	
	public function getItemName()
	{
		/*here i need infomations about the top-level-object*/
		
		return $this->anchestor->getParam('name') . 'i' . $this->getParam('name');
	}
	
}

class b_c extends b
{
	public function __construct()
	{
		parent::__construct();
	}
}

class b_d extends b 
{
	public function __construct()
	{
		parent::__construct();
	}
}

?>