1 | <?php |
||
36 | class BlockRegistrationManager extends BlockManager |
||
37 | { |
||
38 | |||
39 | /** |
||
40 | * @var BlockAssetManagerCollection $block_asset_manager_collection |
||
41 | */ |
||
42 | protected $block_asset_manager_collection; |
||
43 | |||
44 | |||
45 | /** |
||
46 | * BlockRegistrationManager constructor. |
||
47 | * |
||
48 | * @param BlockAssetManagerCollection $block_asset_manager_collection |
||
49 | * @param BlockCollection $blocks |
||
50 | * @param RequestInterface $request |
||
51 | */ |
||
52 | public function __construct( |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Returns the name of a hookpoint to be used to call initialize() |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function initHook() |
||
68 | { |
||
69 | return 'AHEE__EE_System__core_loaded_and_ready'; |
||
70 | } |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Perform any early setup required for block editors to functions |
||
75 | * |
||
76 | * @return void |
||
77 | * @throws Exception |
||
78 | */ |
||
79 | public function initialize() |
||
84 | |||
85 | |||
86 | /** |
||
87 | * @return CollectionInterface|BlockInterface[] |
||
88 | * @throws ReflectionException |
||
89 | * @throws InvalidArgumentException |
||
90 | * @throws EE_Error |
||
91 | * @throws InvalidClassException |
||
92 | * @throws InvalidDataTypeException |
||
93 | * @throws InvalidEntityException |
||
94 | * @throws InvalidFilePathException |
||
95 | * @throws InvalidIdentifierException |
||
96 | * @throws InvalidInterfaceException |
||
97 | */ |
||
98 | protected function populateBlockCollection() |
||
127 | |||
128 | |||
129 | /** |
||
130 | * populates the BlockCollection and calls initialize() on all installed blocks |
||
131 | * |
||
132 | * @return void |
||
133 | * @throws Exception |
||
134 | */ |
||
135 | public function initializeBlocks() |
||
136 | { |
||
137 | try { |
||
138 | $this->populateBlockCollection(); |
||
139 | // cycle thru block loaders and initialize each loader |
||
140 | foreach ($this->blocks as $block) { |
||
141 | $block->initialize(); |
||
142 | if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
||
143 | $this->block_asset_manager_collection->add($block->assetManager()); |
||
144 | $block->assetManager()->setAssetHandles(); |
||
145 | } |
||
146 | } |
||
147 | } catch (Exception $exception) { |
||
148 | new ExceptionStackTraceDisplay($exception); |
||
149 | } |
||
150 | } |
||
151 | |||
152 | |||
153 | /** |
||
154 | * calls registerBlock() and load assets for all installed blocks |
||
155 | * |
||
156 | * @return void |
||
157 | * @throws Exception |
||
158 | */ |
||
159 | public function registerBlocks() |
||
179 | } |
||
180 |