ContributorSelection.php in Bibliography & Citation 2.0.x
File
modules/bibcite_entity/src/Plugin/EntityReferenceSelection/ContributorSelection.php
View source
<?php
namespace Drupal\bibcite_entity\Plugin\EntityReferenceSelection;
use Drupal\bibcite_entity\Entity\Contributor;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
class ContributorSelection extends DefaultSelection {
public function createNewEntity($entity_type_id, $bundle, $label, $uid) {
$entity = parent::createNewEntity($entity_type_id, $bundle, $label, $uid);
$entity->name = $label;
return $entity;
}
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
$query = parent::buildEntityQuery($match, $match_operator);
$group = $query
->orConditionGroup();
foreach (Contributor::getNameParts() as $part) {
$group
->condition($part, $match, $match_operator);
}
$query
->condition($group);
return $query;
}
}