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

Repository class name for ORM has slashes instead of backslashes because it's passed in the URL #65

Closed
rudott opened this issue Feb 28, 2014 · 5 comments

Comments

@rudott
Copy link
Contributor

rudott commented Feb 28, 2014

Hi there,

When using the Midgard\CreatePHP\MapperDoctrineOrmMapper, with the twig function createphp_attributes() will generate RDFA attributes like:
xmlns:schema="http://schema.org/" typeof="schema:Page" about="Acme\DemoBundle\Entity\Page|id=1"

That's ok, untill you want to save something via CreateJS..

The URL will change the Repository class name in : Acme/DemoBundleEntity/Page.

The fix for this could be in Midgard\CreatePHP\MapperDoctrineOrmMapper after this line:
#73 $class = ltrim($ids[0], '/'); // if we get the / from the url, this breaks the class loader in a funny way.

Putting this line.
#74 $class = str_replace('/', '', $class); // change slashes -> backslashes for the repository class

Is this an OK fix and should I commit it? Or should this problem be solved differently? (I also saw when passing the repository class name like AcmeDemoBundle:Page it also works).

I'm using:
"symfony/framework-standard-edition" 2.3.11

With the following extra bundles:
"symfony-cmf/create-bundle": "1.0.@dev",
"midgard/createphp": "0.9.
@dev"

Thanks in advance!

@dbu
Copy link
Collaborator

dbu commented Feb 28, 2014

this sounds strange. we played with this and it did work for us. do you have an idea at what point in the process the \ becomes /? in twig? or in javascript? or by your browser, or while sent to the backend? we could go for any character that is not valid in a class name, if \ is not url safe. like we could use . for example. / feels like a less than great idea for urls.

@rudott
Copy link
Contributor Author

rudott commented Feb 28, 2014

@dbu you are totally right, I think the best character is using the -, that will work in every browser and the fix would be in DoctrineOrmMapper in the function getBySubject, for chaning the - to an .

I only don't know what the correct place is for changing the Repository tag before it is send via Javascript.

Is it maybe a solutions for using class names like AcmeDemoBundle:Page instead of Acme/DemoBundleEntity/Page. That looks much cleaner to me..

@dbu
Copy link
Collaborator

dbu commented Feb 28, 2014

looking at https://github.com/flack/createphp/blob/master/src/Midgard/CreatePHP/Mapper/DoctrineOrmMapper.php#L102 it seems to me we might have an issue with escape / unescape either not working or not being called. can you investigate that? if that is not enough, i would change lines https://github.com/flack/createphp/blob/master/src/Midgard/CreatePHP/Mapper/DoctrineOrmMapper.php#L57 and https://github.com/flack/createphp/blob/master/src/Midgard/CreatePHP/Mapper/DoctrineOrmMapper.php#L73 to replace \ with - - that seems the most url safe thing we could use.

rudott added a commit to rudott/createphp that referenced this issue Feb 28, 2014
Fixed issue: openpsa#65

This will change the createphp_attributes output to something like:
xmlns:schema="http://schema.org/" typeof="schema:Page" about="Acme-DemoBundle-Entity-Page|id=1"

And added the unescape for getBySubject class name.
@rudott
Copy link
Contributor Author

rudott commented Feb 28, 2014

@dbu I added a pull request for this issue which solves it. If you got feedback, let me know!

@flack
Copy link
Collaborator

flack commented Mar 19, 2014

fixed by 8627540

@flack flack closed this as completed Mar 19, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants