diff --git a/src/Context/ContextPluginManager.php b/src/Context/ContextPluginManager.php index afb6527cad18a1e44851f33ed9bac10247907012..db3fc69d85076cb2aabf78ae477fff9411cc86c3 100644 --- a/src/Context/ContextPluginManager.php +++ b/src/Context/ContextPluginManager.php @@ -10,6 +10,8 @@ namespace Drupal\facetapi\Context; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\Element; /** * Manages context plugins. @@ -36,4 +38,35 @@ class ContextPluginManager extends DefaultPluginManager { $this->alterInfo('facetapi_context_info'); } + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + if ($this->hasBundles()) { + $bundles = $this->getEntityBundleOptions(); + $form['default'] = array( + '#type' => 'radios', + '#title' => $this->t('What should be indexed?'), + '#options' => array( + 1 => $this->t('All except those selected'), + 0 => $this->t('None except those selected'), + ), + //'#default_value' => $this->configuration['default'], + ); + $form['bundles'] = array( + '#type' => 'checkboxes', + '#title' => $this->t('Bundles'), + '#options' => $bundles, + //'#default_value' => $this->configuration['bundles'], + '#size' => min(4, count($bundles)), + '#multiple' => TRUE, + ); + $form['test'] = array( + '#markup' => "test", + ); + } + + return $form; + } + } diff --git a/src/Form/FacetForm.php b/src/Form/FacetForm.php index 8565f9cc8def00b3f1184e346306c9716991b5dc..34ea3b36edc0e80cba583ce7f292bdc9bb95a6cf 100644 --- a/src/Form/FacetForm.php +++ b/src/Form/FacetForm.php @@ -16,6 +16,7 @@ use Drupal\Core\Url; use Drupal\facetapi\FacetInterface; use Drupal\facetapi\FacetApiException; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\facetapi\Context; /** * Provides a form for creating and editing search servers. @@ -188,7 +189,7 @@ class FacetForm extends EntityForm { */ public function buildContextForm(array &$form, FormStateInterface $form_state, FacetInterface $facet) { /** - * @var FacetApiContext $context + * @var Context\ContextPluginManager $context */ foreach ($facet->getContextIds() as $context_id => $context) { // @todo Create, use and save SubFormState already here, not only in