-
Notifications
You must be signed in to change notification settings - Fork 14
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
Creating a legacy Redia RSS feed for events. DDFHER-60 #1584
Conversation
0b99bf6
to
a3ae90e
Compare
This feed is needed for some legacy apps to continue working. It will not be updated in the future - rather, this is a 1-1 recreation of the old feed. As I've made a custom redia legacy module, i've also moved the legacy opening hours REST api into this module.
a3ae90e
to
79168fa
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.
Lots of code, lots of comments here 😅 .
I think it is a good idea to create a separate module for the legacy integrations and as I see it you have managed to recreate the feed 1-1 compared to the original.
There are a couple of places where we disagree on the overall code structure:
- I would like to see the
EventWrapper
used more. - I would prefer more proper objects and less arrays and strings.
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
$response = new Response(); | ||
$response->setContent($rss_content); | ||
$response->headers->set('Content-Type', 'application/rss+xml'); | ||
return $response; |
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.
Please update this to return a cacheable response.
I do not know how often the feed is requested but I do not see a reason why we should not be able to cache it in Varnish.
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.
As I see it you have changes the implementation to return a cacheable response but please also add some cacheable dependencies to make it behave right 😄
As per PR change requests, I've switched up the code to use the existing EventWrapper, using OOP rather than array loops, and generally making the RSS code more readable.
37d2ad7
to
873aa38
Compare
/** | ||
* Getting the description, from the first available text paragraph. | ||
*/ | ||
public function getDescription(): ?string { |
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.
I've moved this, from EventRestMapper, as now we use it in two places.
@kasperg This is ready for you again. All the relevant changes have been added in the latest commit :) ("Refactor...") |
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
$branches = $event->get('branch')->referencedEntities(); | ||
$branch = reset($branches); | ||
$event_dates = $event->get('date')->getValue(); | ||
$changed_date = DrupalDateTime::createFromFormat('U', strval($event->getChangedTime())); |
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.
As I see it the code remains. Is that intentional?
web/modules/custom/dpl_redia_legacy/src/Controller/RssFeeds/EventsController.php
Outdated
Show resolved
Hide resolved
/** | ||
* An event object, containing the properties the RSS feed needs. | ||
*/ | ||
class RediaEvent extends ControllerBase { |
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.
Please reconsider if this class and RediaEventMedia
needs to extend ControllerBase
.
I do not understand why this is necessary. As I see it the class is not a controller and it does not utilize any methods provided by the parent class.
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.
They both utilize EntityTypeManager, that comes from that :)
// We'll disable the documentation rules for the member properties, as | ||
// they are pretty self-explanatory. | ||
// phpcs:disable |
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.
Consider if is it possible to only disable the related rules for these lines instead of PHPCS entirely.
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.
I did try, and it just refused to accept it, so this is me going nuclear.
$current_date = new DrupalDateTime(); | ||
$date = $current_date->format('r'); |
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.
Getting the current time is a dependency which should be injected instead of accessed directly.
This feed is needed for some legacy apps to continue working. It will not be updated in the future - rather, this is a 1-1 recreation of the old feed.
As I've made a custom redia legacy module, i've also moved the legacy opening hours REST api into this module.
Link to issue
https://reload.atlassian.net/browse/DDFHER-60
Old feed:
https://www.aakb.dk/ding-redia-rss/event
New feed:
https://varnish.pr-1584.dpl-cms.dplplat01.dpl.reload.dk/ding-redia-rss/event