ConnectionEventArgs.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Doctrine\DBAL\Event;
  3. use Doctrine\Common\EventArgs;
  4. use Doctrine\DBAL\Connection;
  5. use Doctrine\DBAL\Driver;
  6. use Doctrine\DBAL\Platforms\AbstractPlatform;
  7. use Doctrine\DBAL\Schema\AbstractSchemaManager;
  8. use Doctrine\Deprecations\Deprecation;
  9. /**
  10. * Event Arguments used when a Driver connection is established inside {@link Connection}.
  11. */
  12. class ConnectionEventArgs extends EventArgs
  13. {
  14. /** @var Connection */
  15. private $connection;
  16. public function __construct(Connection $connection)
  17. {
  18. $this->connection = $connection;
  19. }
  20. /**
  21. * @return Connection
  22. */
  23. public function getConnection()
  24. {
  25. return $this->connection;
  26. }
  27. /**
  28. * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDriver() instead.
  29. *
  30. * @return Driver
  31. */
  32. public function getDriver()
  33. {
  34. Deprecation::trigger(
  35. 'doctrine/dbal',
  36. 'https://github.com/doctrine/dbal/issues/3580',
  37. 'ConnectionEventArgs::getDriver() is deprecated, ' .
  38. 'use ConnectionEventArgs::getConnection()->getDriver() instead.'
  39. );
  40. return $this->connection->getDriver();
  41. }
  42. /**
  43. * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getDatabasePlatform() instead.
  44. *
  45. * @return AbstractPlatform
  46. */
  47. public function getDatabasePlatform()
  48. {
  49. Deprecation::trigger(
  50. 'doctrine/dbal',
  51. 'https://github.com/doctrine/dbal/issues/3580',
  52. 'ConnectionEventArgs::getDatabasePlatform() is deprecated, ' .
  53. 'use ConnectionEventArgs::getConnection()->getDatabasePlatform() instead.'
  54. );
  55. return $this->connection->getDatabasePlatform();
  56. }
  57. /**
  58. * @deprecated Use ConnectionEventArgs::getConnection() and Connection::getSchemaManager() instead.
  59. *
  60. * @return AbstractSchemaManager
  61. */
  62. public function getSchemaManager()
  63. {
  64. Deprecation::trigger(
  65. 'doctrine/dbal',
  66. 'https://github.com/doctrine/dbal/issues/3580',
  67. 'ConnectionEventArgs::getSchemaManager() is deprecated, ' .
  68. 'use ConnectionEventArgs::getConnection()->getSchemaManager() instead.'
  69. );
  70. return $this->connection->getSchemaManager();
  71. }
  72. }