Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #17782 Support autowiring for Doctrine\Common\Annotations\Rea…
…der (maryo) This PR was merged into the 3.1-dev branch. Discussion ---------- Support autowiring for Doctrine\Common\Annotations\Reader | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a I've added support for autowiring based on `Doctrine\Common\Annotations\Reader` interface simmilar to https://github.com/symfony/symfony/pull/17703/files The `annotations.cached_reader` service is injected when cache is enabled. Commits ------- b325f9c Support autowiring for Doctrine\Common\Annotations\Reader
- Loading branch information
Showing
7 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; | ||
|
||
use Doctrine\Common\Annotations\AnnotationReader; | ||
use Doctrine\Common\Annotations\CachedReader; | ||
|
||
class AutowiringTypesTest extends WebTestCase | ||
{ | ||
public function testAnnotationReaderAutowiring() | ||
{ | ||
static::bootKernel(array('root_config' => 'no_annotations_cache.yml', 'environment' => 'no_annotations_cache')); | ||
$container = static::$kernel->getContainer(); | ||
|
||
$annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader(); | ||
$this->assertInstanceOf(AnnotationReader::class, $annotationReader); | ||
} | ||
|
||
public function testCachedAnnotationReaderAutowiring() | ||
{ | ||
static::bootKernel(); | ||
$container = static::$kernel->getContainer(); | ||
|
||
$annotationReader = $container->get('test.autowiring_types.autowired_services')->getAnnotationReader(); | ||
$this->assertInstanceOf(CachedReader::class, $annotationReader); | ||
} | ||
|
||
protected static function createKernel(array $options = array()) | ||
{ | ||
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes; | ||
|
||
use Doctrine\Common\Annotations\Reader; | ||
|
||
class AutowiredServices | ||
{ | ||
private $annotationReader; | ||
|
||
public function __construct(Reader $annotationReader = null) | ||
{ | ||
$this->annotationReader = $annotationReader; | ||
} | ||
|
||
public function getAnnotationReader() | ||
{ | ||
return $this->annotationReader; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/bundles.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
|
||
return array( | ||
new FrameworkBundle(), | ||
new TestBundle(), | ||
); |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
imports: | ||
- { resource: ../config/default.yml } | ||
|
||
services: | ||
test.autowiring_types.autowired_services: | ||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices | ||
autowire: true |
6 changes: 6 additions & 0 deletions
6
...fony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/no_annotations_cache.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
imports: | ||
- { resource: config.yml } | ||
|
||
framework: | ||
annotations: | ||
cache: none |