Skip to content

Commit

Permalink
Deprecate extension via Doctrine Event Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Oct 22, 2022
1 parent c16bc8f commit 10988f8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 36 deletions.
11 changes: 11 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ awareness about deprecated code.

# Upgrade to 3.5

## Deprecated extension via Doctrine Event Manager

Extension of the library behavior via Doctrine Event Manager has been deprecated.

The following methods and properties have been deprecated:
- `AbsractPlatform::$_eventManager`,
- `AbsractPlatform::getEventManager()`,
- `AbsractPlatform::setEventManager()`,
- `Connection::$_eventManager`,
- `Connection::getEventManager()`.

## Deprecated extension via connection events

Subscription to the `postConnect` event has been deprecated. Use one of the following replacements for the standard
Expand Down
33 changes: 0 additions & 33 deletions docs/en/reference/events.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/en/sidebar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
reference/types
reference/schema-manager
reference/schema-representation
reference/events
reference/security
reference/supporting-other-databases
reference/portability
Expand Down
11 changes: 11 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<referencedClass name="Doctrine\DBAL\Event\Listeners\OracleSessionInit"/>
<referencedClass name="Doctrine\DBAL\Event\Listeners\SQLSessionInit"/>
<referencedClass name="Doctrine\DBAL\Event\Listeners\SQLiteSessionInit"/>
<referencedClass name="Doctrine\DBAL\Events"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedConstant>
Expand Down Expand Up @@ -491,6 +492,11 @@
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getConnection"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Connection::getEventManager"/>
<referencedMethod name="Doctrine\DBAL\Platforms\AbstractPlatform::setEventManager"/>
</errorLevel>
</DeprecatedMethod>
<DeprecatedProperty>
Expand Down Expand Up @@ -544,6 +550,11 @@
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Schema\SchemaDiff::$orphanedForeignKeys"/>
<!--
TODO: remove in 4.0.0
-->
<referencedProperty name="Doctrine\DBAL\Connection::$_eventManager"/>
<referencedProperty name="Doctrine\DBAL\Platforms\AbstractPlatform::$_eventManager"/>
</errorLevel>
</DeprecatedProperty>
<DocblockTypeContradiction>
Expand Down
15 changes: 14 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ class Connection
/** @var Configuration */
protected $_config;

/** @var EventManager */
/**
* @deprecated
*
* @var EventManager
*/
protected $_eventManager;

/**
Expand Down Expand Up @@ -256,10 +260,19 @@ public function getConfiguration()
/**
* Gets the EventManager used by the Connection.
*
* @deprecated
*
* @return EventManager
*/
public function getEventManager()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/5784',
'%s is deprecated.',
__METHOD__,
);

return $this->_eventManager;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Container for all DBAL events.
*
* This class cannot be instantiated.
*
* @deprecated
*/
final class Events
{
Expand Down
24 changes: 23 additions & 1 deletion src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ abstract class AbstractPlatform
*/
protected $doctrineTypeComments;

/** @var EventManager|null */
/**
* @deprecated
*
* @var EventManager|null
*/
protected $_eventManager;

/**
Expand All @@ -102,20 +106,38 @@ abstract class AbstractPlatform
/**
* Sets the EventManager used by the Platform.
*
* @deprecated
*
* @return void
*/
public function setEventManager(EventManager $eventManager)
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/5784',
'%s is deprecated.',
__METHOD__,
);

$this->_eventManager = $eventManager;
}

/**
* Gets the EventManager used by the Platform.
*
* @deprecated
*
* @return EventManager|null
*/
public function getEventManager()
{
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/5784',
'%s is deprecated.',
__METHOD__,
);

return $this->_eventManager;
}

Expand Down

0 comments on commit 10988f8

Please sign in to comment.