added recomputing of home compute field on cron
This commit is contained in:
parent
c8829ee539
commit
b6b71ab9a4
|
@ -23,6 +23,8 @@ display:
|
|||
fields:
|
||||
nothing:
|
||||
admin_label: Icône
|
||||
wid:
|
||||
label: WID
|
||||
severity:
|
||||
label: Importance
|
||||
type:
|
||||
|
@ -31,6 +33,8 @@ display:
|
|||
label: Date
|
||||
message:
|
||||
label: Message
|
||||
alter:
|
||||
alt: '{{ message }}'
|
||||
name:
|
||||
label: Utilisateur
|
||||
separator: ', '
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
label: 'Large (480×480)'
|
|
@ -0,0 +1 @@
|
|||
label: 'Bloquer le(s) utilisateur(s) sélectionné(s)'
|
|
@ -0,0 +1 @@
|
|||
label: 'Annuler l''(les) utilisateur(s) sélectionné(s)'
|
|
@ -0,0 +1 @@
|
|||
label: 'Débloquer le(s) utilisateur(s) sélectionné(s)'
|
|
@ -21,7 +21,14 @@ display:
|
|||
tags:
|
||||
previous: ‹‹
|
||||
next: ››
|
||||
arguments:
|
||||
created_year_month:
|
||||
title: '{{ arguments.created_year_month }}'
|
||||
block_1:
|
||||
display_title: Bloc
|
||||
display_options:
|
||||
arguments:
|
||||
created_year_month:
|
||||
title: '{{ arguments.created_year_month }}'
|
||||
page_1:
|
||||
display_title: Page
|
||||
|
|
|
@ -24,6 +24,7 @@ display:
|
|||
tid:
|
||||
exception:
|
||||
title: Tout
|
||||
title: '{{ arguments.tid }}'
|
||||
feed_1:
|
||||
display_title: Flux
|
||||
page_1:
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
uuid: c2ba4b89-48f4-4d48-9c29-cb7d0df8ead8
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- materio_home
|
||||
title: 'Default cron handler'
|
||||
id: materio_home_cron
|
||||
weight: 0
|
||||
module: materio_home
|
||||
callback: materio_home_cron
|
||||
scheduler:
|
||||
id: simple
|
||||
configuration:
|
||||
rules:
|
||||
- '*/5+@ * * * *'
|
||||
launcher:
|
||||
id: serial
|
||||
configuration:
|
||||
timeouts:
|
||||
lock_timeout: 3600
|
||||
launcher:
|
||||
thread: 0
|
||||
logger:
|
||||
id: database
|
||||
configuration:
|
||||
method: '3'
|
||||
expire: 1209600
|
||||
retain: 1000
|
|
@ -4,22 +4,25 @@ use Drupal\Core\Field\BaseFieldDefinition;
|
|||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\mymodule\Plugin\Field\FieldType\MyFieldComputed;
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
// function materio_home_theme($existing, $type, $theme, $path) {
|
||||
// // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
//
|
||||
// return array(
|
||||
// 'materio_home' => array(
|
||||
// // 'render element' => '',
|
||||
// 'file' => 'includes/materio_home.inc',
|
||||
// 'variables' => array(
|
||||
// 'frontpage_node' => NULL,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
// https://www.drupal.org/project/drupal/issues/2916266#comment-12301574
|
||||
|
||||
// $key_value_factory = \Drupal::service('keyvalue');
|
||||
// $field_map_kv_store = $key_value_factory->get('entity.definitions.bundle_field_map');
|
||||
// $node_map = $field_map_kv_store->get('node');
|
||||
|
||||
// unset($node_map['field_workflow']['bundles']['breve']);
|
||||
// unset($node_map['field_visuel']['bundles']['breve']);
|
||||
// unset($node_map['field_video']['bundles']['breve']);
|
||||
// unset($node_map['field_thesaurus']['bundles']['breve']);
|
||||
// unset($node_map['field_tags']['bundles']['breve']);
|
||||
// unset($node_map['field_source']['bundles']['breve']);
|
||||
// unset($node_map['field_showroom']['bundles']['breve']);
|
||||
// unset($node_map['field_migration']['bundles']['breve']);
|
||||
// unset($node_map['field_linked_materials']['bundles']['breve']);
|
||||
// unset($node_map['field_memo']['bundles']['breve']);
|
||||
|
||||
// $field_map_kv_store->set('node', $node_map);
|
||||
|
||||
/**
|
||||
* Implement hook_entity_bundle_field_info().
|
||||
|
@ -99,6 +102,50 @@ function materio_home_entity_bundle_field_info(EntityTypeInterface $entity_type,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_cron().
|
||||
*
|
||||
*/
|
||||
function materio_home_cron(){
|
||||
$logger = \Drupal::logger('materio_home');
|
||||
// recompile every 5 minutes
|
||||
// $request_time = \Drupal::time()->getRequestTime();
|
||||
// if ($request_time - \Drupal::state()->get('materio_home.last_recompute') >= 300) {
|
||||
// Short-running operation example, not using a queue
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'frontpage');
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
foreach ($nodes as $nid => $node) {
|
||||
$logger->notice('cron | regenerating computed fields for '.$nid);
|
||||
$node->save();
|
||||
}
|
||||
// \Drupal::state()->set('materio_home.last_recompute', $request_time);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
// function materio_home_theme($existing, $type, $theme, $path) {
|
||||
// // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
//
|
||||
// return array(
|
||||
// 'materio_home' => array(
|
||||
// // 'render element' => '',
|
||||
// 'file' => 'includes/materio_home.inc',
|
||||
// 'variables' => array(
|
||||
// 'frontpage_node' => NULL,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * implements hook_entity_extra_field_info
|
||||
// *
|
||||
|
@ -117,19 +164,19 @@ function materio_home_entity_bundle_field_info(EntityTypeInterface $entity_type,
|
|||
// // ];
|
||||
// return $extra;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function materio_home_install() {
|
||||
$entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
|
||||
\Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function materio_home_uninstall() {
|
||||
$entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
|
||||
\Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * Implements hook_install().
|
||||
// */
|
||||
// function materio_home_install() {
|
||||
// $entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
|
||||
// \Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Implements hook_uninstall().
|
||||
// */
|
||||
// function materio_home_uninstall() {
|
||||
// $entity_type = \Drupal::service('entity_type.manager')->getDefinition('node');
|
||||
// \Drupal::service('entity.definition_update_manager')->updateEntityType($entity_type);
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue