Checks given set of behaviors on compatibility
public static getBehaviorsConflicts ( array $behaviors ) : array | ||
$behaviors | array | Array of a Role behaviors |
리턴 | array | Returns an array of behaviors that cannot be used together |
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))]]]; } }