-
Notifications
You must be signed in to change notification settings - Fork 43
Added escape characters for repository class name #66
Conversation
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.
@@ -70,7 +71,7 @@ public function getBySubject($subject) | |||
if (count($ids) < 2) { | |||
throw new RuntimeException("Invalid subject: $subject"); | |||
} | |||
$class = ltrim($ids[0], '/'); // if we get the / from the url, this breaks the class loader in a funny way. | |||
$class = $this->unescape(ltrim($ids[0], '-')); // if we get the - from the url, this breaks the class loader in a funny way. |
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.
i think you might still get /
at the beginning of the url. it has nothing to do with namespaces, but with how the url pattern is built.
@@ -31,6 +31,7 @@ class DoctrineOrmMapper extends BaseDoctrineRdfMapper | |||
'<' => '%3C', | |||
'>' => '%3E', | |||
'|' => '%7C', | |||
'\\' => '-', |
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.
the consistent would probably be to use %92
rather than -
.
the other option is to not use the escape function at all for the class name, but just string-replace \ with -
@dbu thanks for your feedback, I created a new commit with all the requested changes. |
@@ -70,7 +71,7 @@ public function getBySubject($subject) | |||
if (count($ids) < 2) { | |||
throw new RuntimeException("Invalid subject: $subject"); | |||
} | |||
$class = ltrim($ids[0], '/'); // if we get the / from the url, this breaks the class loader in a funny way. | |||
$class = str_replace('-', '\\', ltrim($ids[0], '/')); // if we get the / from the url, this breaks the class loader in a funny way. |
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.
can we separate this in two lines?
$class = ltrim($ids[0], '/'); // if we get the / from the url, this breaks the class loader in a funny way.
$class = str_replace('-', '\\', $class);
@dbu thanks for your quick feedback! |
Hi guys, sorry for the late reply, I'm on vacation until next week and only have sporadic connectivity. I'll look into this & will comment or merge when I have time |
@flack okay no problem, let me know when you can look in to it. I already made two implementations with CreateJS and Doctrine ORM and it works like a charm :-) https://github.com/rudott/create.js-kunstmaan-integration (based on the Kunstmaan bundles) |
@rudott Looks good so far!If you have the time, it would be nice to have a unit test which exhibits the problem. If not, just let me know, then I'll merge as-is |
This wil validate if the Subjectname does not contain backslashes
@flack I added a test for the subjectname in the DoctrineOrmMapperTest. |
Added escape characters for repository class name
Fixed issue: #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.