Last active
August 29, 2015 14:13
-
-
Save pvhee/0cf3f01456c0b71b66ca to your computer and use it in GitHub Desktop.
eva: disable hook_entity_view_alter to improve performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/eva.module b/eva.module | |
| index 5de36e1..ea8dab3 100755 | |
| --- a/eva.module | |
| +++ b/eva.module | |
| @@ -52,54 +52,6 @@ function eva_field_extra_fields() { | |
| } | |
| /** | |
| - * Implements hook_entity_view_alter(). | |
| - * | |
| - * This is a terrible, terrible hack that should not be necessary; taxonomy and | |
| - * some other entity types use fields, but don't implement hook_entity_view(). | |
| - * We have to ALTER those entity types after they're built. For the time being, | |
| - * we'll use a list of special cases to trigger this special handling. | |
| - */ | |
| -function eva_entity_view_alter(&$build, $type) { | |
| - $view_mode = $build['#view_mode']; | |
| - | |
| - if (!$entity = _eva_extract_entity_from_build($build, $type)) { | |
| - return; | |
| - } | |
| - | |
| - $entity_ids = entity_extract_ids($type, $entity); | |
| - $fields = field_extra_fields_get_display($type, $entity_ids[2], $view_mode); | |
| - $views = eva_get_views($type); | |
| - | |
| - foreach ($views as $info) { | |
| - $longname = $info['name'] . '_' . $info['display']; | |
| - if (isset($fields[$longname]) && $fields[$longname]['visible']) { | |
| - if ($view = views_get_view($info['name'])) { | |
| - $view->set_display($info['display']); | |
| - if ($view->access($info['display'])) { | |
| - $view->current_entity = $entity; | |
| - | |
| - if (isset($fields[$longname . '_form']) && $fields[$longname . '_form']['visible']) { | |
| - $view->init_handlers(); | |
| - $exposed_form = $view->display_handler->get_plugin('exposed_form'); | |
| - | |
| - $build[$longname . '_form'] = array( | |
| - '#markup' => $exposed_form->render_exposed_form(TRUE), | |
| - ); | |
| - } | |
| - $result = $view->execute_display($info['display']); | |
| - if (!empty($result)) { | |
| - $build[$longname] = array( | |
| - '#markup' => $result, | |
| - '#weight' => $fields[$longname]['weight'], | |
| - ); | |
| - } | |
| - } | |
| - } | |
| - } | |
| - } | |
| -} | |
| - | |
| -/** | |
| * Gets a list of views and displays attached to specific entities. | |
| * | |
| * This function will cache its results into the views cache, so it gets | |
| @@ -256,4 +208,4 @@ function eva_form_views_ui_edit_form_alter(&$form, &$form_state, $form_id) { | |
| // Clear the field cache when views are saved. This will make sure newly | |
| // created EVA views and/or exposed filters will appear. | |
| $form['actions']['save']["#submit"][] = 'field_cache_clear'; | |
| -} | |
| \ No newline at end of file | |
| +} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment