function ExpressionContainerBase::sortByWeightProperty

Sorts an array of expressions by 'weight' property.

Callback for uasort().

Parameters

\Drupal\rules\Engine\ExpressionInterface $a: First item for comparison.

\Drupal\rules\Engine\ExpressionInterface $b: Second item for comparison.

Return value

int The comparison result for uasort().

File

src/Engine/ExpressionContainerBase.php, line 54

Class

ExpressionContainerBase
Common base class for action and condition expression containers.

Namespace

Drupal\rules\Engine

Code

public static function sortByWeightProperty(ExpressionInterface $a, ExpressionInterface $b) {
    $a_weight = $a->getWeight();
    $b_weight = $b->getWeight();
    if ($a_weight == $b_weight) {
        return 0;
    }
    return $a_weight < $b_weight ? -1 : 1;
}