public function DomainSourceElementManager::disallowedOptions in Domain Access 8
Finds options not accessible to the current user.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
array $field: The field element being processed.
Overrides DomainElementManager::disallowedOptions
File
- domain_source/
src/ DomainSourceElementManager.php, line 17
Class
- DomainSourceElementManager
- Checks the access status of entities based on domain settings.
Namespace
Drupal\domain_sourceCode
public function disallowedOptions(FormStateInterface $form_state, array $field) {
$options = [];
$info = $form_state
->getBuildInfo();
$entity = $form_state
->getFormObject()
->getEntity();
$entity_values = $entity
->get(DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD)
->offsetGet(0);
if (isset($field['widget']['#options']) && !empty($entity_values)) {
$value = $entity_values
->getValue('target_id');
$options = array_diff_key(array_flip($value), $field['widget']['#options']);
}
return array_keys($options);
}