|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\editor; |
|
4
|
|
|
|
|
5
|
|
|
use EventEspresso\core\domain\entities\editor\BlockCollection; |
|
6
|
|
|
use EventEspresso\core\domain\entities\editor\BlockInterface; |
|
7
|
|
|
use EventEspresso\core\services\collections\CollectionInterface; |
|
8
|
|
|
use EventEspresso\core\services\request\RequestInterface; |
|
9
|
|
|
|
|
10
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class BlockManager |
|
16
|
|
|
* Description |
|
17
|
|
|
* |
|
18
|
|
|
* @package EventEspresso\core\services\editor |
|
19
|
|
|
* @author Brent Christensen |
|
20
|
|
|
* @since $VID:$ |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class BlockManager |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var CollectionInterface|BlockInterface[] $blocks |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $blocks; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var RequestInterface $request |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $request; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* the post type that the current request applies to |
|
37
|
|
|
* |
|
38
|
|
|
* @var string $request_post_type |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $request_post_type; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* value of the 'page' $_GET param |
|
44
|
|
|
* |
|
45
|
|
|
* @var string $page |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $page; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* value of the 'action' $_GET param |
|
51
|
|
|
* |
|
52
|
|
|
* @var string $action |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $action; |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* BlockManager constructor. |
|
59
|
|
|
* |
|
60
|
|
|
* @param BlockCollection $blocks |
|
61
|
|
|
* @param RequestInterface $request |
|
62
|
|
|
*/ |
|
63
|
|
|
public function __construct( |
|
64
|
|
|
BlockCollection $blocks, |
|
65
|
|
|
RequestInterface $request |
|
66
|
|
|
) { |
|
67
|
|
|
$this->blocks = $blocks; |
|
68
|
|
|
$this->request = $request; |
|
69
|
|
|
$this->request_post_type = $this->request->getRequestParam('post_type', ''); |
|
70
|
|
|
$this->page = $this->request->getRequestParam('page', ''); |
|
71
|
|
|
$this->action = $this->request->getRequestParam('action', ''); |
|
72
|
|
|
add_action($this->init_hook(), array($this, 'initialize')); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns the name of a hookpoint to be used to call initialize() |
|
78
|
|
|
* |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
abstract public function init_hook(); |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Perform any early setup required for block editors to functions |
|
86
|
|
|
* |
|
87
|
|
|
* @return void |
|
88
|
|
|
*/ |
|
89
|
|
|
abstract public function initialize(); |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public function currentRequestPostType() |
|
96
|
|
|
{ |
|
97
|
|
|
return $this->request_post_type; |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|