You are here

public function ContributorPropertiesService::sortByWeightProperty in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_entity/src/ContributorPropertiesService.php \Drupal\bibcite_entity\ContributorPropertiesService::sortByWeightProperty()

Sort callback for config entities with weight parameter.

Parameters

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity_first: First entity to compare.

\Drupal\Core\Config\Entity\ConfigEntityInterface $entity_second: Second entity to compare.

Return value

int Sort result.

Overrides ContributorPropertiesServiceInterface::sortByWeightProperty

File

modules/bibcite_entity/src/ContributorPropertiesService.php, line 129

Class

ContributorPropertiesService
Class ContributorPropertiesService.

Namespace

Drupal\bibcite_entity

Code

public function sortByWeightProperty(ConfigEntityInterface $entity_first, ConfigEntityInterface $entity_second) {
  $weight_first = $entity_first
    ->get('weight');
  $weight_second = $entity_second
    ->get('weight');
  if ($weight_first == $weight_second) {
    return 0;
  }
  return $weight_first < $weight_second ? -1 : 1;
}