Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

add doctrine orm mapper and cleanup the base mapper to have no phpcr specific code #55

Merged
merged 1 commit into from
Nov 18, 2013
Merged

add doctrine orm mapper and cleanup the base mapper to have no phpcr specific code #55

merged 1 commit into from
Nov 18, 2013

Conversation

dbu
Copy link
Collaborator

@dbu dbu commented Oct 10, 2013

the changes in the phpcr mapper should be no bc break so it should be fine to put into the 0.9 which master currently represents.

this PR does not cover to not expose class names publicly as this involves more refactoring on the library. i created a feature request for that: #57 . same holds about #58, it would be nice to be able to mix objects from various mappers but its out of scope for this PR.

{
$idstring = parent::createSubject($object);

return $this->canonicalName(get_class($object)) . "-$idstring";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this will expose the FQN in the frontend. do we want this? is there something to ask doctrine class metadata for a short name that we can afterwards use to get the repository / original class?

/cc @lsmith77

Choose a reason for hiding this comment

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

not sure .. @stof, @beberlei ?

Choose a reason for hiding this comment

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

In perfect scenario we can configure subject per class. What do you think? Can we do this in createphp metadata?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lsmith77 well, getting the metadata is either the FQCN or alias:relative_name (alias: gets replaced by the namespace corresponding to the alias). But it is still leaking the class name to the frontend.

If you don't want to leak class names, you should build a map of class names to frontend resource (and back if necessary). such mapping could then be useful for other implementations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will check if we can put that into the metadata somewhere, optionally and otherwise fallback to the class. Could the backslash cause issues? Should i use . instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i created #57 for this. i think the framwork would be ready for that, its just that nobody implemented the additional step needed to build a map.

@pjedrzejewski
Copy link

@lsmith77 @dbu Once this one is merged (many thanks!), I'd love to integrate Symfony CMF CreateBundle into Sylius. Does the bundle need any changes to work with ORM, if yes, can I help somehow?

@dbu
Copy link
Collaborator Author

dbu commented Oct 14, 2013

the bundle will need something to provide the orm mapper. i added an issue at CreateBundle symfony-cmf/create-bundle#87 - @pjedrzejewski if you want to play with this already, you could use the fork of createphp with the branch and try the bundle thing. might give us valuable inputs as well.

thanks for all the feedback. i will clean up the PR as soon as possible. these are things that won't make it into cmf 1.0.0 we are releasing today. i have to focus on one after the other.

if (count($ids) < 2) {
throw new RuntimeException("Invalid subject: $subject");
}
$repository = $this->om->getRepository($ids[0]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we discovered that accidentally having / at the beginning of a FQN will lead to php finding the class and loading it, but not realizing its already loaded so it tries to load again and does a "FatalErrorException: Compile Error: Cannot redeclare class ...".

we hacked around this with str_replace('/', '', ltrim($ids[0], '/'));

@dbu
Copy link
Collaborator Author

dbu commented Nov 17, 2013

i now added a test about the escaping as well, seems to work fine.

@flack could you try to activate travis for PRs in this repository? would be nice to see if travis agrees with my local setup that this is working.

@flack
Copy link
Collaborator

flack commented Nov 17, 2013

@dbu This should work already, or at least it did last year. travis seems to be down ATM, so maybe this is the reason why you don't get any feedback. When it's back up, I'll take a look to see if the settings are ok

@dbu
Copy link
Collaborator Author

dbu commented Nov 17, 2013

oh, indeed. i was wondering why i don't see any travis info in the PR header. anyways, tests locally succeed.

does it make sense for you what we do here? ok to merge, or do you want the BC method? should we start a CHANGELOG.md file to record BC breaks and other notable changes?

@flack
Copy link
Collaborator

flack commented Nov 17, 2013

+1 for CHANGELOG.md, it's getting quite hard to remember all the relevant changes between releases.

I think the createSubject removal is fine, considering that our major release number is still zero. Adding a note to the changelog should cover it just fine. I wonder if we shouldn't change the branch-alias anyways, but I don't have much experience with using this, so I would rely on your judgement.

In general the PR looks good to me. The ORM subject logic is not exactly pretty, but I guess it can't be helped. I've added a couple of line notes about minor concerns, but otherwise, this is good to merge

@dbu
Copy link
Collaborator Author

dbu commented Nov 18, 2013

okay, updated to escape <>"'\n and extracted escape method, and squashed the commits.

flack added a commit that referenced this pull request Nov 18, 2013
add doctrine orm mapper and cleanup the base mapper to have no phpcr specific code
@flack flack merged commit 6b980de into openpsa:master Nov 18, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants