-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
News feeds as page controller #4682
Conversation
667c058
to
183a266
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very promising! Added feedback and minor nitpicks, but overall its 🔥
df1ab5e
to
09fc96e
Compare
ba94d69
to
9339deb
Compare
I also noticed FeedIO currently requires Guzzle (see alexdebril/feed-io#398) 🙈 |
fa24ecb
to
cbafd91
Compare
b799aa6
to
f2a2357
Compare
What is your take on this? IMO we should drop these granular permissions and handle feeds like every other page, too. |
5377d6e
to
f0e189f
Compare
I think so too. Did we consider how this can be migrated on an update? Because I guess we cannot migrate the permissions? |
1c1c18e
to
2b1258d
Compare
As there is no direct equivalent to each option after this gets merged I think we cannot migrate these. The baseline would be, that if an editor has the permission to at least one news feed, we should allow access to the new News Feed page type in general. However, this would mean the editor may now have permission to more feeds than previously. |
As you see I have added a
From contao/core-bundle#1243:
Any comment much appreciated. Maybe the image resizing must be solved completely different anyways. |
6330b96
to
bbf5b95
Compare
I experimented with a provider service rather than an event (see bezin@19aad3b) I implemented a FeedProvider that a) creates the feed instance, b) fetches the news articles depending on page settings and c) transforms articles to items. This way, you may decorate the provider and alter the feed instance and/or every item. Add additional namespaces to the feed instance: // src/App/NewsFeedProvider
class NewsFeedProvider implements FeedProviderInterface
{
// ...
public function getFeed(): FeedInterface
{
$feed = $this->inner->getFeed();
$feed->addNS('content', 'http://purl.org/rss/1.0/modules/content/');
return $feed;
}
// ...
} Add a custom format options to // src/App/NewsFeedProvider
class NewsFeedProvider implements FeedProviderInterface
{
// ...
public function getItemFromModel(NewsModel $model): ItemInterface
{
if ('my_custom_source_option' !== $this->pageModel->feedSource) {
return $this->inner->getItemFromModel($model);
}
// Handle item creation in your own way
}
// ...
} What are your thoughts on this? |
Apparently you are not supposed to extend from the original service when decorating 😬 🤷 I'd prefer an event still I think, since that is what we use for |
Yes, that's a bad idea in general, because you cannot guarantee that the original class will be in the correct state if you only pass on some calls. Implementing the interface, injecting the original service and using its public API is usually safer to do. 🙂 But tbh this is also true for every extended base class - so it primarily depends on if a class is designed for this use case or not (for non abstract classes: mostly not). |
Yes, you are right. This is actually wrong in the example – it is not required. |
fed0994
to
3b870ed
Compare
1c6b3c2
to
0a59409
Compare
Did so in 931f26b Thanks for the hint! |
Thank you @bezin. |
Description ----------- This fixes several problems (also see commits) in #4682 1. The feed selection in page layouts was not migrated to the new pages 2. the new feed pages were not published, making the feeds unavailable after the update 3. if no root page was found, the existing data was silently dropped (when dropping tables) instead of failing the migration 4. DBAL `fetchOne` would return `false` if no root page was found, but the method signature expected a `null` value 5. Sorts the new feed pages at the bottom of the root pages (probably related to #6715) 6. correctly handles the base feed URL if it e.g. contains a trailing slash /cc @bezin Commits ------- e77aa64 Also migrate the layout configuration for news feeds 543a354 Publishe the newly created feed pages 631239b Fail the migration if no root page is found 12ff483 Fixed return argument when finding root page be39358 Fixed parsing feed base URL with trailing slash 5d2bd02 Sort the new feed pages at the bottom of the root page acf6e9f Fixed tests
Description ----------- This fixes several problems (also see commits) in contao/contao#4682 1. The feed selection in page layouts was not migrated to the new pages 2. the new feed pages were not published, making the feeds unavailable after the update 3. if no root page was found, the existing data was silently dropped (when dropping tables) instead of failing the migration 4. DBAL `fetchOne` would return `false` if no root page was found, but the method signature expected a `null` value 5. Sorts the new feed pages at the bottom of the root pages (probably related to contao/contao#6715) 6. correctly handles the base feed URL if it e.g. contains a trailing slash /cc @bezin Commits ------- e77aa64d Also migrate the layout configuration for news feeds 543a354c Publishe the newly created feed pages 631239b5 Fail the migration if no root page is found 12ff4830 Fixed return argument when finding root page be393581 Fixed parsing feed base URL with trailing slash 5d2bd02b Sort the new feed pages at the bottom of the root page acf6e9f1 Fixed tests
This implements news feeds as page controller and superseds #4459 eventually. Also I decided to split these into a news-bundle PR and an Event-bundle PR, because I find it easier to handle.
Still a couple things to do:
ResponseContext
)There are also some permissions for news feeds, i.e. which news feed a editor has access to and if he/she is allowed to create or delete them). Since this feed is now a page controller, access in general is handled by the page type limitation. The question is, if we want to keep this distinction? I for myself are fine with the general limitation (can access news feed page types yes/no).
New Features