-
Notifications
You must be signed in to change notification settings - Fork 1
/
Oembed.php
executable file
·69 lines (55 loc) · 1.1 KB
/
Oembed.php
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
<?php
/**
* COPYRIGHT NOTICE
* Copyright (c) 2023 Neue Rituale GbR
* @author NR <code@neuerituale.com>
*/
namespace ProcessWire;
class Oembed extends WireData {
/**
* @var Field|null
*/
protected $field = null;
/**
* @var null|Page
*/
protected $page = null;
/**
* Construct a new Event
*/
public function __construct(Page $page, Field $field) {
parent::__construct();
$page->wire($this);
$this->page = $page;
$this->field = $field;
$this->set('empty', true);
}
/**
* Set a value to the event: date, location or notes
*
* @param string $key
* @param string $value
* @return WireData|self
*
*/
public function set($key, $value) {
// declare as valid
if($key !== 'empty') $this->set('empty', false);
// date
if($key === 'date') $value = $value ? wireDate('c', $value) : '';
return parent::set($key, $value);
}
/**
* @return string
*/
public function render() {
return $this->get('empty') ? '' : (string) $this->get('html');
}
/**
* Return the rendered output
* @return string
*/
public function __toString() {
return $this->render();
}
}