|
@@ -7,6 +7,7 @@
|
|
# @Last modified time: 20-12-2017
|
|
# @Last modified time: 20-12-2017
|
|
# @License: GPL-V3
|
|
# @License: GPL-V3
|
|
|
|
|
|
|
|
+use Drupal\Core\Entity\EntityInterface;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_theme().
|
|
* Implements hook_theme().
|
|
@@ -25,7 +26,6 @@ function edlp_corpus_theme($existing, $type, $theme, $path) {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* hook_entity_extra_field_info()
|
|
* hook_entity_extra_field_info()
|
|
*
|
|
*
|
|
@@ -41,7 +41,6 @@ function edlp_corpus_entity_extra_field_info(){
|
|
return $extra;
|
|
return $extra;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_ENTITY_TYPE_view().
|
|
* Implements hook_ENTITY_TYPE_view().
|
|
* @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8
|
|
* @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8
|
|
@@ -87,7 +86,6 @@ function edlp_corpus_taxonomy_term_view(array &$build, \Drupal\Core\Entity\Entit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Implements hook_page_attachments().
|
|
* Implements hook_page_attachments().
|
|
* @param array $attachments
|
|
* @param array $attachments
|
|
@@ -140,3 +138,60 @@ function edlp_corpus_page_attachments(array &$attachments) {
|
|
$attachments['#attached']['drupalSettings']['edlp_corpus']['colors'] = $js_list;
|
|
$attachments['#attached']['drupalSettings']['edlp_corpus']['colors'] = $js_list;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+function edlp_corpus_invalidate_corpus_cache(){
|
|
|
|
+ \Drupal::service('cache_tags.invalidator')->invalidateTags(['rebuild-corpus-cache']);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Acts when creating a new entity of a specific type.
|
|
|
|
+ *
|
|
|
|
+ * This hook runs after a new entity object has just been instantiated.
|
|
|
|
+ *
|
|
|
|
+ * @param \Drupal\Core\Entity\EntityInterface $entity
|
|
|
|
+ * The entity object.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup entity_crud
|
|
|
|
+ * @see hook_entity_create()
|
|
|
|
+ */
|
|
|
|
+function edlp_corpus_node_create(EntityInterface $node) {
|
|
|
|
+ if($node->getType() == 'enregistrement'){
|
|
|
|
+ edlp_corpus_invalidate_corpus_cache();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Respond to updates to an entity of a particular type.
|
|
|
|
+ *
|
|
|
|
+ * This hook runs once the entity storage has been updated. Note that hook
|
|
|
|
+ * implementations may not alter the stored entity data. Get the original entity
|
|
|
|
+ * object from $entity->original.
|
|
|
|
+ *
|
|
|
|
+ * @param \Drupal\Core\Entity\EntityInterface $entity
|
|
|
|
+ * The entity object.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup entity_crud
|
|
|
|
+ * @see hook_entity_update()
|
|
|
|
+ */
|
|
|
|
+function edlp_corpus_node_update(EntityInterface $node) {
|
|
|
|
+ if($node->getType() == 'enregistrement'){
|
|
|
|
+ edlp_corpus_invalidate_corpus_cache();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * Respond to entity deletion.
|
|
|
|
+ *
|
|
|
|
+ * This hook runs once the entity has been deleted from the storage.
|
|
|
|
+ *
|
|
|
|
+ * @param \Drupal\Core\Entity\EntityInterface $entity
|
|
|
|
+ * The entity object for the entity that has been deleted.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup entity_crud
|
|
|
|
+ * @see hook_ENTITY_TYPE_delete()
|
|
|
|
+ */
|
|
|
|
+function edlp_corpus_node_delete(EntityInterface $node) {
|
|
|
|
+ if($node->getType() == 'enregistrement'){
|
|
|
|
+ edlp_corpus_invalidate_corpus_cache();
|
|
|
|
+ }
|
|
|
|
+}
|