-
Notifications
You must be signed in to change notification settings - Fork 29
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
Warning with cakephp3.5 #60
Comments
Could you also include |
You'll find it attached here. 3d5e0211dc28c59bab413b8dac0ddbe4bc9521105d145d749578bb453c993008.zip |
Sorry, I have included the wrong file, here's the good one. 9354f08c1f47e54248409d9f11b74ab4e9f9d332c0df7ef5d38a4a486cb660cb.zip |
Some methods return I've found a workaround for this, use {{ _view.assign('title', __("I'm title"))|none }} |
What about {% _view.assign('title', __("I'm title")) %} {# execute setter #} Edit: That's sadly not the way Twig works.
{{ _view.fetch('title') }} {# just echo #} Edit: fixed |
@inoas have you checked if your examples work, or maybe you are just guessing? |
Half guessing. I do only use a few parts of TwigView in my projects and I am not using Trying: p.s.: I could not even find the docs for |
Ok, so please don't mislead people :)
|
Ok, so please don't suggest to use dirty hacks :) The problem here is that CakePHPs minor release is non-BC. |
As I said it is a workaround which actually works. |
It does not. You still need |
I'll ask again: have you tried this or still guessing? |
Have you, I have. |
I use this workaround successfilly in my code. Are we talking about the same?
|
Yes that will work, despite being a hack (running Can you see a better way to get around the hack required because of assign/set returning |
We should probably revert the changes in CakePHP then. |
Well 3.5 has been out for some time now and that could have impacts too(?) so my suggestion (disclaimer @robertpustulka I have tried it, right now ;-) would be, to overwrite // in TwigView:
public function assign($name, $value)
{
$this->Blocks->set($name, $value);
} |
@inoas That is another option as well. I can put together a pull request for that if it would be helpful. |
I'll wait for @WyriHaximus to chime in and if he concurs I will do that and hopefully also add working unit tests. |
@inoas This could work 👍 |
Summary: We should either revert CakePHP 3.5 or fix TwigView 4.x & 5.x to make sure existing Twig templates run without touching them (production etc). A quick copy&adapt. I am not sure we ll need/want all of them (consistency? would you set the template path within a twig-template, ever, etc)? In /**
* {@inheritDoc}
* @return void
*/
public function setTemplatePath($path)
{
parent::setTemplatePath($path);
}
/**
* {@inheritDoc}
* @return void
*/
public function setLayoutPath($path)
{
parent::setLayoutPath($path);
}
/**
* {@inheritDoc}
* @return void
*/
public function enableAutoLayout($enable = true)
{
parent::enableAutoLayout($enable);
}
/**
* {@inheritDoc}
* @return void
*/
public function setTemplate($name)
{
parent::setTemplate($name);
} These for sure: /**
* {@inheritDoc}
* @return void
*/
public function setTheme($theme)
{
parent::setTheme($theme);
}
/**
* {@inheritDoc}
* @return void
*/
public function setLayout($name)
{
parent::setLayout($name);
}
/**
* {@inheritDoc}
* @return void
*/
public function start($name)
{
parent::start($name);
}
/**
* {@inheritDoc}
* @return void
*/
public function prepend($name, $value)
{
parent::prepend($name, $value);
}
/**
* {@inheritDoc}
* @return void
*/
public function append($name, $value)
{
parent::append($name, $value);
}
/**
* {@inheritDoc}
* @return void
*/
public function assign($name, $value)
{
parent::assign($name, $value);
}
/**
* {@inheritDoc}
* @return void
*/
public function reset($name)
{
parent::reset($name);
}
/**
* {@inheritDoc}
* @return void
*/
public function end()
{
parent::end();
}
/**
* {@inheritDoc}
* @return void
*/
public function extend($name)
{
parent::extend($name);
} Question: I assume about the same amount of functions that should go inside TwigView would otherwise need to become Twig Tags for TwigView + CakePHP 3.5 to run without changes on Templates? |
Another option I thought of is to implement |
I am going to give this a try before hacking other ways. |
I gave it a try locally (in my SimpleTwigView ... but it should be the same). Within your
|
@inoas I'll test it and dive into this issue tomorrow 👍 |
@inoas I was proposing to implement __toString() on CakePHP's view class. |
@inoas You are dead-wrong. This is not a BC break from the framework perspective. That said, the solution now provided seems to fix this in some way. So seems to be all good with the next patch release. Just be a bit more careful with your accusations, please :) |
Ideally a "native" support for Cake blocks would be great. Something like: {% start 'header' %}
<h1>Title</h1>
{% end %} {% append 'header' %}
<h2>Subtitle</h2>
{% end %} {% fetch 'header' %} |
Edit: @robertpustulka yep, however:
|
The change is from returning I suspect that you expected that Please, again, get your facts straight before you start telling people that they are wrong.
Yes. I'm talking about a future plugin release. IMO there needs to be some other way of manipulaitng Cake blocks. Currently the state changing functions ( |
As I can take care and implement the tags for |
@inoas But you complained about 3.5 in particular. But the only change there was cakephp/cakephp#11134 which is BC (void to $this is always BC as per BC guidelines). |
4.0.6 has been tagged with a fix for this thanks to @inoas 👍 |
Same/Similar Issue: cakephp/cakephp#11276 (comment) |
Hello,
When i run TwigView on a CakePhp 3.5, with this code,
i got those warnings :
The text was updated successfully, but these errors were encountered: