Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdanek/doctrine-plugin
Doctrine 2 integration plugin
https://github.com/jdanek/doctrine-plugin
Last synced: 5 days ago
JSON representation
Doctrine 2 integration plugin
- Host: GitHub
- URL: https://github.com/jdanek/doctrine-plugin
- Owner: jDanek
- Created: 2021-07-31T16:44:54.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2020-07-26T15:07:06.000Z (over 4 years ago)
- Last Synced: 2024-11-08T03:34:52.255Z (about 2 months ago)
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Doctrine plugin
###############Doctrine 2 integration plugin.
.. contents::
Requirements
************- PHP 7.2+
- SunLight CMS 8Usage
*****See `Doctrine 2 documentation `_.
Entity registration
===================Entities need to be registered using the `doctrine.map_entities`_ event before they
can be used.Table names
===========Table are automatically prefixed with ``db.prefix`` as defined in the global *config.php*.
If no table name is explicitly specified, ``UnderscoreNamingStrategy`` is used to generate one.
Base entity class
=================An optional base entity class is available. It provides several active record-esque
utility methods.Static methods
--------------- ``find($id)`` - try to find an instance by ID
- ``getRepository()`` - get repository for the entity class
- ``getEntityManager()`` - get the entity manager (protected)Instance methods
----------------- ``persist()`` - make the entity managed and persistent
- ``save()`` - persist and flush the entity to the database
- ``delete()`` - delete and flush this entity from the databaseExample
-------Entity definition
^^^^^^^^^^^^^^^^^.. code:: php
name = $name;
}
}Basic usage
^^^^^^^^^^^.. code:: php
save();
var_dump($foo->id);// find existing entities
Foo::find(1); // by ID
Foo::getRepository()->findBy(['name' => 'test']); // using repository// saving changes
$foo->name = 'new name';
$foo->save();// deleting entities
$foo->delete();Accessing the entity manager
============================.. code:: php
`_
- `XML mapping `_Doctrine console
================Doctrine console can be accessed by clicking on the plugin's "Console" action
in "Administration - Plugins".