Drupal 8  8.0.2
ViewsSelection Class Reference
Inheritance diagram for ViewsSelection:

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)
 
 entityQueryAlter (SelectInterface $query)
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static settingsFormValidate ($element, FormStateInterface $form_state, $form)
 

Protected Member Functions

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

Protected Attributes

 $entityManager
 
 $moduleHandler
 
 $currentUser
 
 $view
 

Detailed Description

Plugin implementation of the 'selection' entity_reference.

( id = "views", label = ("Views: Filter by an entity reference view"), group = "views", weight = 0 )

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\currentUser(), Drupal\entityManager(), Url\fromRoute(), Views\getApplicableViews(), Drupal\moduleHandler(), and t().

Here is the call 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 ViewsSelection\getReferenceableEntities().

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.

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 ViewsSelection\initializeView().

Referenced by ViewsSelection\countReferenceableEntities().

Here is the call graph for this function:

Here is the caller graph for this function:

initializeView (   $match = NULL,
  $match_operator = 'CONTAINS',
  $limit = 0,
  $ids = NULL 
)
protected

Initializes a view.

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".
int$limitLimit the query to a given number of items. Defaults to 0, which indicates no limiting.
array | null$idsArray of entity IDs. Defaults to NULL.
Returns
bool Return TRUE if the view was initialized, FALSE otherwise.

References Views\getView(), and t().

Referenced by ViewsSelection\getReferenceableEntities(), and ViewsSelection\validateReferenceableEntities().

Here is the call graph for this function:

Here is the caller graph for this function:

static settingsFormValidate (   $element,
FormStateInterface  $form_state,
  $form 
)
static

Element validate; Check View is valid.

References FormStateInterface\setError(), FormStateInterface\setValueForElement(), and t().

Here is the call 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.

validateReferenceableEntities ( array  $ids)

{Validates which existing entities can be referenced.

Returns
array An array of valid entity IDs.
}

Implements SelectionInterface.

References ViewsSelection\initializeView().

Here is the call graph for this function:


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