/** * {@inheritdoc} */ public function access(AccountInterface $account) { $bundles = $this->entityManager->getBundleInfo($this->getEntityType()); if ($this->options['expose']['hide_single_bundle'] && count($bundles) <= 1) { return FALSE; } return parent::access($account); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['expose']['hide_single_bundle'] = ['#type' => 'checkbox', '#title' => t('Hide if there\'s only one bundle.'), '#default_value' => $this->options['expose']['hide_single_bundle']]; }