Friday, 1 August 2014

Using anonymous class to instantiate object


use \Domain\ModelOrder as ModelOrder;

class ClassA extends classB
{
public function __construct(Context $context = null)
{
$this->modelOrder = function ($context)
{
return new ModelOrder($context);
};

parent::__construct($context);
}

protected function test()
{
$ordermethodA = $this->modelOrder->getmethodA();

return true;
}
}