Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_custom_blocks
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_custom_blocks
Commits
80fd009d
Commit
80fd009d
authored
3 weeks ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-7265: Code cleanup
parent
c6ca05a4
No related branches found
No related tags found
1 merge request
!269
ISTWCMS-7265 Make aggregator remove items from the Web Resources feed that don't exist
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_custom_blocks.module
+10
-0
10 additions, 0 deletions
uw_custom_blocks.module
with
10 additions
and
0 deletions
uw_custom_blocks.module
+
10
−
0
View file @
80fd009d
...
...
@@ -293,6 +293,7 @@ function uw_custom_blocks_field_widget_entity_reference_paragraphs_form_alter(&$
* Implements hook_cron().
*/
function
uw_custom_blocks_cron
()
{
// Time interval 6 hours in seconds, taken from multi type list block.
$interval
=
UwCblMultiTypeList
::
$cacheMaxAge
;
...
...
@@ -307,9 +308,13 @@ function uw_custom_blocks_cron() {
// Load all aggregator feeds.
$feeds
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'aggregator_feed'
)
->
loadMultiple
();
// Step through each of the feeds and update the web resources feed.
foreach
(
$feeds
as
$feed
)
{
// Check if the feed title matches 'Web-resources news'.
if
(
$feed
->
label
()
==
'Web-resources news'
)
{
// Fetch the current feed items.
$current_items
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'aggregator_item'
)
->
loadByProperties
([
'fid'
=>
$feed
->
id
()]);
...
...
@@ -324,17 +329,22 @@ function uw_custom_blocks_cron() {
// Process the latest feed data as needed.
// Compare and remove items no longer present in the current feed.
foreach
(
$current_items
as
$item
)
{
// Set the flag to FALSE.
$item_found
=
FALSE
;
// Loop through all latest feed data.
foreach
(
$latest_feed_data
->
channel
->
item
as
$latest_item
)
{
// If the current item is in the latest feed data.
if
(
$item
->
getTitle
()
==
(
string
)
$latest_item
->
title
)
{
// Set the flag to TRUE.
$item_found
=
TRUE
;
break
;
}
}
// If the flag is false, remove the current feed item.
if
(
!
$item_found
)
{
$item
->
delete
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment