Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
ea473f7d
Commit
ea473f7d
authored
Feb 09, 2016
by
Claudio Zizza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Schema events skeleton and documentation of onSchemaCreateTable
parent
625dd635
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
events.rst
docs/en/reference/events.rst
+98
-0
No files found.
docs/en/reference/events.rst
View file @
ea473f7d
...
@@ -39,3 +39,101 @@ instance passed to the Connection factory:
...
@@ -39,3 +39,101 @@ instance passed to the Connection factory:
$conn = DriverManager::getConnection($connectionParams, null, $evm);
$conn = DriverManager::getConnection($connectionParams, null, $evm);
Schema Events
-------------
There are multiple events in Doctrine DBAL that are triggered on schema changes
of the database. It is possible to add your own event listener to be able to run
your own code before changes to the database are commited. An instance of
``Doctrine\Common\EventManager`` can also be added to :doc:`platforms`.
A event listener class can contain one or more methods to schema events. These
methods must be named like the events itself.
.. code-block:: php
<?php
$evm = new EventManager();
$eventName = 'onSchemaCreateTable';
$evm->addEventListener($eventName, new MyEventListener());
.. code-block:: php
<?php
$evm = new EventManager();
$eventNames = array('onSchemaCreateTable', 'onSchemaCreateTableColumn');
$evm->addEventListener($eventNames, new MyEventListener());
The following events are available.
OnSchemaCreateTable Event
^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::onSchemaCreateTable`` is triggered before every
create statement that is executed by one of the Platform instances and gets
an instance of ``Doctrine\DBAL\Event\SchemaCreateTableEventArgs`` as event argument.
.. code-block:: php
<?php
class MyEventListener
{
public function onSchemaCreateTable(SchemaCreateTableEventArgs $event)
{
// Your EventListener code
}
}
$evm = new EventManager();
$evm->addEventListener('onSchemaCreateTable', new MyEventListener());
$conn = DriverManager::getConnection($connectionParams, null, $evm);
It allows you to access the ``Doctrine\DBAL\Schema\Table`` instances and its columns, the used Platform and
provides a way to add your own SQL statements.
OnSchemaCreateTableColumn Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaDropTable Event
^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaAlterTable Event
^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaAlterTableAddColumn Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaAlterTableRemoveColumn Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaAlterTableChangeColumn Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaAlterTableRenameColumn Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaColumnDefinition Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
OnSchemaIndexDefinition Event
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``Doctrine\DBAL\Events::postConnect`` is triggered
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment