Skip to content
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

Implement configuration via container extensions #17

Merged
merged 5 commits into from Jul 28, 2014
Merged

Implement configuration via container extensions #17

merged 5 commits into from Jul 28, 2014

Conversation

ghost
Copy link

@ghost ghost commented Jul 28, 2014

This means you can configure the bundle settings without extending
the base controller class.

For example: you can add these settings to your config.yml file

c33s_static_pages:
    content_bundle: MyBundle
    content_dir:    Pages

You can either look at the Configuration class or run
app/console config:dump-reference c33s_static_pages (after pulling) to see
a list of all current configuration parameters.

@ghost
Copy link
Author

ghost commented Jul 28, 2014

I think that the controller class should be renamed after this is merged. It's not really a base controller anymore.

@vworldat
Copy link
Collaborator

This change does not allow for several bundles to hold static content at the same time. For me this is a dealbraker. I want to be able to:

  • have content in several bundles/controllers
  • use different "settings" (e.g. base template) depending on the controller being used

This is easily possible at the moment, but not with your changes. What about changing the config to something like this:

c33s_static_pages:
    My\Bundle\Controller\MyController:
        content_dir:    Pages
        wrapper_template: something
        # ...
    My\Bundle\Controller\OtherController:
        content_dir:    Stuff
        wrapper_template: something
        # ...
    My\OtherBundle\Controller\MyController:
        content_dir:    Sites
        wrapper_template: something
        # ...

Not that I want to change these settings all the time, but I need to have various configurations at the same time.

Edit: this would again require separate controllers, I will think of something else. Not quite woken up yet ;-)

@ghost
Copy link
Author

ghost commented Jul 28, 2014

ah that was next on my list. i didn't realize this bundle was that popular to get a comment so quickly.

$contentName,
$this->getTranslationFilePath(),
$this->getTemplateExtension()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing: please do not remove those calls. They are extremely important for cases in which the class is extended. Why not just let the getTemplateExtension() method return the container-getParameter() call?

@ghost
Copy link
Author

ghost commented Jul 28, 2014

@vworldat that's exactly what i just did, since i think the work of making the configuration parser recursive deserves it's own pull request. I figured i'd implement that later.

However.. I am against having a bloated controller. the way you suggested before is a more correct way of doing it. I definitely don't wanna have a bunch of configurable methods in a controller.

I was planning on moving all that configurable stuff out to a template locator service.

@ghost
Copy link
Author

ghost commented Jul 28, 2014

@c33s : i kept compatibility with the current controller methods as suggested by @vworldat . This should be mergeable now and it doesn't even break BC

@vworldat
Copy link
Collaborator

Well, actually a dedicated service to handle configuration / templates / etc would be great. I just don't have any idea yet, how this can be combined with the routing configuration. Using templates from several locations under several URLs might lead to something like this:

#routing.yml

some_bundle_webpage_static:
    pattern:  /some/path/{name}
    defaults: { _controller: "SomeWebpageBundle:StaticPage:show" }
    requirements:
        name:  .*

my_bundle_webpage_static:
    pattern:  /{name}
    defaults: { _controller: "MyWebpageBundle:StaticPage:show" }
    requirements:
        name:  .*

This also is how it is currently used by me and @c33s (we were both involved in the basic development of the package).

Johnny Robeson added 5 commits July 28, 2014 06:47
This adds configuration for all the extendable methods from
the controller class.

Currently this only supports the yaml file format.

You can view all the configuration options by reading the Configuration
class or running  `app/console config:dump-reference c33s_static_pages`
@ghost
Copy link
Author

ghost commented Jul 28, 2014

sorry for all the churn.. this should be good to go now.

@ghost
Copy link
Author

ghost commented Jul 28, 2014

@vworldat, @c33s : are either of you on freenode irc? if you got a minute we could discuss how to handle that usecase there.

@vworldat
Copy link
Collaborator

Please give me 30 to 45 minutes, then I'll be able to join. Which channel?

@ghost ghost mentioned this pull request Jul 28, 2014
@ghost
Copy link
Author

ghost commented Jul 28, 2014

I think that's a bit soon for me. I'm going to bed soon, and we could probably end up talking for awhile.

I'll just think a bit longer and then try to meet up soon.

Hopefully the PR is good to go now?

@ghost
Copy link
Author

ghost commented Jul 28, 2014

i guess the only thing that should be changed is maybe c33s_static_pages: to c33s_static_content.

If it's ok other than that.. then please say so. so i can start using it in my own fork until you folks actually merge it.

@vworldat
Copy link
Collaborator

Since this is work in progress anyway, I think we can just leave it at that for now.

vworldat added a commit that referenced this pull request Jul 28, 2014
…ions

Implement configuration via container extensions
@vworldat vworldat merged commit 91c3749 into c33s:master Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant