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

add attribute driver support #692

Merged
merged 6 commits into from
Oct 23, 2021
Merged

Conversation

IonBazan
Copy link
Member

This PR adds support for upcoming attribute mapping driver introduced in doctrine/mongodb-odm#2344.

@IonBazan IonBazan force-pushed the attribute-driver branch 3 times, most recently from 91b620a to 9e56b2d Compare August 11, 2021 08:37
@malarzm
Copy link
Member

malarzm commented Aug 16, 2021

@IonBazan if you want to see whether static analysis is green or add some test feel free to require ODM's 2.3.x branch in composer.json. Later we'll drop the change once 2.3.0 is tagged properly

@malarzm
Copy link
Member

malarzm commented Aug 16, 2021

Also it'd be great to check and update the docs. They definitely need some love since they still mention yaml as one of the mapping options 😅 https://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/config.html#mapping-configuration

@malarzm malarzm added this to the 4.4.0 milestone Aug 16, 2021
@malarzm
Copy link
Member

malarzm commented Aug 16, 2021

For the docs we could also add "PHP (attributes)" section for mapping examples: https://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/first_steps.html#creating-a-document-class

@IonBazan
Copy link
Member Author

IonBazan commented Aug 17, 2021

Alright, I've temporarily added @dev flag to the version constraint so it will ignore minimum-stability during static analysis. I've also added Attribute mapping examples in several places in docs, mentioning they were added in 4.4.
I'm thinking whether we can make it more clear how to use the new mapping method 🤔 Maybe put attributes examples as the primary?

@franmomu
Copy link
Contributor

As suggested in doctrine/mongodb-odm#2344 (comment), it would be nice to add some tests like in https://github.com/doctrine/DoctrineBundle/pull/1322/files

@IonBazan
Copy link
Member Author

IonBazan commented Oct 16, 2021

@franmomu @malarzm I've added some test cases for the new driver configuration ✨
Also, rebased and fixed Doctor-RST issues. All green now ✅

Copy link
Contributor

@franmomu franmomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor comments

@@ -176,7 +176,7 @@ The following configuration shows a bunch of mapping examples:
mappings:
MyBundle1: ~
MyBundle2: xml
MyBundle3: { type: annotation, dir: Documents/ }
MyBundle3: { type: attribute, dir: Documents/ }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we keep annotation example and add a new one for attribute

#[MongoDB\Id]
protected string $id;

#[MongoDB\Field(type: 'string')]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in our examples we could suggest to use constants like Doctrine\ODM\MongoDB\Types\Type::STRING

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be changed in annotation examples then too but I think this is a candidate for a separate PR.
I don't see the constants usages in ORM docs neither and I don't think it's clear to new developers.

Copy link
Contributor

@franmomu franmomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this one we can maybe think about #703 before any other new PR appears

@IonBazan IonBazan merged commit 16e2290 into doctrine:4.4.x Oct 23, 2021
@IonBazan IonBazan deleted the attribute-driver branch October 23, 2021 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants