-
Notifications
You must be signed in to change notification settings - Fork 76
CMF Resource provider #288
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
Conversation
|
||
if ($config['map_orm']) { | ||
$container->setParameter($this->getAlias() . '.backend_type_orm', true); | ||
} |
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.
We have a small problem here: The resource bundle could potentially use either or both of the PHPCR/ORM Route document/entities. So I have added options to trigger the adding of those folders to doctrine.
However, we also need to have the "prefix" stuff working at least for the PHPCR-ODM documents.
Any ideas?
56716ff
to
c98f1a8
Compare
This almost works, see the question above about prefixes. |
i have problems seeing how this is different from the phpcr router. i thought you check puli for a file and provide a route to download that file. but this is doing something else. i don't know enough of puli to exactly understand what the point of this is. can you explain that a bit please? does this belong into this repo or into one of the resource repositories? |
The way this is configured at the moment, it is functionaly equivilent to the PHPCR-ODM router as we have configured the However, it becomes more interesting when you use a more fancy repository, such as a "context aware" repository which would change the repositories base path depending on the host (multi-portal/site). Or if you use a composite repository to combine several different route sources into a single tree. Or you could use a cascading repository try a sequence of repositories, for example first try Site A, then Site B then fallback to Default Site. |
->children() | ||
->scalarNode('repository_name')->isRequired()->end() | ||
->booleanNode('map_orm') | ||
->info('Enable the RoutingBundle\'s Doctrine PHPCR Route Documents to be mapped') |
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 accidentally swapped the info text
@webmozart BTW what is the ETA for a stable Puli release? |
@lsmith77 March 2015. I want to publish a RC in February. |
@dantleech now that puli is released, any chance that you wrap this up? |
and does this still belong here or rather into the ResourceBundle? |
I think this would depend on a release of the Resource lib. and bundle I am currently dedicating nearly all of my resources to another project With respect to where this belongs, it probably doesn't belong here, at On Fri, Aug 21, 2015 at 05:03:55AM -0700, David Buchmann wrote:
|
actually i feel the ResourceBundle would be the more natural fit for this. its all about resources. but of course in most real-world scenarios, one would want to use this provider with the CmfRoutingBundle to hook the provider into the dynamic router for example. |
i removed the milestone. if you agree, move the code to ResourceBundle and close this. |
This PR introduces a route provider for Puli resources via. the CMF ResourceBundle.
As I am moving the code now I see why I put it here in the first place. On Fri, Aug 21, 2015 at 06:17:16AM -0700, David Buchmann wrote:
|
I actually believe in the future, the resource provider might take over both other route providers. Resource can handle PHPCR, ORM, filesystem, etc. natively. |
alright, then lets add it here. can you rebase and update the PR?
|
c98f1a8
to
bb91709
Compare
Rebased -- but merging would depend on a stable release of the Resource stuff and also I or somebody would have to invest time in this as it is probably non trivial. |
Hmm, I'm not sure if I really like the way this PR works. Basically, this PR lets you configure a repository for the routing stuff. This means we are limited to one repository and the RoutingBundle config is aware of the backend type (as that's the repository). I'm more thinking about only 1 repository per application: The default repository. This can then be configured by the CmfResourceBundle. This allows you to, for instance, bind multiple different backends to the default Composite repository. Using the Puli Discovery component, the RoutingBundle can then find all routes: class ResourcesRouteProvider // ...
{
// ...
public function getRouteCollectionForRequest(Request $request)
{
$path = $request->getPathInfo();
foreach ($this->getPaths($path) as $targetPath) {
$this->findRoutes($targetPath, $collection);
}
}
private function findRoutes($path, $collection)
{
$bindings = $this->discovery->findByPathAndType($path, 'cmf/routes');
foreach ($bindings as $binding) {
foreach ($binding->getResources() as $resource) {
// ...
}
}
}
} Configuration then looks like: cmf_resource:
repositories:
routing_phpcr:
type: doctrine_phpcr_odm
basepath: /cmf/routing
default:
type: composite
mounts:
- { repository: routing_phpcr, mountpoint: /phpcr/routes }
bindings:
- { path: /phpcr/routes, type: cmf/routes }
cmf_routing:
persistence:
resource:
repository: default |
Could we not just have it default to |
Yeah, we should still allow other repository names as well. However, I think tagging is really the implementation we need here, as it allows to have routes in multiple locations. E.g. simple cms documents and routes. |
Not sure what you mean by "tagging"? |
Sorry, type binding. As shown in my comment above, using Puli Discovery. |
ok yeah, so you would configure whatever repositories in the ResourceBundle, "bind" them to a Puli type and then let the Discovery component handle the rest in the RoutingProvider, sounds like the best way to do it. |
In case this is relevant here: the Discovery component will be extended in beta8. Binding types will become actual PHP interface (or class) names such as /**
* @BindingType
* @Subject("RESOURCE")
*/
interface ResourceBundle {} or continue to mark it as binding type with the CLI:
Furthermore and most important, it will be possible to bind class names: /**
* @BindingType
* @Subject("CLASS")
*/
interface Service {}
This could be useful here. |
Especially that second feature would be usefull :) (I assume the code of |
@wouterj of course, same as now :) |
See puli/issues#114 for more detail |
@wouterj @dantleech is this a blocker for the 2.0 bundle? i guess we can't really do it in a BC way so if its not in 2.0 it will have to wait for quite a while. but i really want to get 2.0 moving to get symfony 3 support. |
@dbu I see this as a feature, not a BC break. We would just be adding a new Provider .. ? In which case we can release 2.0 and put this in 2.1 if it turns out to be a worthy addition. |
This should be closed in favor of #314 btw |
oh, didn't see that one :) well done. |
This PR introduces a route provider for Puli resources via. the CMF
ResourceBundle.
Adding resource support means