BRICKOO::GetObject  (since version 2.0)
Syntax
object GetObject (  string $objectName [, array $arguments = null [, array $decorators = null ]] )
Parameters
objectName
The name of the object to retrieve the reference from.
arguments
The arguments to pass to the object constructor method.
decorators
The decorators to bind to the reference.
Each decorator can have an array with array args and string type to pass constructor arguments or the decorator type.
Description
Returns an reference of the requested object.
Passes the arguments to the constructor of the created reference.
Binds requested decorators to the object reference.

With BrickOO you do not have to chain classes to extend functionality, instead you can bind and unbind decorators to an new or existing reference at any time.
Return
object Returns an reference of the object requested.
Examples
<?php


class person
{

    public 
$name;

    public 
$age;

    public function 
__construct($name$age)
    {
        
$this->name  $name;
        
$this->age      $age;
    }

    public function 
getInformation()
    {
        return 
$this->name ' is ' $this->age ' years old and lives in the ' .$this->getStreet() . ', ' $this->getCity();
    }

}

class 
adress
{
    public 
$city;

    public function 
getCity()
    {
        return 
$this->city;
    }

    public function 
setCity($city)
    {
        
$this->city $city;
    }

    public 
$street;

    public function 
getStreet()
    {
        return 
$this->street;
    }

    public function 
setStreet($street)
    {
        
$this->street $street;
    }
}

// retrieve person reference and bind adress as decorator
$person BRICKOO::GetObject('person', array('mike'20), array('adress' => array('type' => BRICKOO::DECORATOR_SINGLE )));

$person->setStreet('Wallstreet');
$person->setCity('New York');

$information $person->getInformation();
echo(
$information);

?>

Output:
mike is 20 years old an lives in the Wallstreet, New York


Last change 10/15/2009




Administration