[Flow] Constructor injection and IDE

Mathis Hoffmann mathis at hoffpost.de
Sat Aug 10 12:49:17 CEST 2013


Hey another Christian,

thank you. Then I will try to set the locale accordingly.

Cheers
Mathis

Am 10.08.2013 09:20, schrieb Christian Müller:
>
>
> Mathis Hoffmann wrote:
>> Hey Christian,
>
> Hi Mathis,
> another Christian here ;)
>
>>
>> I have just two other questions :)
>> 1.) Is there a possibility to configure the datetime-format for the
>> DateTimeConverter globally? I don't want to do all that configuration
>> stuff in every controller. What I did now and what does work for me is
>> that I wrote mit own converter and gave it a higher priority than the
>> default one. But maybe there is an easier solution?
>
> That is the easiest solution for now, there is no hidden configuration 
> option you missed.
>
>> 2.) I have the same problem with the float converter. I currently only
>> accepts numbers like 13.87, but I want it to accept 13.87 as well as
>> 13,87 (which is the german format for that).
>>
>
> If you want to accept the format matching your locale that works 
> automatically if the right locale can be determined. But that means 
> either dots or commas as separators never both. If you want to accept 
> both you probably need to extend the float converter and adjust the 
> code to your needs.
>
>>
>> Cheers
>> Mathis
>
> Cheers,
> Christian
>
>>>
>>> Am 09.08.2013 12:21, schrieb Mathis Hoffmann:
>>>> Hello Christian,
>>>>
>>>> thanks for your quick reply!
>>>>
>>>> But what you suggest is, as I understand everything right, not
>>>> constructor injection but only dependency injection in general. This
>>>> works in most cases but not if you have a constructor that uses the
>>>> injected properties. The problem is that this "standard dependency
>>>> injection" happens after my constructor is called. So if I for
>>>> example need a repository in my own constructor and call
>>>> $respository->findAll() I get an error that tells me that I must not
>>>> call findAll() on a non object. That's why I specifically need
>>>> constructor injection in this case.
>>>>
>>>> I'm not really shure weather what I just wrote ist absolutely right.
>>>> But looking into the generated proxy class I found that the proxy
>>>> first calls my original constructor and only afterwards injects the
>>>> properties: http://pastebin.com/GG5KAy4v
>>>>
>>>> Cheers
>>>> Mathis
>>>>
>>>> Am 09.08.2013 11:14, schrieb Christian Loock:
>>>>> Am 09.08.2013 11:08, schrieb Mathis Hoffmann:
>>>>>> ng constructor parameter. I tried to set a default value
>>>>>> (__construct(..,.., \My\Injected\Type $parameter = null)) but that
>>>>>> disabled constructor injection.Does anyone have a solution for that?
>>>>> I dont understand that exactly.
>>>>>
>>>>> When you use constructor injection, you dont have to declare
>>>>> anything at you constructor at all. At least if I understood the
>>>>> concept correctly.
>>>>>
>>>>> You use constructor injection by using the Inject Annotation like 
>>>>> this:
>>>>>
>>>>> /**
>>>>> * @Flow\Inject
>>>>> * @var TYPO3\Flow\Object\ObjectManager
>>>>> protected $objectManager;
>>>>>
>>>>> You dont even need a constructor to get this work, since flow
>>>>> generates it in its proxy classes and does the injection magics in 
>>>>> it.
>>>>>
>>>>> Im not 100% sure if this works for your example, but then also I
>>>>> dont get why you dont Inject everything else that gets passed to the
>>>>> constructor.
>>>>> _______________________________________________
>>>>> Flow mailing list
>>>>> Flow at lists.typo3.org
>>>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>>>
>>>> _______________________________________________
>>>> Flow mailing list
>>>> Flow at lists.typo3.org
>>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>>
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>>
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow



More information about the Flow mailing list