Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove BeanFactoryPostProcessor #102

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ the `@Parameter` collection. The new syntax looks like this:
*/
```

## BC BREAK: Removal of BeanFactoryPostProcessor

Injecting a container into a bean (service) is considered a bad practice,
thus the BeanFactoryPostProcessor implementation is removed. The general
post processor logic is still in place, a custom BeanFactoryPostProcessor
implementation can still be used.

# Upgrade to Disco 0.5.0

## BC BREAK: Rasing minimum PHP version to 7.0
Expand Down
8 changes: 0 additions & 8 deletions docs/advanced/bean-post-processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,3 @@ Disco will call every post processor for every new bean instance created.
In case of a singleton bean the call for each post processor will happen once,
in case of a lazy bean the call will happen when the "real" instance gets
created. Disco will manage this all for you.

# BeanFactoryPostProcessor

Disco comes with one post processor implementation out-of-the-box:
`\bitExpert\Disco\BeanFactoryPostProcessor`. This post processor will only
run for classes implementing the `\bitExpert\Disco\BeanFactoryAware`
interface. As the name implies it will inject the current BeanFactory
instance into the created bean instance.
28 changes: 0 additions & 28 deletions src/bitExpert/Disco/BeanFactoryAware.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/bitExpert/Disco/BeanFactoryAwareTrait.php

This file was deleted.

34 changes: 0 additions & 34 deletions src/bitExpert/Disco/BeanFactoryPostProcessor.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ public function __construct(
$body .= '$this->' . $sessionBeansProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() .
'->getSessionBeanStore();' . PHP_EOL;
$body .= '// register {@link \\bitExpert\\Disco\\BeanPostProcessor} instances' . PHP_EOL;
$body .= '$this->' . $beanPostProcessorsProperty->getName() .
'[] = new \bitExpert\Disco\BeanFactoryPostProcessor();' . PHP_EOL;
foreach ($beanPostProcessorMethodNames as $methodName) {
$body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = $this->' . $methodName . '(); ';
$body .= PHP_EOL;
Expand Down
14 changes: 0 additions & 14 deletions tests/bitExpert/Disco/AnnotationBeanFactoryUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use bitExpert\Disco\Config\BeanConfigurationWithPrimitives;
use bitExpert\Disco\Config\BeanConfigurationWithProtectedMethod;
use bitExpert\Disco\Config\WrongReturnTypeConfiguration;
use bitExpert\Disco\Helper\BeanFactoryAwareService;
use bitExpert\Disco\Helper\MasterService;
use bitExpert\Disco\Helper\SampleService;
use bitExpert\Disco\Helper\SampleServiceInterface;
Expand Down Expand Up @@ -251,19 +250,6 @@ public function postProcessorHookRunsAfterLazyBeanCreation()
self::assertEquals('postProcessed', $bean->test);
}

/**
* @test
*/
public function beanFactoryPostProcessorHookRuns()
{
$this->beanFactory = new AnnotationBeanFactory(BeanConfigurationWithPostProcessor::class);
BeanFactoryRegistry::register($this->beanFactory);

/** @var BeanFactoryAwareService $bean */
$bean = $this->beanFactory->get('beanFactoryAwareBean');
self::assertInstanceOf(BeanFactory::class, $bean->getBeanFactory());
}

/**
* @test
*/
Expand Down
35 changes: 0 additions & 35 deletions tests/bitExpert/Disco/BeanFactoryAwareTraitUnitTest.php

This file was deleted.

40 changes: 0 additions & 40 deletions tests/bitExpert/Disco/BeanFactoryPostProcessorUnitTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ public function sampleServiceBeanPostProcessor() : SampleServiceBeanPostProcesso
return new SampleServiceBeanPostProcessor();
}

/**
* @BeanPostProcessor
*/
public function beanFactoryBeanPostProcessor() : BeanFactoryPostProcessor
{
return new BeanFactoryPostProcessor();
}

/**
* @Bean
*/
Expand All @@ -56,12 +48,4 @@ public function nonSingletonLazyRequestBean() : SampleService
{
return new SampleService();
}

/**
* @Bean
*/
public function beanFactoryAwareBean() : BeanFactoryAwareService
{
return new BeanFactoryAwareService();
}
}
40 changes: 0 additions & 40 deletions tests/bitExpert/Disco/Helper/BeanFactoryAwareService.php

This file was deleted.