getBehaviorsConflicts() public static method

Checks given set of behaviors on compatibility
public static getBehaviorsConflicts ( array $behaviors ) : array
$behaviors array Array of a Role behaviors
return array Returns an array of behaviors that cannot be used together
示例#1
0
 protected function _builtinAutomation($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Role */
             if ($from->isScalarized) {
                 $to->builtinAutomation = static::behaviorsToData($from->getBehaviors());
             }
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to Role */
             if (!is_array($from->builtinAutomation)) {
                 throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Property builtinAutomation must be an array");
             }
             $behaviors = array_unique($from->builtinAutomation);
             if (count($behaviors) != count($from->builtinAutomation)) {
                 throw new ApiErrorException(409, ErrorMessage::ERR_UNICITY_VIOLATION, "Builtin automation list contains duplicates");
             }
             $behaviors = static::behaviorsToEntity($behaviors);
             $conflicts = Role::getBehaviorsConflicts($behaviors);
             if (!empty($conflicts)) {
                 throw new ApiErrorException(409, ErrorMessage::ERR_UNICITY_VIOLATION, sprintf("The following behaviors can not be combined: [%s]", implode(', ', static::behaviorsToData($conflicts))));
             }
             $to->setBehaviors($behaviors);
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             return [['behaviors' => ['$regex' => implode('|', static::behaviorsToEntity((array) $from->builtinAutomation, false))]]];
     }
 }