|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\entities\routing\data_nodes\domains; |
|
4
|
|
|
|
|
5
|
|
|
use EE_Error; |
|
6
|
|
|
use EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData; |
|
7
|
|
|
use EventEspresso\core\services\json\JsonDataNode; |
|
8
|
|
|
use EventEspresso\core\services\json\JsonDataNodeValidator; |
|
9
|
|
|
use ReflectionException; |
|
10
|
|
|
use WP_Post; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class EventEditor |
|
14
|
|
|
* Description |
|
15
|
|
|
* |
|
16
|
|
|
* @package EventEspresso\core\domain\entities\routing\data_nodes\domains |
|
17
|
|
|
* @author Brent Christensen |
|
18
|
|
|
* @since $VID:$ |
|
19
|
|
|
*/ |
|
20
|
|
|
class EventEditor extends JsonDataNode |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
const NODE_NAME = 'eventEditor'; |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var EventEditorGraphQLData |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $event_editor_gql_data; |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* EventEditor JsonDataNode constructor. |
|
34
|
|
|
* |
|
35
|
|
|
* @param EventEditorGraphQLData $event_editor_gql_data |
|
36
|
|
|
* @param JsonDataNodeValidator $validator |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct( |
|
39
|
|
|
EventEditorGraphQLData $event_editor_gql_data, |
|
40
|
|
|
JsonDataNodeValidator $validator |
|
41
|
|
|
) { |
|
42
|
|
|
parent::__construct($validator); |
|
43
|
|
|
$this->event_editor_gql_data = $event_editor_gql_data; |
|
44
|
|
|
$this->setDomain(EventEditor::NODE_NAME); |
|
45
|
|
|
$this->setNodeName(EventEditor::NODE_NAME); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @throws EE_Error |
|
51
|
|
|
* @throws ReflectionException |
|
52
|
|
|
* @since $VID:$ |
|
53
|
|
|
*/ |
|
54
|
|
|
public function initialize() |
|
55
|
|
|
{ |
|
56
|
|
|
global $post; |
|
57
|
|
|
$eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
58
|
|
|
// if there's no event ID but there IS a WP Post... then use the Post ID |
|
59
|
|
|
$use_post_id = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'; |
|
|
|
|
|
|
60
|
|
|
$eventId = $use_post_id ? $post->ID : $eventId; |
|
61
|
|
|
$event = ['dbId' => $eventId]; |
|
62
|
|
|
$this->addData('event', $event); |
|
63
|
|
|
$related_data = $this->event_editor_gql_data->getData($eventId); |
|
64
|
|
|
foreach ($related_data as $key => $value) { |
|
65
|
|
|
$this->addData($key, $value); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|