[Flow] Dependency Injection and external Libraries

Christian Loock chl at vkf-renzel.de
Fri Jul 19 11:14:31 CEST 2013


Another solution would be to just keep the original method header of the 
__construct method, so it would still stay true to the interface.

Also, if there is no constructor injection, the constructor could also 
be entirly omitted. At least the generated constructor doesnt seem to do 
anything else then just calling the parent constructor:

Here both constructors:

Original:

    public function __construct($options = null)
     {
         if (null !== $options) {
             $this->setOptions($options);
         } else {
             $this->init();
         }
     }


Generated:

  public function __construct() {
                 $arguments = func_get_args();

                 if (!array_key_exists(0, $arguments)) $arguments[0] = NULL;
                 call_user_func_array('parent::__construct', $arguments);
         }


Am 19.07.2013 11:04, schrieb Christian Loock:
> Hello,
>
> I encountered an interesting problem while using Flows DI with an 
> external Library (Solarium).
>
> Some Interfaces of the Solarium Library define the __construct method. 
> However, Flow does Change the __construct methods of cached objects, 
> in the generated class. The constructor defined here does not have any 
> arguments but instead call the parents constructer with 
> call_user_func_array.
>
> This will lead into a Fatal Error, because the the generated class 
> still implements the original interface, which has a parameter 
> declared for the constructor.
>
> The only way that i managed to get this to work now, is by editing the 
> interfaces. But of course, that is nothing that i really want to do, 
> because its a third party library.
>
> There is one question and a suggestion I have now.
>
> The question is: Is there another way then changing the interface to 
> solve the problem.
>
> The sugesstion I would make to solve this, is to remove the 
> "implements" statement from the generated class. Since the generated 
> class extends the original, it should still stay true to the 
> interface, right?
>
> Thanks a lot,
>
> Christian
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list