[FEATURE] Support @Flow\Inject annotations in Extbase 32/21732/3
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Sat, 29 Jun 2013 16:44:00 +0000 (18:44 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 2 Jul 2013 07:51:54 +0000 (09:51 +0200)
This patch provides support for the TYPO3.Flow syntax
of property injections:

/**
 * @var Vendor\Ext\FooClass
 * @Flow\Inject
 */
protected $vendorExtFooClass;

Resolves: #49497
Releases: 6.2
Change-Id: Ib5f0ff5e83580cc9c327b7320f49c5a892240eb5
Reviewed-on: https://review.typo3.org/21732
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php
typo3/sysext/extbase/Tests/Fixture/ClassWithInjectProperties.php
typo3/sysext/extbase/Tests/Unit/Object/Container/ClassInfoFactoryTest.php

index 9f5b8e7..69f51f9 100644 (file)
@@ -123,7 +123,7 @@ class ClassInfoFactory {
                if (is_array($reflectionProperties)) {
                        foreach ($reflectionProperties as $reflectionProperty) {
                                $reflectedProperty = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Reflection\\PropertyReflection', $reflectedClass->getName(), $reflectionProperty->getName());
-                               if ($reflectedProperty->isTaggedWith('inject') && $reflectedProperty->getName() !== 'settings') {
+                               if (($reflectedProperty->isTaggedWith('inject') || $reflectedProperty->isTaggedWith('Flow\Inject')) && $reflectedProperty->getName() !== 'settings') {
                                        $varValues = $reflectedProperty->getTagValues('var');
                                        if (count($varValues) == 1) {
                                                $result[$reflectedProperty->getName()] = ltrim($varValues[0], '\\');
index b4f0a4d..fb4076e 100644 (file)
@@ -39,6 +39,12 @@ class ClassWithInjectProperties {
         * @inject
         */
        protected $secondDummyClass;
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Tests\Fixture\SecondDummyClass
+        * @Flow\Inject
+        */
+       protected $secondDummyClassWithFlowInject;
 }
 
 ?>
\ No newline at end of file
index ac6d1a6..31ad1c6 100644 (file)
@@ -66,7 +66,13 @@ class ClassInfoFactoryTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         */
        public function buildClassInfoDetectsPropertiesToInjectByAnnotation() {
                $classInfo = $this->classInfoFactory->buildClassInfoFromClassName('TYPO3\\CMS\\Extbase\\Tests\\Fixture\\ClassWithInjectProperties');
-               $this->assertEquals(array('secondDummyClass' => 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\SecondDummyClass'), $classInfo->getInjectProperties());
+               $this->assertEquals(
+                       array(
+                               'secondDummyClass' => 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\SecondDummyClass',
+                               'secondDummyClassWithFlowInject' => 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\SecondDummyClass'
+                       ),
+                       $classInfo->getInjectProperties()
+               );
        }
 
        /**