You are here

function FormDefaultsHelper::search in Form Defaults 8

Search for forms matching wildcard and return all those that match.

Parameters

String $search_str:

Return value

array Array of forms matching search criteria and their definitions

File

src/Helper/FormDefaultsHelper.php, line 64

Class

FormDefaultsHelper
@class FormDefaultHelper

Namespace

Drupal\Formdefaults\Helper

Code

function search($search_str) {
  $search_str = '%' . $search_str . '%';
  $result = Database::getConnection()
    ->query('SELECT * FROM {formdefaults_forms} WHERE formid LIKE :formid', [
    ':formid' => $search_str,
  ]);
  $forms = array();
  foreach ($result as $form) {
    if ($form) {
      $formarray = unserialize($form->formdata);
      $forms[$form->formid] = $formarray;
    }
  }
  return $forms;
}