private static function process_layer($layer, $layer_parameter) { if (is_array($layer)) { $resource_type = Cloudinary::option_get($layer, "resource_type"); $type = Cloudinary::option_get($layer, "type"); $text = Cloudinary::option_get($layer, "text"); $text_style = NULL; $public_id = Cloudinary::option_get($layer, "public_id"); $format = Cloudinary::option_get($layer, "format"); $components = array(); if ($public_id != NULL) { $public_id = str_replace("/", ":", $public_id); if ($format != NULL) { $public_id = $public_id . "." . $format; } } if ($text == NULL && $resource_type != "text") { if ($public_id == NULL) { throw new InvalidArgumentException("Must supply public_id for {$resource_type} {$layer_parameter}"); } if ($resource_type == "subtitles") { $text_style = Cloudinary::text_style($layer, $layer_parameter); } } else { $resource_type = "text"; $type = NULL; // type is ignored for text layers $text_style = Cloudinary::text_style($layer, $layer_parameter); #FIXME duplicate if ($text != NULL) { if (!($public_id != NULL xor $text_style != NULL)) { throw new InvalidArgumentException("Must supply either style parameters or a public_id when providing text parameter in a text {$layer_parameter}"); } $text = Cloudinary::smart_escape($text); $text = str_replace("%2C", "%252C", $text); $text = str_replace("/", "%252F", $text); } } if ($resource_type != "image") { array_push($components, $resource_type); } if ($type != "upload") { array_push($components, $type); } array_push($components, $text_style); array_push($components, $public_id); array_push($components, $text); $layer = implode(":", array_filter($components, 'Cloudinary::is_not_null')); } return $layer; }