Scalr\Api\Service\User\V1beta0\Adapter\RoleAdapter::behaviorsToEntity PHP 메소드

behaviorsToEntity() 공개 정적인 메소드

Transforms given names of behaviors used in API to internal representation
public static behaviorsToEntity ( array $behaviors, boolean $onlySupported = true ) : array
$behaviors array Array of a Role behaviors
$onlySupported boolean optional Converts only available to users behavior
리턴 array Returns an array of names of behaviors
    public static function behaviorsToEntity(array $behaviors, $onlySupported = true)
    {
        $unsupported = array_diff($behaviors, array_keys(static::$supportedBehaviors));
        if ($onlySupported && !empty($unsupported)) {
            throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, sprintf("Unknown automations: ['%s']", implode("', '", $unsupported)));
        }
        $converted = array_values(array_intersect_key(static::$supportedBehaviors, array_flip($behaviors)));
        return $onlySupported ? $converted : array_merge($converted, $unsupported);
    }