Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
varbase-3293696
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
varbase-3293696
Commits
b3f47121
Commit
b3f47121
authored
3 years ago
by
Rajab Natshah
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3252657
: Match default content creation date with install date
parent
c25850ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
varbase.profile
+57
-18
57 additions, 18 deletions
varbase.profile
with
57 additions
and
18 deletions
varbase.profile
+
57
−
18
View file @
b3f47121
...
...
@@ -13,7 +13,6 @@ use Drupal\varbase\Form\ConfigureMultilingualForm;
use
Drupal\varbase\Form\AssemblerForm
;
use
Drupal\varbase\Form\DevelopmentToolsAssemblerForm
;
use
Vardot\Entity\EntityDefinitionUpdateManager
;
use
Drupal\node\Entity\Node
;
use
Drupal\path_alias
\Entity\PathAlias
;
/**
...
...
@@ -270,14 +269,11 @@ function varbase_assemble_extra_components(array &$install_state) {
$uninstall_components
[]
=
'disabled_varbase_heroslider_media_content'
;
}
// Reset timestamp for nodes.
$node_ids
=
\Drupal
::
entityQuery
(
'node'
)
->
execute
();
if
(
isset
(
$node_ids
)
&&
is_array
(
$node_ids
)
&&
count
(
$node_ids
)
>
0
)
{
$batch
[
'operations'
][]
=
[
'varbase_reset_timestamp_for_nodes'
,
$node_ids
];
}
// Reset timestamp for default content.
$batch
[
'operations'
][]
=
[
'varbase_reset_timestamp_for_default_content'
,
(
array
)
TRUE
,
];
if
(
count
(
$uninstall_components
)
>
0
)
{
foreach
(
$uninstall_components
as
$uninstall_component
)
{
...
...
@@ -524,17 +520,60 @@ function varbase_uninstall_component($uninstall_component) {
}
/**
* Batch to reset timestamp for
selected nodes
.
* Batch to reset timestamp for
default content
.
*
* @param
array $node_ids
* T
he Node IDs
.
* @param
string|array $reset
* T
o entity update or not
.
*/
function
varbase_reset_timestamp_for_nodes
(
array
$node_ids
)
{
foreach
(
$node_ids
as
$nid
)
{
$node
=
Node
::
load
(
$nid
);
if
(
isset
(
$node
))
{
$node
->
created
=
\Drupal
::
time
()
->
getCurrentTime
();
$node
->
save
();
function
varbase_reset_timestamp_for_default_content
(
$reset
)
{
if
(
$reset
)
{
// Reset timestamp for all file's default content.
$file_storage
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'file'
);
$file_ids
=
$file_storage
->
getQuery
()
->
execute
();
if
(
isset
(
$file_ids
)
&&
is_array
(
$file_ids
)
&&
count
(
$file_ids
)
>
0
)
{
foreach
(
$file_ids
as
$fid
)
{
$file
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'file'
)
->
load
(
$fid
);
if
(
isset
(
$file
))
{
$file
->
set
(
'created'
,
\Drupal
::
time
()
->
getCurrentTime
());
$file
->
save
();
}
}
}
// Reset timestamp for all Media's default content.
$media_storage
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'media'
);
$media_ids
=
$media_storage
->
getQuery
()
->
execute
();
if
(
isset
(
$media_ids
)
&&
is_array
(
$media_ids
)
&&
count
(
$media_ids
)
>
0
)
{
foreach
(
$media_ids
as
$mid
)
{
$media
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'media'
)
->
load
(
$mid
);
if
(
isset
(
$media
))
{
$media
->
set
(
'created'
,
\Drupal
::
time
()
->
getCurrentTime
());
$media
->
save
();
}
}
}
// Reset timestamp for all Node's default content.
$node_storage
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'node'
);
$node_ids
=
$node_storage
->
getQuery
()
->
execute
();
if
(
isset
(
$node_ids
)
&&
is_array
(
$node_ids
)
&&
count
(
$node_ids
)
>
0
)
{
foreach
(
$node_ids
as
$nid
)
{
$node
=
\Drupal
::
service
(
'entity_type.manager'
)
->
getStorage
(
'node'
)
->
load
(
$nid
);
if
(
isset
(
$node
))
{
$node
->
set
(
'created'
,
\Drupal
::
time
()
->
getCurrentTime
());
$node
->
save
();
}
}
}
}
}
...
...
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