-
Notifications
You must be signed in to change notification settings - Fork 348
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
made session flashes closeable with configuration #840
base: master
Are you sure you want to change the base?
Conversation
Couple things.. You should probably just pass the parameter to the twig extension instead of passing the whole container, and I'm not sure about adding another global variable to Twig, I wonder if it makes more sense to make it a function and then call it when you want the value? I'm not really sure what the best option is for doing something like that. |
Also, we don't need the initRuntime / environment variable. |
I dont know how to only pass the argument in the service, in Symfony 2.4 it would be something like this <argument type="expression">@=container.hasParameter('mopa_bootstrap.flash.closeable') ? parameter('mopa_bootstrap.flash.closeable') : false</argument> But in <2.4 I have no idea - I have tried with <argument type="string">@=container.getParameter('mopa_bootstrap.flash.closeable')</argument> But this obvious does not work - anybody knows which argument type it should be? |
%path.to.parameter% You don't need expression language at all
|
And you'll either need to set the parameter regardless or do: if (isset($config['flash']) {
// ...
} else {
$container->removeDefinition('mopa_bootstrap.twig.extension.bootstrap_flash');
} |
Now if If If the config mopa_bootstrap:
flash:
closeable: true is set, it will show the X |
Why are you using setting injection? Just add it to the constructor |
Well, mostly Im fan of getters and setters, and not passing everything to the contructor - but well its a personal reference :) |
I mean, there's really no use for a setter here, the twig extension is pretty specific. I would just change the global variable to a function just like the mappings. No need to add global variables for this to be inserted into every single template render. |
@lsv any news? |
He made the changes. Only thing I'm not crazy about is the $close === null part, I think this could be done in twig with a |default() |
Remember $this->closeable is always set as either true or false (false is standard) Im pretty sure |default only gets called when the return value is null |
Yeah I get that, it just seems like an unnecessary thing to put in a getter. Could change it to just be like this:
or
That should be fine too if you don't pass in a |
So in the twig you want
|
or
I think the first is better |
The second is so much more readable - the first is really hard to see what its actually does imo |
@lsv is this ready to merge ? |
I'd still like the weird getter to be fixed and needs a blank line before the return statement to be PSR. |
29c9954
to
6708dba
Compare
@lsv can you update the PR, then we could merge it asap.. |
@isometriks what should we do with this? |
Eh, I don't like that variable passthrough though, I'd rather use |
With the following configuration
Session flashes are now closeable, meaning it adds the X to flash message