security updated for entity api

This commit is contained in:
2018-04-24 14:17:02 +02:00
parent 870831757c
commit 8fb74fdf95
24 changed files with 649 additions and 154 deletions

View File

@@ -7,6 +7,12 @@
/**
* Returns the configured entity features controller.
*
* @param string $type
* The entity type to get the controller for.
*
* @return EntityDefaultFeaturesController
* The configured entity features controller.
*/
function entity_features_get_controller($type) {
$static = &drupal_static(__FUNCTION__);
@@ -85,6 +91,7 @@ class EntityDefaultFeaturesController {
$fields = field_info_instances($this->info['bundle of'], $entity->{$this->bundleKey});
foreach ($fields as $name => $field) {
$pipe['field'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
$pipe['field_instance'][] = "{$field['entity_type']}-{$field['bundle']}-{$field['field_name']}";
}
}
}
@@ -125,9 +132,7 @@ class EntityDefaultFeaturesController {
*/
function revert($module = NULL) {
if ($defaults = features_get_default($this->type, $module)) {
foreach ($defaults as $name => $entity) {
entity_delete($this->type, $name);
}
entity_delete_multiple($this->type, array_keys($defaults));
}
}
}
@@ -146,6 +151,8 @@ function entity_features_api() {
}
/**
* Implements hook_features_export_options().
*
* Features component callback.
*/
function entity_features_export_options($a1, $a2 = NULL) {
@@ -157,6 +164,8 @@ function entity_features_export_options($a1, $a2 = NULL) {
}
/**
* Implements hook_features_export().
*
* Features component callback.
*/
function entity_features_export($data, &$export, $module_name = '', $entity_type) {
@@ -164,6 +173,8 @@ function entity_features_export($data, &$export, $module_name = '', $entity_type
}
/**
* Implements hook_features_export_render().
*
* Features component callback.
*/
function entity_features_export_render($module, $data, $export = NULL, $entity_type) {
@@ -171,8 +182,23 @@ function entity_features_export_render($module, $data, $export = NULL, $entity_t
}
/**
* Implements hook_features_revert().
*
* Features component callback.
*/
function entity_features_revert($module = NULL, $entity_type) {
return entity_features_get_controller($entity_type)->revert($module);
}
/**
* Implements hook_features_post_restore().
*
* Rebuild all defaults when a features rebuild is triggered - even the ones not
* handled by features itself.
*/
function entity_features_post_restore($op, $items = array()) {
if ($op == 'rebuild') {
// Use features rebuild to rebuild the features independent exports too.
entity_defaults_rebuild();
}
}