Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Closed
wants to merge 1 commit into from
Closed

CMF Resource provider #288

wants to merge 1 commit into from

Conversation

dantleech
Copy link
Member

This PR introduces a route provider for Puli resources via. the CMF
ResourceBundle.

Adding resource support means

  • Possiblity to have context-aware route repositories, i.e. resolve different routes dending on the host or other critriea.
  • Possiblity for cascading route resolution
  • Possiblity for combining different route sources in the same route tree.


if ($config['map_orm']) {
$container->setParameter($this->getAlias() . '.backend_type_orm', true);
}
Copy link
Member Author

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?

@dantleech
Copy link
Member Author

This almost works, see the question above about prefixes.

@dbu
Copy link
Member

dbu commented Jan 29, 2015

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?

@dantleech
Copy link
Member Author

The way this is configured at the moment, it is functionaly equivilent to the PHPCR-ODM router as we have configured the PhpcrRepository directly.

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')
Copy link
Member

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

@lsmith77
Copy link
Member

lsmith77 commented Feb 4, 2015

@webmozart BTW what is the ETA for a stable Puli release?

@webmozart
Copy link

@lsmith77 March 2015. I want to publish a RC in February.

@dantleech dantleech self-assigned this Mar 11, 2015
@lsmith77 lsmith77 added this to the 1.4 milestone Jun 17, 2015
@dbu
Copy link
Member

dbu commented Aug 21, 2015

@dantleech now that puli is released, any chance that you wrap this up?

@dbu
Copy link
Member

dbu commented Aug 21, 2015

and does this still belong here or rather into the ResourceBundle?

@dantleech
Copy link
Member Author

I think this would depend on a release of the Resource lib. and bundle
so I think effort should go there first.

I am currently dedicating nearly all of my resources to another project
so don't have time to get back into Resource stuff atm, but maybe late
next month.

With respect to where this belongs, it probably doesn't belong here, at
least while the Resource stuff is still experimental. Is it in the scope
fo this bundle to provide third-party route providers?

On Fri, Aug 21, 2015 at 05:03:55AM -0700, David Buchmann wrote:

and does this still belong here or rather into the ResourceBundle?


Reply to this email directly or [1]view it on GitHub.

Reverse link: [2]unknown

References

Visible links

  1. CMF Resource provider #288 (comment)
  2. CMF Resource provider #288 (comment)

@dbu dbu removed this from the 1.4 milestone Aug 21, 2015
@dbu
Copy link
Member

dbu commented Aug 21, 2015

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.

@dbu
Copy link
Member

dbu commented Aug 21, 2015

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.
@dantleech
Copy link
Member Author

As I am moving the code now I see why I put it here in the first place.
The RoutingBundle already natively supports both the Doctrine ORM and
PHPCR-ODM route providers. Why shouldn't it, in theory, also support the
CMF/Puli resources?

On Fri, Aug 21, 2015 at 06:17:16AM -0700, David Buchmann wrote:

i removed the milestone. if you agree, move the code to ResourceBundle and
close this.


Reply to this email directly or [1]view it on GitHub.

Reverse link: [2]unknown

References

Visible links

  1. CMF Resource provider #288 (comment)
  2. CMF Resource provider #288 (comment)

@wouterj
Copy link
Member

wouterj commented Aug 21, 2015

I actually believe in the future, the resource provider might take over both other route providers. Resource can handle PHPCR, ORM, filesystem, etc. natively.

@dbu
Copy link
Member

dbu commented Aug 21, 2015 via email

@dantleech
Copy link
Member Author

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.

@wouterj
Copy link
Member

wouterj commented Aug 23, 2015

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

@dantleech
Copy link
Member Author

Could we not just have it default to default and keep the option to use an alternative repository?

@wouterj
Copy link
Member

wouterj commented Aug 23, 2015

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.

@dantleech
Copy link
Member Author

Not sure what you mean by "tagging"?

@wouterj
Copy link
Member

wouterj commented Aug 24, 2015

Sorry, type binding. As shown in my comment above, using Puli Discovery.

@dantleech
Copy link
Member Author

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.

@webmozart
Copy link

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 Cmf\Resource\ResourceBundle. You'll be able to annotate this interface:

/**
 * @BindingType
 * @Subject("RESOURCE")
 */
interface ResourceBundle {}

or continue to mark it as binding type with the CLI:

$ puli type --register Cmf\\Resource\\ResourceBundle

Furthermore and most important, it will be possible to bind class names:

/**
 * @BindingType
 * @Subject("CLASS")
 */
interface Service {}
$ puli bind My\\ConcreteService Cmf\\Api\\Service

This could be useful here.

@wouterj
Copy link
Member

wouterj commented Aug 24, 2015

Especially that second feature would be usefull :) (I assume the code of puli bind will be available as a normal PHP method that we can use in the ResourceBundle?)

@webmozart
Copy link

@wouterj of course, same as now :)

@webmozart
Copy link

See puli/issues#114 for more detail

@wouterj wouterj modified the milestone: 2.0 Oct 28, 2015
@dbu
Copy link
Member

dbu commented Jun 14, 2016

@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.

@dantleech
Copy link
Member Author

@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.

@wouterj
Copy link
Member

wouterj commented Jun 14, 2016

This should be closed in favor of #314 btw

@dantleech
Copy link
Member Author

oh, didn't see that one :) well done.

@dantleech dantleech closed this Jun 14, 2016
@dantleech dantleech removed the review label Jun 14, 2016
@dbu dbu deleted the resource_provider branch June 14, 2016 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.