本文整理匯總了PHP中Drupal\Core\Config\Entity\ConfigEntityInterface::getWeight方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConfigEntityInterface::getWeight方法的具體用法?PHP ConfigEntityInterface::getWeight怎麽用?PHP ConfigEntityInterface::getWeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Config\Entity\ConfigEntityInterface
的用法示例。
在下文中一共展示了ConfigEntityInterface::getWeight方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sort
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
{
/* @var $a WorkflowState */
/* @var $b WorkflowState */
$a_wid = $a->wid;
$b_wid = $b->wid;
if ($a_wid == $b_wid) {
$a_weight = $a->getWeight();
$b_weight = $b->getWeight();
return $a_weight < $b_weight ? -1 : 1;
}
return $a_wid < $b_wid ? -1 : 1;
}
示例2: sort
/**
* Sorts active blocks by weight; sorts inactive blocks by name.
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
{
// Separate enabled from disabled.
$status = (int) $b->status() - (int) $a->status();
if ($status !== 0) {
return $status;
}
// Sort by weight, unless disabled.
if ($a->getRegion() != static::BLOCK_REGION_NONE) {
$weight = $a->getWeight() - $b->getWeight();
if ($weight) {
return $weight;
}
}
// Sort by label.
return strcmp($a->label(), $b->label());
}