Visitar URL original
Added event listener to toggle TL_VIEW cookie by aschempp · Pull Request #26 · contao/core-bundle · GitHub
Skip to content

Added event listener to toggle TL_VIEW cookie - #26

Merged
leofeyer merged 7 commits into
contao:developfrom
aschempp:feature/toggle-view-listener
Dec 1, 2014
Merged

leofeyer merged 7 commits into
contao:developfrom
aschempp:feature/toggle-view-listener

Conversation

@aschempp

Copy link
Copy Markdown
Member

I started reviewing/working on the routing feature and stumbled over this part. The only difference I can see is the toggle action is executed everywhere and not only for regular pages, but I don't think that would be a problem?

@leofeyer leofeyer added this to the 4.0.0 milestone Nov 27, 2014
@leofeyer

Copy link
Copy Markdown
Member

Looks good, but you are not following the coding style and you have forgotten to add a test :)

@aschempp

Copy link
Copy Markdown
Member Author

I've fixed the yoda conditions and added unit tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should say: Sets the TL_VIEW cookie based on the "toggle_view" query parameter. (Also note the full stop at the end).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the user input is valid, toggle_view will be a string already ("mobile" or "desktop"). Otherwise the comparison will fail anyways, so the cast is actually not necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well the @return statement of the ParameterBag says it can be mixed…

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might be true, but it is still irrelevant. If $state is not a string, the comparison will fail. And that's correct.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lines 118 and 119 should be equally aligned.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@aschempp If you fix this last CS error, I can merge the PR.

@leofeyer

Copy link
Copy Markdown
Member

Thanks for applying all the changes. There's one remaining issue: System::setCookie() automatically sets the cookie path to Environment::get('path') if no custom path is passed as argument. This feature needs to be merged, too.

BTW, should we use the System class from the global namespace? Or should we add a use Contao\System statement? @contao/developers

@Toflar

Toflar commented Nov 27, 2014

Copy link
Copy Markdown
Member

Contao namespace! The global one is just for BC.

@aschempp

Copy link
Copy Markdown
Member Author

I've stumbled upon the namespace question too. I'd go for Contao namespace, but that's currently not the case anywhere…

@leofeyer

Copy link
Copy Markdown
Member

I know, because I wasn't sure either. I'll happily change it though :)

@aschempp

aschempp commented Dec 1, 2014

Copy link
Copy Markdown
Member Author

Fixed last issue, you can merge it now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants