Overrides \Drupal\system\Plugin\PluginUIBase::form().
@todo Add inline documentation to this method.
Overrides PluginUIBase::form
public function form($form, &$form_state, $facet = NULL) {
// @todo Add an inline comment here.
list($plugin, $theme) = explode(':', $this
->getPluginId());
$plugin_definition = $this
->getPluginDefinition();
// @todo Find out how to let the manager be injected into the class.
$manager = drupal_container()
->get($plugin_definition['manager']);
$plugins = $manager
->getDefinitions();
$form['#theme'] = 'system_plugin_ui_form';
$form['theme'] = array(
'#type' => 'value',
'#value' => $theme,
);
$form['manager'] = array(
'#type' => 'value',
'#value' => $manager,
);
$form['instance'] = array(
'#type' => 'value',
'#value' => $this,
);
$form['right']['block'] = array(
'#type' => 'textfield',
'#title' => t('Search'),
'#autocomplete_path' => 'system/autocomplete/' . $this
->getPluginId(),
);
$form['right']['submit'] = array(
'#type' => 'submit',
'#value' => t('Next'),
);
$rows = array();
foreach ($plugins as $plugin_id => $display_plugin_definition) {
if (empty($facet) || $this
->facetCompare($facet, $display_plugin_definition)) {
$rows[$plugin_id] = $this
->row($plugin_id, $display_plugin_definition);
}
foreach ($plugin_definition['facets'] as $key => $title) {
$facets[$key][$display_plugin_definition[$key]] = $this
->facetLink($key, $plugin_id, $display_plugin_definition);
}
$form['right']['all_plugins'] = array(
'#type' => 'link',
'#title' => $plugin_definition['all_plugins'],
'#href' => $this
->allPluginsUrl($plugin_id, $display_plugin_definition),
);
foreach ($facets as $group => $values) {
$form['right'][$group] = array(
'#theme' => 'links',
'#heading' => array(
'text' => $plugin_definition['facets'][$group],
'level' => 'h3',
),
'#links' => $values,
);
}
}
// Sort rows alphabetically.
asort($rows);
$form['left']['plugin_library'] = array(
'#theme' => 'table',
'#header' => $this
->tableHeader(),
'#rows' => $rows,
);
return $form;
}