Re: RFC: Custom Factories (SPL)
| From: | Robert Lemke | Date: | Wed, 18 Nov 2009 17:17:55 +0000 |
| Subject: | Re: RFC: Custom Factories (SPL) | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46084@lists.php.net to get a copy of this message | ||
Hi Alexey,
Am 18.11.2009 um 17:27 schrieb Alexey Zakhlestin:
> So, from the high-level point of view, you want to introduce mechanism, which would allow
> instantiate objects by their interface, instead of their class-name.
> And this mechanism should use user-provided rules for choosing appropriate implementation.
well, using interface was just an example, we'd need the ability to instantiate classes as well
by custom factories. I tried to clarify this by an updated example:
class Foo {
public function bar() {
// Instantiate by class name:
$email = new Email();
// or even instantiate by interface name (the factory needs to find the right implementation):
$email = new EmailInterface();
}
}
So in the end the custom factory needs to find an appropriate implementation for EmailInterface.
Cheers,
robert
--
Robert Lemke
Fluent Code Artisan
http://typo3.org
http://flow3.typo3.org