Skip to content

[DoctrineBridge] remove deprecated features #22784

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

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,8 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
* @param ChoiceListFactoryInterface $factory The factory for creating
* the loaded choice list
*/
public function __construct($manager, $class, $idReader = null, $objectLoader = null, $factory = null)
public function __construct(ObjectManager $manager, $class, $idReader = null, $objectLoader = null, $factory = null)
{
// BC to be removed and replace with type hints in 4.0
if ($manager instanceof ChoiceListFactoryInterface) {
@trigger_error(sprintf('Passing a ChoiceListFactoryInterface to %s is deprecated since version 3.1 and will no longer be supported in 4.0. You should either call "%s::loadChoiceList" or override it to return a ChoiceListInterface.', __CLASS__, __CLASS__), E_USER_DEPRECATED);

// Provide a BC layer since $factory has changed
// form first to last argument as of 3.1
$manager = $class;
$class = $idReader;
$idReader = $objectLoader;
$objectLoader = $factory;
}

$classMetadata = $manager->getClassMetadata($class);

$this->manager = $manager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,19 @@
*/
class MergeDoctrineCollectionListener implements EventSubscriberInterface
{
// Keep BC. To be removed in 4.0
private $bc = true;
private $bcLayer = false;

public static function getSubscribedEvents()
{
// Higher priority than core MergeCollectionListener so that this one
// is called before
return array(
FormEvents::SUBMIT => array(
array('onBind', 10), // deprecated
array('onSubmit', 5),
),
);
}

public function onSubmit(FormEvent $event)
{
if ($this->bc) {
// onBind() has been overridden from a child class
@trigger_error('The onBind() method is deprecated since version 3.1 and will be removed in 4.0. Use the onSubmit() method instead.', E_USER_DEPRECATED);

if (!$this->bcLayer) {
// If parent::onBind() has not been called, then logic has been executed
return;
}
}

$collection = $event->getForm()->getData();
$data = $event->getData();

Expand All @@ -64,20 +49,4 @@ public function onSubmit(FormEvent $event)
$collection->clear();
}
}

/**
* Alias of {@link onSubmit()}.
*
* @deprecated since version 3.1, to be removed in 4.0.
* Use {@link onSubmit()} instead.
*/
public function onBind(FormEvent $event)
{
if (__CLASS__ === get_class($this)) {
$this->bc = false;
} else {
// parent::onBind() has been called
$this->bcLayer = true;
}
}
}
6 changes: 1 addition & 5 deletions src/Symfony/Bridge/Doctrine/ManagerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ protected function resetService($name)
$manager = $this->container->get($name);

if (!$manager instanceof LazyLoadingInterface) {
@trigger_error(sprintf('Resetting a non-lazy manager service is deprecated since Symfony 3.2 and will throw an exception in version 4.0. Set the "%s" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.', $name), E_USER_DEPRECATED);

$this->container->set($name, null);

return;
throw new \LogicException(sprintf('Resetting a non-lazy manager service is not supported. Set the "%s" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.', $name));
}
$manager->setProxyInitializer(\Closure::bind(
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -113,37 +113,6 @@ public function testLoadChoiceList()
$this->assertEquals($choiceList, $loader->loadChoiceList($value));
}

/**
* @group legacy
*/
public function testLegacyLoadChoiceList()
{
$factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
$loader = new DoctrineChoiceLoader(
$factory,
$this->om,
$this->class,
$this->idReader
);

$choices = array($this->obj1, $this->obj2, $this->obj3);
$value = function () {};
$choiceList = new ArrayChoiceList($choices, $value);

$this->repository->expects($this->once())
->method('findAll')
->willReturn($choices);

$factory->expects($this->never())
->method('createListFromChoices');

$this->assertEquals($choiceList, $loaded = $loader->loadChoiceList($value));

// no further loads on subsequent calls

$this->assertSame($loaded, $loader->loadChoiceList($value));
}

public function testLoadChoiceListUsesObjectLoaderIfAvailable()
{
$loader = new DoctrineChoiceLoader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,4 @@ public function testOnSubmitNullClearCollection()

$this->assertTrue($this->collection->isEmpty());
}

/**
* @group legacy
*/
public function testLegacyChildClassOnSubmitCallParent()
{
$form = $this->getBuilder('name')
->setData($this->collection)
->addEventSubscriber(new TestClassExtendingMergeDoctrineCollectionListener())
->getForm();
$submittedData = array();
$event = new FormEvent($form, $submittedData);

$this->dispatcher->dispatch(FormEvents::SUBMIT, $event);

$this->assertTrue($this->collection->isEmpty());
$this->assertTrue(TestClassExtendingMergeDoctrineCollectionListener::$onBindCalled);
}
}

/**
* @group legacy
*/
class TestClassExtendingMergeDoctrineCollectionListener extends MergeDoctrineCollectionListener
{
public static $onBindCalled = false;

public function onBind(FormEvent $event)
{
self::$onBindCalled = true;

parent::onBind($event);
}
}