Drupal 8  8.0.2
DefaultSelection Class Reference
Inheritance diagram for DefaultSelection:

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user)
 
 buildConfigurationForm (array $form, FormStateInterface $form_state)
 
 validateConfigurationForm (array &$form, FormStateInterface $form_state)
 
 submitConfigurationForm (array &$form, FormStateInterface $form_state)
 
 getReferenceableEntities ($match=NULL, $match_operator= 'CONTAINS', $limit=0)
 
 countReferenceableEntities ($match=NULL, $match_operator= 'CONTAINS')
 
 validateReferenceableEntities (array $ids)
 
 createNewEntity ($entity_type_id, $bundle, $label, $uid)
 
 validateReferenceableNewEntities (array $entities)
 
 entityQueryAlter (SelectInterface $query)
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static elementValidateFilter (&$element, FormStateInterface $form_state)
 

Protected Member Functions

 buildEntityQuery ($match=NULL, $match_operator= 'CONTAINS')
 
 reAlterQuery (AlterableInterface $query, $tag, $base_table)
 

Protected Attributes

 $entityManager
 
 $moduleHandler
 
 $currentUser
 

Detailed Description

Default plugin implementation of the Entity Reference Selection plugin.

Also serves as a base class for specific types of Entity Reference Selection plugins.

See Also
Plugin API

( id = "default", label = ("Default"), group = "default", weight = 0, deriver = "Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver" )

Constructor & Destructor Documentation

__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
EntityManagerInterface  $entity_manager,
ModuleHandlerInterface  $module_handler,
AccountInterface  $current_user 
)

Constructs a new SelectionBase object.

Parameters
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin_id for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager service.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler service.
\Drupal\Core\Session\AccountInterface$current_userThe current user.

References Drupal\currentUser(), Drupal\entityManager(), and Drupal\moduleHandler().

Here is the call graph for this function:

Member Function Documentation

buildConfigurationForm ( array  $form,
FormStateInterface  $form_state 
)

{Form constructor.Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see .

Parameters
array$formAn associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
Returns
array The form structure.
}

Implements PluginFormInterface.

References Drupal\entityManager(), and t().

Here is the call graph for this function:

buildEntityQuery (   $match = NULL,
  $match_operator = 'CONTAINS' 
)
protected

Builds an EntityQuery to get referenceable entities.

Parameters
string | null$match(Optional) Text to match the label against. Defaults to NULL.
string$match_operator(Optional) The operation the matching should be done with. Defaults to "CONTAINS".
Returns
The EntityQuery object with the basic conditions and sorting applied to it.

References Drupal\entityManager().

Referenced by DefaultSelection\countReferenceableEntities(), DefaultSelection\getReferenceableEntities(), and DefaultSelection\validateReferenceableEntities().

Here is the call graph for this function:

Here is the caller graph for this function:

countReferenceableEntities (   $match = NULL,
  $match_operator = 'CONTAINS' 
)

{Counts entities that are referenceable.

Returns
int The number of referenceable entities.
}

Implements SelectionInterface.

References DefaultSelection\buildEntityQuery().

Here is the call graph for this function:

static create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

{Creates an instance of the plugin.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe container to pull out services used in the plugin.
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin ID for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.
Returns
static Returns an instance of this plugin.
}

Implements ContainerFactoryPluginInterface.

createNewEntity (   $entity_type_id,
  $bundle,
  $label,
  $uid 
)

{Creates a new entity object that can be used as a valid reference.

Parameters
string$entity_type_idThe entity type ID.
string$bundleThe bundle name.
string$labelThe entity label.
int$uidThe entity owner ID, if the entity type supports it.
Returns
An unsaved entity object.
}

Implements SelectionWithAutocreateInterface.

References Drupal\entityManager().

Here is the call graph for this function:

static elementValidateFilter ( $element,
FormStateInterface  $form_state 
)
static

Form element validation handler; Filters the #value property of an element.

References FormStateInterface\setValueForElement().

Here is the call graph for this function:

entityQueryAlter ( SelectInterface  $query)

{Allows the selection to alter the SelectQuery generated by EntityFieldQuery.

Parameters
\Drupal\Core\Database\Query\SelectInterface$queryA Select Query object.
}

Implements SelectionInterface.

getReferenceableEntities (   $match = NULL,
  $match_operator = 'CONTAINS',
  $limit = 0 
)

{Gets the list of referenceable entities.

Returns
array A nested array of entities, the first level is keyed by the entity bundle, which contains an array of entity labels (escaped), keyed by the entity ID.
}

Implements SelectionInterface.

References DefaultSelection\buildEntityQuery(), Drupal\entityManager(), and Html\escape().

Here is the call graph for this function:

reAlterQuery ( AlterableInterface  $query,
  $tag,
  $base_table 
)
protected

Helper method: Passes a query to the alteration system again.

This allows Entity Reference to add a tag to an existing query so it can ask access control mechanisms to alter it again.

References Drupal\moduleHandler().

Referenced by CommentSelection\entityQueryAlter().

Here is the call graph for this function:

Here is the caller graph for this function:

submitConfigurationForm ( array &  $form,
FormStateInterface  $form_state 
)

{Form submission handler.

Parameters
array$formAn associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
}

Implements PluginFormInterface.

validateConfigurationForm ( array &  $form,
FormStateInterface  $form_state 
)

{Form validation handler.

Parameters
array$formAn associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface$form_stateThe current state of the complete form.
}

Implements PluginFormInterface.

References FormStateInterface\getValue(), and FormStateInterface\setValue().

Here is the call graph for this function:

validateReferenceableEntities ( array  $ids)

{Validates which existing entities can be referenced.

Returns
array An array of valid entity IDs.
}

Implements SelectionInterface.

References DefaultSelection\buildEntityQuery(), and Drupal\entityManager().

Here is the call graph for this function:

validateReferenceableNewEntities ( array  $entities)

{Validates which newly created entities can be referenced.This method should replicate the logic implemented by ::validateReferenceableEntities(), but applied to newly created entities that have not been saved yet.

Parameters
\Drupal\Core\Entity\EntityInterface[]$entities An array of entities to check.
Returns
[] The incoming $entities parameter, filtered for valid entities. Array keys are preserved.
}

Implements SelectionWithAutocreateInterface.


The documentation for this class was generated from the following file: