-
Notifications
You must be signed in to change notification settings - Fork 519
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
Support alternative mapping formats #159
Conversation
Tests are on their way. |
Done. Waiting for a review :) |
Any feedback? |
Do you give me an entity(yml) example please? |
Here it is: Jedi\DomainBundle\Entity\Article:
type: entity
table: articles
repositoryClass: Jedi\DomainBundle\Repository\ArticleRepository
vich:
uploadable:
file:
mapping: article_pdf
filename_property: file_name
fields:
id:
type: integer
id: true
generator: {strategy: AUTO}
title:
type: string
length: 255
file_name:
type: text
slug:
type: string
length: 255
gedmo:
slug: { fields: [title] }
# ... |
@dustin10 so, what should I do to have this PR merged? :) |
HI @K-Phoen, It would be a really nice feature to have, alternative mappings is definitely something that I would put in the bundle.
If you think about it, Vich's mapping data are not so different from the validator annotations (@Assert/XXX) or the JmsSerializerBundle annotations (http://jmsyst.com/libs/serializer), I think we should do as they do: allowing extra mapping datas without mixing with doctrine. What do you think about it? If you don't have time to rewrite the pull request, or if don't want to, as a first step, in order to not throw away your work, I could merge it if dmr/dmr became a suggestion and not an hard dependency. This way, if you have doctrine 2.3+ you can install dmr/dmr and enable different mapping, but if you're working with doctrine 2.2 you can still use the bundle with annotations as it is working now. In my opinion it would be better to rewrite this without dmr/dmr, allowing the user to specify a separate yml o xml mapping file for upload information, but if you want to keep dmr/dmr, at least, it has to be a soft dependency and not and hard one. |
I think it's nice to have feedback, especially when it's a relevant one! No need to merge this PR right now, I'll rewrite it to remove the dependency to dmr/dmr. Thanks! |
@ftassi I modified the PR to use jms/metadata instead of dmr/dmr. The dependency to doctrine is now limited to the annotation reader (for the metadata part of the bundle of course). Can you review it? |
}, | ||
"require-dev": { | ||
"doctrine/orm": "@stable", | ||
"doctrine/mongodb-odm": "@dev", | ||
"knplabs/knp-gaufrette-bundle": "*", | ||
"phpunit/phpunit": "@stable" | ||
"phpunit/phpunit": "~3.7@stable", | ||
"symfony/yaml": "@stable" | ||
}, | ||
"suggest": { | ||
"doctrine/orm": "*", | ||
"doctrine/doctrine-bundle": "*", | ||
"doctrine/mongodb-odm-bundle": "*", | ||
"knplabs/knp-gaufrette-bundle": "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you missed a comma here
👍 |
I'll try to add XML support soon. |
It make sense for me now, I guess that adding some documentation about this new feature we could merge it. |
Sorry, I've missed the updated doc file. By the way, reading it I've thought that was kind of weird to have to define upload annotation within the entity YAML file. Metadata for uploadable fields aren't really related to doctrine, the bundle actually relies on doctrine events to trigger the upload, but it could work even without it. Can't we put our metadata in a separate yaml file ? Wouldn't it be better ? I haven't checked it yet, but I guess your code should work with a separate file right now if we just let the user to configure where he wants to store them and if the annotation driver gets the right file. We should look for some pattern from other bundles, JmsSerializerBundle stores its metadata in a separate file, I think that's a good pattern to follow, it leads to a better decoupling for our bundle. If we want to go for a separate file we should document where put the file and how to configure its position (if configurable). |
Ultimately this would be great. As a matter of fact, I even think it's already possible. If you read the I think we should merge this PR as is and in the meantime work on a new version of this bundle - let's say 1.0 - with (at least) the following objectives:
What do you think? |
Hum. I don't know why I said that the yaml config was coupled to doctrine... |
@K-Phoen as you said reading metadata from a separate yaml file should be quite easy, maybe it's just a matter of updating the documentation and defining a new default directory for the yaml file. If you agree that a separate file is the way to go, I'd like to update the PR before merging it. If we merge it as it is now, and users start to use this new feature they'll have to split their yaml file when we'll decouple the yamls. |
For now, only Annotations and Yaml are supported. XML will come later.
Done :) The configuration files are searched in |
I guess we can merge it now and get some feedback from users. |
Support alternative mapping formats
This PR provides support for yaml mapping description (in addition to annotations).
Implementing XML support should be an easy task.