@@ -60,12 +60,6 @@ class Embeddable extends DataExtension
60
60
'EmbedImage '
61
61
];
62
62
63
- /**
64
- * List the allowed included embed types. If null all are allowed.
65
- * @var array
66
- */
67
- private static $ allowed_embed_types = null ;
68
-
69
63
/**
70
64
* Defines tab to insert the embed fields into.
71
65
* @var string
@@ -138,7 +132,7 @@ public function updateCMSFields(FieldList $fields)
138
132
)
139
133
);
140
134
141
- if (Count ($ owner ->AllowedEmbedTypes ) > 1 ) {
135
+ if (isset ( $ owner -> AllowedEmbedTypes ) && Count ($ owner ->AllowedEmbedTypes ) > 1 ) {
142
136
$ fields ->addFieldToTab (
143
137
'Root. ' . $ tab ,
144
138
ReadonlyField::create (
@@ -214,7 +208,7 @@ public function onBeforeWrite()
214
208
}
215
209
216
210
/**
217
- * @return array()
211
+ * @return array()|null
218
212
*/
219
213
public function getAllowedEmbedTypes ()
220
214
{
@@ -229,17 +223,17 @@ public function validate(ValidationResult $validationResult)
229
223
{
230
224
$ owner = $ this ->owner ;
231
225
$ allowed_types = $ owner ->AllowedEmbedTypes ;
232
- if ($ sourceURL = $ owner ->SourceURL && isset ($ allowed_types )) {
226
+ $ sourceURL = $ owner ->EmbedSourceURL ;
227
+ if ($ sourceURL && isset ($ allowed_types )) {
233
228
$ embed = Embed::create ($ sourceURL );
234
- if (!in_array ($ embed ->getType () , $ allowed_types )) {
229
+ if (!in_array ($ embed ->Type , $ allowed_types )) {
235
230
$ string = implode (', ' , $ allowed_types );
236
231
$ string = (substr ($ string , -1 ) == ', ' ) ? substr_replace ($ string , ' or ' , -1 ) : $ string ;
237
- $ validationResult ->error (
232
+ $ validationResult ->addError (
238
233
_t (__CLASS__ . '.ERRORNOTSTRING ' , "The embed content is not a $ string " )
239
234
);
240
235
}
241
236
}
242
-
243
237
return $ validationResult ;
244
238
}
245
239
0 commit comments