[TYPO3-team-core-v5] RFC: ComponentFactory

Malte Jansen mail at maltejansen.de
Mon Oct 6 12:35:40 CEST 2008


Malte Jansen schrieb:
> So I have just extendend the normal factory. So I have access to the 
> isComponentRegistered(). But sometimes the an extra class is to much.
> 
> Just for getting an idea.
> 
> class ComponentFactory extends F3::FLOW3::Component::Factory {
>     public function getTokenComponentByElementType($elementType) {
>         switch ($elementType) {
>             case 'Interface':
>                 $elementType = 'IClass';
>                 break;
>             case 'Abstract class':
>                 $elementType = 'AClass';
>                 break;
>         }
>         $componentName = 'F3::FLOW3CGL::DocComment::Elements::' . 
> ucfirst($elementType) . 'Element';
>         if 
> (!$this->compoinentManager->isComponentRegistered($componentName)) {
>             throw new 
> F3::FLOW3CGL::DocComment::Exception::UnknownTagComponent('Component "' . 
> $componentName . '" is not registered.', 1222723005);
>         }
>         return parent::getComponent($componentName);
>     }
> }

Hi,

just a notice:

You cannot create you own Component factory like above.
Because in each class, where you use the new ComponentFactory an error 
occurs:

~\Packages\FLOW3\Classes\Component\F3_FLOW3_Component_ObjectBuilder.php:271
Component "F3::FLOW3::Component::ObjectCacheInterface" is not registered.

Cheers,

Malte


More information about the TYPO3-team-core-v5 mailing list