Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Gorodkov Denis
Project
Commits
cf7a7d3d
Commit
cf7a7d3d
authored
May 05, 2022
by
Gorodkov Denis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
parent
c5d0be44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
mymodule.module
app/docroot/modules/custom/mymodule/mymodule.module
+9
-4
QueueSwapi.php
...les/custom/mymodule/src/Plugin/QueueWorker/QueueSwapi.php
+1
-4
No files found.
app/docroot/modules/custom/mymodule/mymodule.module
View file @
cf7a7d3d
...
...
@@ -12,9 +12,7 @@ function mymodule_cron() {
$result_api
=
$api
->
getResponse
(
'https://swapi.dev/api'
);
$queue_api
=
\Drupal
::
queue
(
'mymodule_swapi'
);
$date
=
new
DateTime
();
$date
=
$date
->
getTimestamp
();
\Drupal
::
state
()
->
set
(
'date_queue_swapi'
,
$date
);
$time
=
\Drupal
::
state
()
->
get
(
'date_queue_swapi'
);
foreach
(
$result_api
as
$item
)
{
$bundle
=
$api
->
getTypeNode
(
$item
);
...
...
@@ -35,7 +33,10 @@ function mymodule_cron() {
$node_edited
=
$val
;
}
if
(
!
empty
(
$node
))
{
if
(
$node_edited
->
field_edited
->
value
!==
$value
[
'edited'
])
{
$changed
=
$node_edited
->
get
(
'changed'
)
->
getValue
();
$changed
=
$changed
[
0
][
'value'
];
if
(
$time
-
$changed
<
0
)
{
$queue_api
->
createItem
(
$value
);
}
}
else
{
...
...
@@ -48,6 +49,10 @@ function mymodule_cron() {
\Drupal
::
logger
(
'Queue mymodule_api'
)
->
notice
(
"Content type
$bundle
не создан!"
);
}
}
$date
=
new
DateTime
();
$date
=
$date
->
getTimestamp
();
\Drupal
::
state
()
->
set
(
'date_queue_swapi'
,
$date
);
}
/**
...
...
app/docroot/modules/custom/mymodule/src/Plugin/QueueWorker/QueueSwapi.php
View file @
cf7a7d3d
...
...
@@ -18,10 +18,7 @@ class QueueSwapi extends QueueWorkerBase {
public
function
processItem
(
$data
)
{
$node
=
$this
->
getNodeByUrl
(
$data
[
'url'
]);
if
(
$data
[
'edited'
]
!=
$node
->
field_edited
)
{
$this
->
edited
(
$data
,
$node
);
}
$this
->
edited
(
$data
,
$node
);
}
private
function
edited
(
$data
,
$node
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment