Commit 0b760b1c authored by alexpott's avatar alexpott

Issue #2190183 by damiankloip: Replace views_view_has_form_elements() with a...

Issue #2190183 by damiankloip: Replace views_view_has_form_elements() with a hasFormElements() method on ViewExecutable.
parent 932e4d9e
......@@ -2237,4 +2237,28 @@ public function buildThemeFunctions($hook) {
return $themes;
}
/**
* Determines if this view has form elements.
*
* @return bool
* Returns TRUE if this view contains handlers with views form
* implementations, FALSE otherwise.
*/
public function hasFormElements() {
foreach ($this->field as $field) {
if (property_exists($field, 'views_form_callback') || method_exists($field, 'viewsForm')) {
return TRUE;
}
}
$area_handlers = array_merge(array_values($this->header), array_values($this->footer));
$empty = empty($this->result);
foreach ($area_handlers as $area) {
if (method_exists($area, 'viewsForm') && !$area->viewsFormEmpty($empty)) {
return TRUE;
}
}
return FALSE;
}
}
......@@ -926,26 +926,6 @@ function views_get_view($name) {
return Views::getView($name);
}
/**
* Returns TRUE if the passed-in view contains handlers with views form
* implementations, FALSE otherwise.
*/
function views_view_has_form_elements($view) {
foreach ($view->field as $field) {
if (property_exists($field, 'views_form_callback') || method_exists($field, 'viewsForm')) {
return TRUE;
}
}
$area_handlers = array_merge(array_values($view->header), array_values($view->footer));
$empty = empty($view->result);
foreach ($area_handlers as $area) {
if (method_exists($area, 'viewsForm') && !$area->viewsFormEmpty($empty)) {
return TRUE;
}
}
return FALSE;
}
/**
* Replaces views substitution placeholders.
*
......
......@@ -130,7 +130,7 @@ function template_preprocess_views_view(&$variables) {
}
// If form fields were found in the view, reformat the view output as a form.
if (views_view_has_form_elements($view)) {
if ($view->hasFormElements()) {
// Copy the rows so as not to modify them by reference when rendering.
$rows = $variables['rows'];
// Only render row output if there are rows. Otherwise, render the empty
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment