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

Support shared site.contentType.php controller #6950

Open
wants to merge 1 commit into
base: v5/develop
Choose a base branch
from

Conversation

distantnative
Copy link
Member

@distantnative distantnative commented Jan 24, 2025

Description

Summary of changes

  • Allows content representation-specific site controllers, e.g. site.json.php
  • Either site.php or the more specific representation site controller get merged into any other controller, but never both

Reasoning

Allows to globally provide data to all controllers/templates that only a specific content type needs.

Additional context

  • To discuss:
    • Requesting blog.rss with no blog.rss.php controller would take the regular blog.php controller merged with a potentially existing site.rss.php controller. Seems a bit weird, but probably also not harmful. Not sure how I feel about it.
    • See my own review comments on difficult parts
  • Please review the unit tests closely if each configuration ends in the results you would expect as well.

Changelog

Enhancement

  • Support for content representation specific site controllers, e.g. site.rss.php

Ready?

  • In-code documentation (wherever needed)
  • Unit tests for fixed bug/feature
  • Tests and CI checks all pass

For review team

  • Add changes & docs to release notes draft in Notion

@distantnative distantnative added the needs: discussion 🗣 Requires further discussion to proceed label Jan 24, 2025
@distantnative distantnative self-assigned this Jan 24, 2025
@distantnative distantnative added this to the 5.0.0-beta.3 milestone Jan 24, 2025
if ($controller = $this->controllerLookup('site')) {
$data = (array)$controller->call($this, $arguments);
$site = $this->controllerLookup('site', $contentType);
$site ??= $this->controllerLookup('site');
Copy link
Member Author

Choose a reason for hiding this comment

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

Discuss: Is it ok that we use either or? Or should both site controllers be used, if available?

'template' => 'another'
]);

ob_start();
$app->controller('another.json', [], 'json');
Copy link
Member Author

Choose a reason for hiding this comment

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

Question: Was it ever right to have this test calling with another.json as name and json as contentType instead of another and json?

@@ -1,3 +1,5 @@
<?php

echo json_encode(['foo' => 'bar']);
Copy link
Member Author

Choose a reason for hiding this comment

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

Question: Why would the controller echo the JSON? Isn't that the job of the template in a content representation?

@distantnative distantnative marked this pull request as ready for review January 24, 2025 19:43
@distantnative distantnative requested a review from a team January 24, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: discussion 🗣 Requires further discussion to proceed
Development

Successfully merging this pull request may close these issues.

1 participant