-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathUrlConfig.php
More file actions
235 lines (202 loc) · 6.46 KB
/
UrlConfig.php
File metadata and controls
235 lines (202 loc) · 6.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
/**
* This file is part of the Cloudinary PHP package.
*
* (c) Cloudinary
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Cloudinary\Configuration;
/**
* Defines the global configuration applied when generating Cloudinary URLs.
*
* @property bool $secure Force HTTPS URLs for resources even if they are embedded in
* non-secure HTTP pages.
* @property bool $forceVersion By default, set to self::DEFAULT_FORCE_VERSION.
* @property mixed $responsiveWidthTransformation The transformation to use with responsive width.
* @property bool $longUrlSignature Whether to use long URL signature.
*
* @api
*/
class UrlConfig extends BaseConfigSection
{
use UrlConfigTrait;
protected static array $aliases = ['secure_distribution' => self::SECURE_CNAME];
/**
* @internal
*/
public const CONFIG_NAME = 'url';
/**
* @internal
*/
public const DEFAULT_DOMAIN = 'cloudinary.com';
/**
* @internal
*/
public const DEFAULT_SUB_DOMAIN = 'res';
/**
* @internal
*/
public const DEFAULT_SHARED_HOST = self::DEFAULT_SUB_DOMAIN . '.' . self::DEFAULT_DOMAIN;
public const PROTOCOL_HTTP = 'http';
public const PROTOCOL_HTTPS = 'https';
/**
* Default value for secure (distribution).
*/
public const DEFAULT_SECURE = true;
/**
* Default value for long URL signature.
*/
public const DEFAULT_LONG_URL_SIGNATURE = true;
/**
* Default value for forcing version.
*/
public const DEFAULT_FORCE_VERSION = true;
/**
* Default value for analytics.
*/
public const DEFAULT_ANALYTICS = true;
/**
* Default responsive width transformation.
*/
public const DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = 'c_limit,w_auto';
// Supported parameters
public const CDN_SUBDOMAIN = 'cdn_subdomain';
public const SECURE_CDN_SUBDOMAIN = 'secure_cdn_subdomain';
public const CNAME = 'cname';
public const SECURE = 'secure';
public const SECURE_CNAME = 'secure_cname';
public const PRIVATE_CDN = 'private_cdn';
public const SIGN_URL = 'sign_url';
public const LONG_URL_SIGNATURE = 'long_url_signature';
public const SHORTEN = 'shorten';
public const USE_ROOT_PATH = 'use_root_path';
public const FORCE_VERSION = 'force_version';
public const ANALYTICS = 'analytics';
public const RESPONSIVE_WIDTH = 'responsive_width';
public const RESPONSIVE_WIDTH_TRANSFORMATION = 'responsive_width_transformation';
/**
* Whether to automatically build URLs with multiple CDN sub-domains.
*
* @var ?bool
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#multiple_sub_domains
*/
public ?bool $cdnSubdomain = null;
/**
* Secure CDN sub-domain.
*
* @var ?bool
*/
public ?bool $secureCdnSubdomain = null;
/**
* The custom domain name to use for building HTTP URLs. Relevant only for Advanced plan users that have a private
* CDN distribution and a custom CNAME
*
* @var ?string
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames
*/
public ?string $cname = null;
/**
* Force HTTPS URLs for resources even if they are embedded in non-secure HTTP pages.
*
* @var bool
*/
protected bool $secure;
/**
* The domain name of the CDN distribution to use for building HTTPS URLs. Relevant only for Advanced plan users
* that have a private CDN distribution.
*
* @var string|null
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames
*/
public ?string $secureCname = null;
/**
* Set this parameter to true if you are an Advanced plan user with a private CDN distribution.
*
* @var bool
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_cnames
*/
public ?bool $privateCdn = null;
/**
* Set to true to create a Cloudinary URL signed with the first 8 characters of a SHA-1 hash.
*
* @var bool
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#generating_delivery_url_signatures
*/
public ?bool $signUrl = null;
/**
* Setting both this and signUrl to true will sign the URL using the first 32 characters of a SHA-256 hash.
*
* @var bool
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#generating_delivery_url_signatures
*/
protected ?bool $longUrlSignature = null;
/**
* Set to true to use shorten asset type.
*
* @var bool
*/
public ?bool $shorten = null;
/**
* Set to true to omit type and resource_type in the URL.
*
* @var bool
*
* @see https://cloudinary.com/documentation/advanced_url_delivery_options#root_path_urls
*/
public ?bool $useRootPath = null;
/**
* Set to false in order to omit default version string for assets in folders in the delivery URL.
*
* @var bool
*/
protected ?bool $forceVersion = null;
/**
* Set to false in order to omit analytics data.
*
* @var bool
*/
protected bool $analytics;
/**
* Whether to use responsive width.
*
* @var bool $responsiveWidth
*/
public ?bool $responsiveWidth = null;
/**
* The transformation to use with responsive width.
*
* @var mixed $responsiveWidthTransformation
*/
protected mixed $responsiveWidthTransformation = null;
/**
* Serialises configuration section to a string representation.
*
* @return string
*/
public function __toString()
{
return $this->toString([self::SECURE_CNAME, self::PRIVATE_CDN]);
}
/**
* Sets the Url configuration key with the specified value.
*
* @param string $configKey The configuration key.
* @param mixed $configValue THe configuration value.
*
* @return $this
*
* @internal
*/
public function setUrlConfig(string $configKey, mixed $configValue): static
{
return $this->setConfig($configKey, $configValue);
}
}