Skip to content
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

Remove mongodb support #761

Merged
merged 1 commit into from
Aug 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
run:
uses: "nucleos/actions/.github/workflows/continuous-integration.yml@main"
with:
PHP_EXTENSIONS: "mbstring, json, mongodb"
PHP_EXTENSIONS: "mbstring, json"
SYMFONY_KERNEL: "Nucleos\\UserBundle\\Tests\\App\\AppKernel"
SYMFONY_VERSIONS: "6.4,7.0"
secrets:
Expand Down
6 changes: 6 additions & 0 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPGRADE FROM 3.x to 4.0
=======================

## Remove MongoDB support

MongoDB is not supported by this bundle anymore. All classes related to `doctrine/mongodb-odm` were removed.
4 changes: 0 additions & 4 deletions composer-require.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"callable",
"void",
"object",
"Doctrine\\Bundle\\DoctrineBundle\\DependencyInjection\\Compiler\\DoctrineOrmMappingsPass",
"Doctrine\\Bundle\\MongoDBBundle\\DependencyInjection\\Compiler\\DoctrineMongoDBMappingsPass",
"Doctrine\\ODM\\MongoDB\\DocumentManager",
"Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata",
"Doctrine\\ORM\\EntityManager",
"Doctrine\\ORM\\Mapping\\ClassMetadata"
]
Expand Down
6 changes: 0 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@
"twig/twig": "^2.14 || ^3.1"
},
"require-dev": {
"ext-mongodb": "*",
"dama/doctrine-test-bundle": "^8.0",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/mongodb-odm": "^2.3",
"doctrine/mongodb-odm-bundle": "^4.4 || ^5.0",
"doctrine/orm": "^2.18 || ^3.0",
"ergebnis/composer-normalize": "^2.0.1",
"symfony/browser-kit": "^6.4 || ^7.0",
Expand All @@ -83,9 +80,6 @@
"conflict": {
"doctrine/dbal": ">=4",
"doctrine/doctrine-bundle": "<1.12",
"doctrine/mongodb": "<1.6",
"doctrine/mongodb-odm": "<1.1",
"doctrine/mongodb-odm-bundle": "<4.1",
"doctrine/orm": "<2.18"
},
"autoload": {
Expand Down
2 changes: 0 additions & 2 deletions docs/configuration_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ All available configuration options are listed below with their default values.
.. code-block:: yaml

nucleos_user:
db_driver: ~ # Required
firewall_name: ~ # Required
user_class: ~ # Required
use_listener: true
use_flash_notifications: true
model_manager_name: null # change it to the name of your entity/document manager if you don't want to use the default one.
use_authentication_listener: true
Expand Down
54 changes: 0 additions & 54 deletions docs/custom_storage_layer.rst

This file was deleted.

20 changes: 0 additions & 20 deletions docs/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@ Doctrine Implementations

This chapter describes some things specific to these implementations.

Using a different object manager than the default one
-----------------------------------------------------

Using the default configuration , NucleosUserBundle will use the default doctrine
object manager. If you are using multiple ones and want to handle your users
with a non-default one, you can change the object manager used in the configuration
by giving its name to NucleosUserBundle.

.. code-block:: yaml

# config/packages/nucleos_user.yaml
nucleos_user:
db_driver: orm
model_manager_name: non_default # the name of your entity manager

.. note::

Using the default object manager is done by setting the configuration
option to ``null`` which is the default value.

Replacing the mapping of the bundle
-----------------------------------

Expand Down
55 changes: 0 additions & 55 deletions docs/groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Below is an example configuration for enabling groups support.

# config/packages/nucleos_user.yaml
nucleos_user:
db_driver: orm
firewall_name: main
user_class: App\Entity\User
group:
Expand All @@ -33,9 +32,6 @@ The Group class
The simplest way to create a Group class is to extend the mapped superclass
provided by the bundle.

a) ORM Group class implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: php-annotations

// src/Entity/Group.php
Expand All @@ -62,37 +58,11 @@ a) ORM Group class implementation

``Group`` is a reserved keyword in SQL so it cannot be used as the table name.

b) MongoDB Group class implementation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: php

// src/Document/Group.php
namespace App\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Nucleos\UserBundle\Model\Group as BaseGroup;

/**
* @MongoDB\Document
*/
class Group extends BaseGroup
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;
}

Defining the User-Group relation
--------------------------------

The next step is to map the relation in your ``User`` class.

a) ORM User-Group mapping
~~~~~~~~~~~~~~~~~~~~~~~~~


.. code-block:: php-annotations

// src/Entity/User.php
Expand Down Expand Up @@ -122,28 +92,3 @@ a) ORM User-Group mapping
*/
protected $groups;
}

b) MongoDB User-Group mapping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: php

// src/Document/User.php
namespace App\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Nucleos\UserBundle\Model\User as BaseUser;

