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

Add template logic for nested data #30

Merged
merged 4 commits into from
Oct 25, 2018
Merged

Add template logic for nested data #30

merged 4 commits into from
Oct 25, 2018

Conversation

JoshuaCarter
Copy link
Contributor

JSON data given to template components can now have nested arrays of iterable children (see the SubNavigation example from front-end-tooling). Test included.

This PR resolves:

I would suggest making a new release for this addition.

Note: This change will also need to go into master, but as the source file is different, that will need to be a separate PR.

jcarter added 2 commits October 18, 2018 11:35
@JoshuaCarter JoshuaCarter self-assigned this Oct 18, 2018
Copy link
Contributor

@nglasl nglasl left a comment

Choose a reason for hiding this comment

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

@JoshuaCarter, have left a couple of things that jumped out to me, but looks good to merge and tag otherwise. The only thing missing actually would be a bump to the branch-alias in composer.json since this looks like a feature release.

*
* And implement '__set_state' to return a constructed ArrayList.
*/
class ArrayListExportable
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're defining a new class here, this should be contained in a new file.

Copy link
Contributor Author

@JoshuaCarter JoshuaCarter Oct 23, 2018

Choose a reason for hiding this comment

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

I did it that way because it's only for internal use in ComponentService, but I can see how it's bad, so I've split it out into it's own file.

* @param bool $root Ignore this
* @return string Executable template logic
*/
private static function exportNestedDataForTemplates(array $array, $root = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason this is static?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be a method, but as a static function it's clear that it doesn't interact with $this at all, it takes nestsed data, recurses it, and spits back the output. Whilst I think this is technically better/clearer, I'm happy to change it if you prefer.

Copy link
Contributor

@nglasl nglasl Oct 23, 2018

Choose a reason for hiding this comment

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

Hmm, while I don't disagree, if we're going to make it static I would lean towards making it public so it can be accessed from outside the service class. But for consistency purposes, it should probably stay public and non-static. Happy to leave this one to your judgement, just let me know what you decide on :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My vote is:

  • private: because it's too specific and niche to be externally useful. Else I would be all for making it public.
  • static: because it works independant of $this which is context I would find useful when navigating unfamiliar code, etc.

But I'm the noob here, so happy to be overridden.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed IRL, I can always see someone trying to access a private function, no matter how niche it is :) But I agree, private and static makes the most sense!

@JoshuaCarter
Copy link
Contributor Author

The branch alias on 1.1 branch was 1.0.x. I've bumped it to 1.2.x, but perhaps it should only be 1.1.x?

@nglasl
Copy link
Contributor

nglasl commented Oct 23, 2018

Ahh, forgot this was on the 1.1 branch. That likely means somebody forgot the bump the branch alias previously, so yeah 1.2.x would be correct. However, the branch alias only really matters for the master branch, so we just need to make sure that's the one we bump when it comes back into SS4 :)

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.

2 participants