-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
Currently depends on: doctrine/phpcr-odm#372 |
cool .. still in the Ukraine so not sure yet when I can help review. one thing though .. we should try to update this Bundle soon to our standards to prevent more people from suffering from BC breaks. |
Probably ... I am somewhat reluctant to do it atm as it will probably I am planning a medium refactor to enable (the possiblity at least) for On Sat, Oct 26, 2013 at 08:28:32AM -0700, Lukas Kahwe Smith wrote:
|
ok -- this does not seem to be possible with the PHPCR-ODM at the moment, at least in the way that I am doing this. The RoutingAutoBundle gets the scheduled inserts and updates determines if there are any candidates for "auto routing" and then creates the auto routes and adds them to the insert/update schedule. So far so good. Problem: To retrieve the translated fields of the subject of the "auto routing" PHPCR-ODM requires that the document be persisted. There are two solutions I can think of:
In anycase, doing anything after the flush would be sub optimal. |
+1 for moving to bundle standards and working towards a stable release. post flush would be sad, we would need another flush, and i think i commented on the phpcr-odm issue that i think getLocalesFor and |
|
||
if ($route instanceof AutoRoute) { | ||
$routeParent = $route->getParent(); | ||
$id = spl_object_hash($routeParent).$route->getName(); |
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.
This is a potential edge case fail. Current there is no way to reliably retrieve the ID of a non-persisted document. The AutoRoute uses setParent and setName (which allows renaming) as opposed to setId (which causes a fail because the ID is immutable).
This means that I cannot use $metadata->getIdentifierValue
. Here I get the object hash of the parent and append the name of the autoroute.
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 should use $dm->getUnitOfWork()->getObjectIdentifier($obj) and not the metadata method.
we will deprecate the metadata->getIdentifierValue method in phpcr-odm 1.1, it makes little sense (its not even guaranteed that the id is mapped to the document, as parent and name completely identify the document). see also doctrine/phpcr-odm#368
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.
Its getUnitOfWork()->getDocumentId()
- but this doesn't work here as the Route documents are generated each time (they are not managed, they are NEW
) and the getDocumentId
method only works for Managed documents.
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.
okay, i got confused by your initial comment i think ;-)
you do not build the object id anyways, that would be the repository path. the uow method that indeed is called getDocumentId gets you the path by document object, using the spl_object_hash. so you use this to generate a random id, correct? i think spl_object_hash is a bad random id, as its basically the memory pointer to the object. should you not rather just use rand() here, to reduce the probability of a clash as much as possible?
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.
No, its not for a random ID - it needs to be an identifier which represents the path of the generated route.
The builder now iterates over each of the translations and generates a route stack for each. Therefore in the collection route stacks there is a very good chance of having route objects with duplicate paths. e.g.
/this/is/a/path/to/fr/article-en-francais
/this/is/a/path/to/en/article-in-english
The route representing /this/is/a/path
appears in both stacks but it needs (and has to be) persisted only once.
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.
seems to be too early for me. you hash the parent. so you would hash the same object and would want to get the overlaps. fine then.
ok... this works! Depends on : doctrine/phpcr-odm#375 |
i commented on the phcpr-odm PR. i think it is really going in the right direction. if we can wrap the phpcr-odm fix up this week, i can tag 1.0.1 of phpcr-odm later this week. |
$id = spl_object_hash($routeParent).$route->getName(); | ||
} else { | ||
$metadata = $dm->getClassMetadata(get_class($route)); | ||
$id = $metadata->getIdentifierValue($route); |
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.
okay, and as the route happens to have the id field mapped, this will work. nonetheless, we probably will deprecate this method in favor of $dm->getUnitOfWork->getDocumentId(). why don't you simply do $route->getId()? as you know the class of $route, you know that method is existing.
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.
Yeah, this works for Route but not for AutoRoute
which uses the parent
strategy. The problem is that I cannot gurantee, here, that the Route is a specific class. It could be anything as the user can implement their own Maker classes.
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.
unless you have the identifier mapped on your class, the metadata->getIdentifierValue method will not be able to return you something.
isn't uow getDocumentId populated as soon as persist was called?
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 don't think that these routes are persisted at this point. I would need a way to infer the path from the strategy.
What's the state of this issue? Will this be fixed in a feature release? |
@bertjh we are waiting on doctrine/phpcr-odm#375 - which is very nearly done, after that this is fine. |
@dantleech Any idea about a working timeframe? |
@bertjh well, theoretically the Doctrine PR just needs a rebase and merge. I just need to sit down and work on this -- luckily I start my vacation tomorrow so if all goes well it should certainly be OK next week. |
@dantleech Great, don't work to hard and have a nice Christmas! |
@@ -13,7 +13,8 @@ | |||
"require": { | |||
"symfony-cmf/routing-bundle": "1.1.*", | |||
"symfony-cmf/core-bundle": "1.0.*", | |||
"aferrandini/urlizer": "1.0.*" | |||
"aferrandini/urlizer": "1.0.*", | |||
"doctrine/phpcr-odm": "dev-master as 1.0.x-dev" |
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.
This PR needs dev-master of PHPCR-ODM -- how should we handle that?
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 that is ok like this .. we will, just like for 1.0, first release phpcr, then jackalope, then phpcr odm and only then the bundles
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.
should we not depend on phpcr-odm 1.1.* with a minimum stability of dev? everything should be ok with phpcr-odm 1.1 or if not we need to fix that.
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.
then we should use 1.1.*@dev
, we should not use unstable versions for all packages because one needs an unstable version.
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.
ok, will change to @wouterj 's suggestion.
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.
Actually, that doesn't work as testing relies on 1.0 -- I think leaving it as "as 1.0.x-dev" is best for now. This bundle isn't stable yet.
This is working now with
|
[WIP] Adding support for multilang
Pop. |
Thank you! Now only #37 needs to be finished before we can refactor to bundle standards and tag stable, isn't it? |
Yep.. my next job :) |
@dantleech How can I import this commit in my composer.json? I tried adding a specific commit ( "symfony-cmf/routing-auto-bundle": "dev-master#e325fed1ee45aa903519778a186685712ce657fb" ) but then it starts complaining about mismatching phpcr-odm versions.
|
@bertjh this requires a fix scheduled for the 1.1 release of PHPCR-ODM, other CMF components depend on version 1.0 currently. You can include the latest version (or any version you want) using an alias:
|
@dantleech Thanks for the info. The fix was adding PHPCR-ODM to my composer.json.
|
@dantleech When will the other CMF components be updated to support #33? |
@bertjh when CMF 1.1 will be released I think. |
@wouterj What's the planning on that? I'm trying to build my own CMS, and this is kind of essential. |
@bertjh I thought we planned in the end of January |
@wouterj Our deadline is the 1st of Februari. Is it possible to speed this up a little? |
@bertjh doctrine phpcr-odm is planned to release 1.1 in 12 days (https://github.com/doctrine/phpcr-odm/issues?milestone=2 ). I think Sonata admin will be updated to doctrine 1.1 after that release and then you can use the master version of Sonata admin and everything should work. |
@wouterj OK. I'll wait for that. Fijne jaarwisseling! |
This PR adds multilang support to RoutingAuto