/**
* @MongoDB\Document
*/
class User extends BaseUser
{
/** @MongoDB\Id(strategy="auto") */
protected $id;

/**
* @MongoDB\ReferenceMany(targetDocument="App\Document\Group")
*/
protected $groups;
}
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ The following documents are available:
emails
groups
doctrine
custom_storage_layer
security
deletion
configuration_reference
Expand Down
51 changes: 4 additions & 47 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Require the bundle with composer:

$ composer require nucleos/user-bundle

If you encounter installation errors pointing at a lack of configuration parameters, such as ``The child node "db_driver" at path "nucleos_user" must be configured``, you should complete the configuration in Step 5 first and then re-run this step.
If you encounter installation errors pointing at a lack of configuration parameters, you should complete the configuration in Step 5 first and then re-run this step.

Step 2: Enable the bundle
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -57,8 +57,8 @@ Enable the bundle in the kernel:
Step 3: Create your User class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The goal of this bundle is to persist some ``User`` class to a database (MySql,
MongoDB, etc). Your first job, then, is to create the ``User`` class
The goal of this bundle is to persist some ``User`` class to a database.
Your first job, then, is to create the ``User`` class
for your application. This class can look and act however you want: add any
properties or methods you find useful. This is *your* ``User`` class.

Expand All @@ -75,7 +75,7 @@ to make it easier to create your entity. Here is how you use it:
redefine the mapping for the other fields as it is provided by the bundle.

In the following sections, you'll see examples of how your ``User`` class should
look, depending on how you're storing your users (Doctrine ORM or MongoDB ODM).
look.

.. note::

Expand All @@ -89,9 +89,6 @@ look, depending on how you're storing your users (Doctrine ORM or MongoDB ODM).
to call parent::__construct(), as the base User class depends on
this to initialize some fields.

a) Doctrine ORM User class
..........................

If you're persisting your users via the Doctrine ORM, then your ``User`` class
should live in the ``Entity`` namespace of your bundle and look like this to
start:
Expand Down Expand Up @@ -129,38 +126,6 @@ start:

``user`` is a reserved keyword in the SQL standard. If you need to use reserved words, surround them with backticks, *e.g.* ``@ORM\Table(name="`user`")``

b) MongoDB User class
.....................

If you're persisting your users via the Doctrine MongoDB ODM, then your ``User``
class should live in the ``Document`` namespace of your bundle and look like
this to start.

.. code-block:: php-annotations

// src/Document/User.php
namespace App\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Nucleos\UserBundle\Model\User as BaseUser;

/**
* @MongoDB\Document
*/
class User extends BaseUser
{
/**
* @MongoDB\Id(strategy="auto")
*/
protected $id;

public function __construct()
{
parent::__construct();
// your own logic
}
}


Step 4: Configure your application's security.yaml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -256,7 +221,6 @@ of datastore you are using.

# config/packages/nucleos_user.yaml
nucleos_user:
db_driver: orm # other valid values is 'mongodb'
firewall_name: main
user_class: App\Entity\User
from_email: "%mailer_user%"
Expand All @@ -266,7 +230,6 @@ of datastore you are using.

Only four configuration's nodes are required to use the bundle:

* The type of datastore you are using (``orm`` or ``mongodb``).
* The firewall name which you configured in Step 4.
* The fully qualified class name (FQCN) of the ``User`` class which you created in Step 3.

Expand Down Expand Up @@ -317,11 +280,5 @@ For ORM run the following command.

$ php bin/console doctrine:schema:update --force

For MongoDB users you can run the following command to create the indexes.

.. code-block:: bash

$ php bin/console doctrine:mongodb:schema:create --index

.. _Symfony documentation: https://symfony.com/doc/current/book/translation.html
.. _security component documentation: https://symfony.com/doc/current/book/security.html
21 changes: 0 additions & 21 deletions docs/user_manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ Using it ensures that your code will continue to work if you change the storage.
The controllers provided by the bundle use the configured user manager instead
of interacting directly with the storage layer.

If you configure the ``db_driver`` option to ``orm``, this service is an instance
of ``Nucleos\UserBundle\Doctrine\UserManager``.

If you configure the ``db_driver`` option to ``mongodb``, this service is an
instance of ``Nucleos\UserBundle\Doctrine\UserManager``.


Accessing the User Manager service
----------------------------------

Expand Down Expand Up @@ -72,20 +65,6 @@ Updating a User object

$userManager->updateUser($user);

.. note::

To make it easier, the bundle comes with a Doctrine listener handling
the update of the password fields for you behind the
scenes. If you always save the user through the user manager, you may
want to disable it to improve performance.

.. code-block:: yaml

# config/packages/nucleos_user.yaml
nucleos_user:
# ...
use_listener: false

.. note::

For the Doctrine implementations, the default behavior is to flush the
Expand Down
Loading
Loading