Completed
Branch Gutenberg/event-attendees-bloc... (16f1da)
by
unknown
13:41
created
core/services/editor/BlockRegistrationManager.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -32,223 +32,223 @@
 block discarded – undo
32 32
 class BlockRegistrationManager extends BlockManager
33 33
 {
34 34
 
35
-    /**
36
-     * @var BlockAssetManagerCollection $block_asset_manager_collection
37
-     */
38
-    protected $block_asset_manager_collection;
39
-
40
-    /**
41
-     * @var RouteMatchSpecificationManager $route_manager
42
-     */
43
-    protected $route_manager;
44
-
45
-    /**
46
-     * array for tracking asset managers required by blocks for the current route
47
-     *
48
-     * @var array $block_asset_managers
49
-     */
50
-    protected $block_asset_managers = array();
51
-
52
-
53
-    /**
54
-     * BlockRegistrationManager constructor.
55
-     *
56
-     * @param BlockAssetManagerCollection    $block_asset_manager_collection
57
-     * @param BlockCollection                $blocks
58
-     * @param RouteMatchSpecificationManager $route_manager
59
-     * @param RequestInterface               $request
60
-     */
61
-    public function __construct(
62
-        BlockAssetManagerCollection $block_asset_manager_collection,
63
-        BlockCollection $blocks,
64
-        RouteMatchSpecificationManager $route_manager,
65
-        RequestInterface $request
66
-    ) {
67
-        $this->block_asset_manager_collection = $block_asset_manager_collection;
68
-        $this->route_manager = $route_manager;
69
-        parent::__construct($blocks, $request);
70
-    }
71
-
72
-
73
-    /**
74
-     *  Returns the name of a hookpoint to be used to call initialize()
75
-     *
76
-     * @return string
77
-     */
78
-    public function initHook()
79
-    {
80
-        return 'AHEE__EE_System__initialize';
81
-    }
82
-
83
-
84
-    /**
85
-     * Perform any early setup required for block editors to functions
86
-     *
87
-     * @return void
88
-     * @throws Exception
89
-     */
90
-    public function initialize()
91
-    {
92
-        $this->initializeBlocks();
93
-        add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks'));
94
-        add_action('wp_loaded', array($this, 'unloadAssets'));
95
-        add_filter('block_categories', array($this, 'addEspressoBlockCategories'));
96
-    }
97
-
98
-
99
-    /**
100
-     * @param array $categories
101
-     * @since $VID:$
102
-     * @return array
103
-     */
104
-    public function addEspressoBlockCategories(array $categories)
105
-    {
106
-        return array_merge(
107
-            $categories,
108
-            array(
109
-                array(
110
-                    'slug' => 'event-espresso',
111
-                    'title' => esc_html__('Event Espresso', 'event_espresso'),
112
-                ),
113
-            )
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * @return CollectionInterface|BlockInterface[]
120
-     * @throws CollectionLoaderException
121
-     * @throws CollectionDetailsException
122
-     */
123
-    protected function populateBlockCollection()
124
-    {
125
-        $loader = new CollectionLoader(
126
-            new CollectionDetails(
127
-                // collection name
128
-                'editor_blocks',
129
-                // collection interface
130
-                'EventEspresso\core\domain\entities\editor\BlockInterface',
131
-                // FQCNs for classes to add (all classes within each namespace will be loaded)
132
-                apply_filters(
133
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
134
-                    array('EventEspresso\core\domain\entities\editor\blocks')
135
-                ),
136
-                // filepaths to classes to add
137
-                array(),
138
-                // file mask to use if parsing folder for files to add
139
-                '',
140
-                // what to use as identifier for collection entities
141
-                // using CLASS NAME prevents duplicates (works like a singleton)
142
-                CollectionDetails::ID_CLASS_NAME
143
-            ),
144
-            $this->blocks
145
-        );
146
-        return $loader->getCollection();
147
-    }
148
-
149
-
150
-    /**
151
-     * populates the BlockCollection and calls initialize() on all installed blocks
152
-     *
153
-     * @return void
154
-     * @throws Exception
155
-     */
156
-    public function initializeBlocks()
157
-    {
158
-        try {
159
-            $this->populateBlockCollection();
160
-            // cycle thru block loaders and initialize each loader
161
-            foreach ($this->blocks as $block) {
162
-                $block->initialize();
163
-                $this->trackAssetManagersForBlocks($block);
164
-                if (! $this->block_asset_manager_collection->has($block->assetManager())) {
165
-                    $this->block_asset_manager_collection->add($block->assetManager());
166
-                    $block->assetManager()->setAssetHandles();
167
-                }
168
-            }
169
-        } catch (Exception $exception) {
170
-            new ExceptionStackTraceDisplay($exception);
171
-        }
172
-    }
173
-
174
-
175
-    /**
176
-     * track blocks with routes that match the current request
177
-     *
178
-     * @param BlockInterface $block
179
-     * @throws InvalidClassException
180
-     */
181
-    private function trackAssetManagersForBlocks(BlockInterface $block)
182
-    {
183
-        $supported_routes = $block->supportedRoutes();
184
-        foreach ($supported_routes as $supported_route) {
185
-            if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) {
186
-                $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace();
187
-            }
188
-        }
189
-    }
190
-
191
-
192
-    /**
193
-     * returns true if the block should be registered for the current request
194
-     * else removes block from block_routes array and returns false
195
-     *
196
-     * @param BlockInterface $block
197
-     * @return boolean
198
-     * @throws InvalidClassException
199
-     */
200
-    public function matchesRoute(BlockInterface $block)
201
-    {
202
-        if (isset($this->block_asset_managers[ $block->blockType() ])) {
203
-            return true;
204
-        }
205
-        unset($this->block_asset_managers[ $block->blockType() ]);
206
-        return false;
207
-    }
208
-
209
-
210
-    /**
211
-     * calls registerBlock() and load assets for all installed blocks
212
-     *
213
-     * @return void
214
-     * @throws Exception
215
-     */
216
-    public function registerBlocks()
217
-    {
218
-        try {
219
-            // cycle thru block loader folders
220
-            foreach ($this->blocks as $block) {
221
-                if (! $this->matchesRoute($block)) {
222
-                    continue;
223
-                }
224
-                // perform any setup required for the block
225
-                $block_type = $block->registerBlock();
226
-                if (! $block_type instanceof WP_Block_Type) {
227
-                    throw new InvalidEntityException($block_type, 'WP_Block_Type');
228
-                }
229
-                do_action(
230
-                    'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
231
-                    $block,
232
-                    $block_type
233
-                );
234
-            }
235
-        } catch (Exception $exception) {
236
-            new ExceptionStackTraceDisplay($exception);
237
-        }
238
-    }
239
-
240
-    public function unloadAssets()
241
-    {
242
-        $assets = array_flip($this->block_asset_managers);
243
-        foreach ($this->block_asset_manager_collection as $asset_manager) {
244
-            // if there are no longer any blocks that require these assets,
245
-            if (! isset($assets[ $asset_manager->assetNamespace() ])) {
246
-                // then unset asset enqueueing and bail
247
-                remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
248
-                remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
249
-                remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
250
-                remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
251
-            }
252
-        }
253
-    }
35
+	/**
36
+	 * @var BlockAssetManagerCollection $block_asset_manager_collection
37
+	 */
38
+	protected $block_asset_manager_collection;
39
+
40
+	/**
41
+	 * @var RouteMatchSpecificationManager $route_manager
42
+	 */
43
+	protected $route_manager;
44
+
45
+	/**
46
+	 * array for tracking asset managers required by blocks for the current route
47
+	 *
48
+	 * @var array $block_asset_managers
49
+	 */
50
+	protected $block_asset_managers = array();
51
+
52
+
53
+	/**
54
+	 * BlockRegistrationManager constructor.
55
+	 *
56
+	 * @param BlockAssetManagerCollection    $block_asset_manager_collection
57
+	 * @param BlockCollection                $blocks
58
+	 * @param RouteMatchSpecificationManager $route_manager
59
+	 * @param RequestInterface               $request
60
+	 */
61
+	public function __construct(
62
+		BlockAssetManagerCollection $block_asset_manager_collection,
63
+		BlockCollection $blocks,
64
+		RouteMatchSpecificationManager $route_manager,
65
+		RequestInterface $request
66
+	) {
67
+		$this->block_asset_manager_collection = $block_asset_manager_collection;
68
+		$this->route_manager = $route_manager;
69
+		parent::__construct($blocks, $request);
70
+	}
71
+
72
+
73
+	/**
74
+	 *  Returns the name of a hookpoint to be used to call initialize()
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public function initHook()
79
+	{
80
+		return 'AHEE__EE_System__initialize';
81
+	}
82
+
83
+
84
+	/**
85
+	 * Perform any early setup required for block editors to functions
86
+	 *
87
+	 * @return void
88
+	 * @throws Exception
89
+	 */
90
+	public function initialize()
91
+	{
92
+		$this->initializeBlocks();
93
+		add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks'));
94
+		add_action('wp_loaded', array($this, 'unloadAssets'));
95
+		add_filter('block_categories', array($this, 'addEspressoBlockCategories'));
96
+	}
97
+
98
+
99
+	/**
100
+	 * @param array $categories
101
+	 * @since $VID:$
102
+	 * @return array
103
+	 */
104
+	public function addEspressoBlockCategories(array $categories)
105
+	{
106
+		return array_merge(
107
+			$categories,
108
+			array(
109
+				array(
110
+					'slug' => 'event-espresso',
111
+					'title' => esc_html__('Event Espresso', 'event_espresso'),
112
+				),
113
+			)
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return CollectionInterface|BlockInterface[]
120
+	 * @throws CollectionLoaderException
121
+	 * @throws CollectionDetailsException
122
+	 */
123
+	protected function populateBlockCollection()
124
+	{
125
+		$loader = new CollectionLoader(
126
+			new CollectionDetails(
127
+				// collection name
128
+				'editor_blocks',
129
+				// collection interface
130
+				'EventEspresso\core\domain\entities\editor\BlockInterface',
131
+				// FQCNs for classes to add (all classes within each namespace will be loaded)
132
+				apply_filters(
133
+					'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs',
134
+					array('EventEspresso\core\domain\entities\editor\blocks')
135
+				),
136
+				// filepaths to classes to add
137
+				array(),
138
+				// file mask to use if parsing folder for files to add
139
+				'',
140
+				// what to use as identifier for collection entities
141
+				// using CLASS NAME prevents duplicates (works like a singleton)
142
+				CollectionDetails::ID_CLASS_NAME
143
+			),
144
+			$this->blocks
145
+		);
146
+		return $loader->getCollection();
147
+	}
148
+
149
+
150
+	/**
151
+	 * populates the BlockCollection and calls initialize() on all installed blocks
152
+	 *
153
+	 * @return void
154
+	 * @throws Exception
155
+	 */
156
+	public function initializeBlocks()
157
+	{
158
+		try {
159
+			$this->populateBlockCollection();
160
+			// cycle thru block loaders and initialize each loader
161
+			foreach ($this->blocks as $block) {
162
+				$block->initialize();
163
+				$this->trackAssetManagersForBlocks($block);
164
+				if (! $this->block_asset_manager_collection->has($block->assetManager())) {
165
+					$this->block_asset_manager_collection->add($block->assetManager());
166
+					$block->assetManager()->setAssetHandles();
167
+				}
168
+			}
169
+		} catch (Exception $exception) {
170
+			new ExceptionStackTraceDisplay($exception);
171
+		}
172
+	}
173
+
174
+
175
+	/**
176
+	 * track blocks with routes that match the current request
177
+	 *
178
+	 * @param BlockInterface $block
179
+	 * @throws InvalidClassException
180
+	 */
181
+	private function trackAssetManagersForBlocks(BlockInterface $block)
182
+	{
183
+		$supported_routes = $block->supportedRoutes();
184
+		foreach ($supported_routes as $supported_route) {
185
+			if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) {
186
+				$this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace();
187
+			}
188
+		}
189
+	}
190
+
191
+
192
+	/**
193
+	 * returns true if the block should be registered for the current request
194
+	 * else removes block from block_routes array and returns false
195
+	 *
196
+	 * @param BlockInterface $block
197
+	 * @return boolean
198
+	 * @throws InvalidClassException
199
+	 */
200
+	public function matchesRoute(BlockInterface $block)
201
+	{
202
+		if (isset($this->block_asset_managers[ $block->blockType() ])) {
203
+			return true;
204
+		}
205
+		unset($this->block_asset_managers[ $block->blockType() ]);
206
+		return false;
207
+	}
208
+
209
+
210
+	/**
211
+	 * calls registerBlock() and load assets for all installed blocks
212
+	 *
213
+	 * @return void
214
+	 * @throws Exception
215
+	 */
216
+	public function registerBlocks()
217
+	{
218
+		try {
219
+			// cycle thru block loader folders
220
+			foreach ($this->blocks as $block) {
221
+				if (! $this->matchesRoute($block)) {
222
+					continue;
223
+				}
224
+				// perform any setup required for the block
225
+				$block_type = $block->registerBlock();
226
+				if (! $block_type instanceof WP_Block_Type) {
227
+					throw new InvalidEntityException($block_type, 'WP_Block_Type');
228
+				}
229
+				do_action(
230
+					'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered',
231
+					$block,
232
+					$block_type
233
+				);
234
+			}
235
+		} catch (Exception $exception) {
236
+			new ExceptionStackTraceDisplay($exception);
237
+		}
238
+	}
239
+
240
+	public function unloadAssets()
241
+	{
242
+		$assets = array_flip($this->block_asset_managers);
243
+		foreach ($this->block_asset_manager_collection as $asset_manager) {
244
+			// if there are no longer any blocks that require these assets,
245
+			if (! isset($assets[ $asset_manager->assetNamespace() ])) {
246
+				// then unset asset enqueueing and bail
247
+				remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
248
+				remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0);
249
+				remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
250
+				remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2);
251
+			}
252
+		}
253
+	}
254 254
 }
Please login to merge, or discard this patch.
core/domain/entities/editor/blocks/EventAttendees.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -24,148 +24,148 @@
 block discarded – undo
24 24
 class EventAttendees extends Block
25 25
 {
26 26
 
27
-    const BLOCK_TYPE = 'event-attendees';
27
+	const BLOCK_TYPE = 'event-attendees';
28 28
 
29
-    /**
30
-     * @var EspressoEventAttendees $shortcode
31
-     */
32
-    protected $shortcode;
29
+	/**
30
+	 * @var EspressoEventAttendees $shortcode
31
+	 */
32
+	protected $shortcode;
33 33
 
34 34
 
35
-    /**
36
-     * EventAttendees constructor.
37
-     *
38
-     * @param CoreBlocksAssetManager $block_asset_manager
39
-     * @param RequestInterface       $request
40
-     * @param EspressoEventAttendees $shortcode
41
-     */
42
-    public function __construct(
43
-        CoreBlocksAssetManager $block_asset_manager,
44
-        RequestInterface $request,
45
-        EspressoEventAttendees $shortcode
46
-    ) {
47
-        parent::__construct($block_asset_manager, $request);
48
-        $this->shortcode = $shortcode;
49
-    }
35
+	/**
36
+	 * EventAttendees constructor.
37
+	 *
38
+	 * @param CoreBlocksAssetManager $block_asset_manager
39
+	 * @param RequestInterface       $request
40
+	 * @param EspressoEventAttendees $shortcode
41
+	 */
42
+	public function __construct(
43
+		CoreBlocksAssetManager $block_asset_manager,
44
+		RequestInterface $request,
45
+		EspressoEventAttendees $shortcode
46
+	) {
47
+		parent::__construct($block_asset_manager, $request);
48
+		$this->shortcode = $shortcode;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Perform any early setup required by the block
54
-     * including setting the block type and supported post types
55
-     *
56
-     * @return void
57
-     */
58
-    public function initialize()
59
-    {
60
-        $this->setBlockType(self::BLOCK_TYPE);
61
-        $this->setSupportedRoutes(
62
-            array(
63
-                'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor',
64
-                'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor',
65
-                'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer',
66
-            )
67
-        );
68
-        $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
69
-            ? $this->request->getRequestParam('post', 0)
70
-            : 0;
71
-        $this->setAttributes(
72
-            array(
73
-                'eventId'            => array(
74
-                    'type'    => 'number',
75
-                    'default' => $EVT_ID,
76
-                ),
77
-                'datetimeId'         => array(
78
-                    'type'    => 'number',
79
-                    'default' => 0,
80
-                ),
81
-                'ticketId'           => array(
82
-                    'type'    => 'number',
83
-                    'default' => 0,
84
-                ),
85
-                'status'              => array(
86
-                    'type'    => 'string',
87
-                    'default' => EEM_Registration::status_id_approved,
88
-                ),
89
-                'limit' => array(
90
-                    'type'    => 'number',
91
-                    'default' => 10,
92
-                ),
93
-                'showGravatar'       => array(
94
-                    'type'    => 'boolean',
95
-                    'default' => false,
96
-                ),
97
-                'displayOnArchives' => array(
98
-                    'type'    => 'boolean',
99
-                    'default' => false,
100
-                ),
101
-            )
102
-        );
103
-        $this->setDynamic();
104
-    }
52
+	/**
53
+	 * Perform any early setup required by the block
54
+	 * including setting the block type and supported post types
55
+	 *
56
+	 * @return void
57
+	 */
58
+	public function initialize()
59
+	{
60
+		$this->setBlockType(self::BLOCK_TYPE);
61
+		$this->setSupportedRoutes(
62
+			array(
63
+				'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor',
64
+				'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor',
65
+				'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer',
66
+			)
67
+		);
68
+		$EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
69
+			? $this->request->getRequestParam('post', 0)
70
+			: 0;
71
+		$this->setAttributes(
72
+			array(
73
+				'eventId'            => array(
74
+					'type'    => 'number',
75
+					'default' => $EVT_ID,
76
+				),
77
+				'datetimeId'         => array(
78
+					'type'    => 'number',
79
+					'default' => 0,
80
+				),
81
+				'ticketId'           => array(
82
+					'type'    => 'number',
83
+					'default' => 0,
84
+				),
85
+				'status'              => array(
86
+					'type'    => 'string',
87
+					'default' => EEM_Registration::status_id_approved,
88
+				),
89
+				'limit' => array(
90
+					'type'    => 'number',
91
+					'default' => 10,
92
+				),
93
+				'showGravatar'       => array(
94
+					'type'    => 'boolean',
95
+					'default' => false,
96
+				),
97
+				'displayOnArchives' => array(
98
+					'type'    => 'boolean',
99
+					'default' => false,
100
+				),
101
+			)
102
+		);
103
+		$this->setDynamic();
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * returns an array where the key corresponds to the incoming attribute name from the WP block
109
-     * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
110
-     *
111
-     * @since $VID:$
112
-     * @return array
113
-     */
114
-    private function getAttributesMap()
115
-    {
116
-        return array(
117
-            'eventId'           => array('attribute' => 'event_id', 'sanitize' => 'absint'),
118
-            'datetimeId'        => array('attribute' => 'datetime_id', 'sanitize' => 'absint'),
119
-            'ticketId'          => array('attribute' => 'ticket_id', 'sanitize' => 'absint'),
120
-            'status'            => array('attribute' => 'status', 'sanitize' => 'sanitize_text_field'),
121
-            'limit'             => array('attribute' => 'limit', 'sanitize' => 'intval'),
122
-            'showGravatar'      => array('attribute' => 'show_gravatar', 'sanitize' => 'bool'),
123
-            'displayOnArchives' => array('attribute' => 'display_on_archives', 'sanitize' => 'bool'),
124
-        );
125
-    }
107
+	/**
108
+	 * returns an array where the key corresponds to the incoming attribute name from the WP block
109
+	 * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
110
+	 *
111
+	 * @since $VID:$
112
+	 * @return array
113
+	 */
114
+	private function getAttributesMap()
115
+	{
116
+		return array(
117
+			'eventId'           => array('attribute' => 'event_id', 'sanitize' => 'absint'),
118
+			'datetimeId'        => array('attribute' => 'datetime_id', 'sanitize' => 'absint'),
119
+			'ticketId'          => array('attribute' => 'ticket_id', 'sanitize' => 'absint'),
120
+			'status'            => array('attribute' => 'status', 'sanitize' => 'sanitize_text_field'),
121
+			'limit'             => array('attribute' => 'limit', 'sanitize' => 'intval'),
122
+			'showGravatar'      => array('attribute' => 'show_gravatar', 'sanitize' => 'bool'),
123
+			'displayOnArchives' => array('attribute' => 'display_on_archives', 'sanitize' => 'bool'),
124
+		);
125
+	}
126 126
 
127 127
 
128
-    /**
129
-     * @param array $attributes
130
-     * @since $VID:$
131
-     * @return array
132
-     */
133
-    private function parseAttributes(array $attributes)
134
-    {
135
-        foreach ($attributes as $attribute => $value) {
136
-            $convert = $this->getAttributesMap();
137
-            if (isset($convert[ $attribute ])) {
138
-                $sanitize = $convert[ $attribute ]['sanitize'];
139
-                if ($sanitize === 'bool') {
140
-                    $attributes[ $convert[ $attribute ]['attribute'] ] = filter_var(
141
-                        $value,
142
-                        FILTER_VALIDATE_BOOLEAN
143
-                    );
144
-                } else {
145
-                    $attributes[ $convert[ $attribute ]['attribute'] ] = $sanitize($value);
146
-                }
147
-                if ($attribute !== $convert[ $attribute ]['attribute']) {
148
-                    unset($attributes[ $attribute ]);
149
-                }
150
-            }
151
-        }
152
-        return $attributes;
153
-    }
128
+	/**
129
+	 * @param array $attributes
130
+	 * @since $VID:$
131
+	 * @return array
132
+	 */
133
+	private function parseAttributes(array $attributes)
134
+	{
135
+		foreach ($attributes as $attribute => $value) {
136
+			$convert = $this->getAttributesMap();
137
+			if (isset($convert[ $attribute ])) {
138
+				$sanitize = $convert[ $attribute ]['sanitize'];
139
+				if ($sanitize === 'bool') {
140
+					$attributes[ $convert[ $attribute ]['attribute'] ] = filter_var(
141
+						$value,
142
+						FILTER_VALIDATE_BOOLEAN
143
+					);
144
+				} else {
145
+					$attributes[ $convert[ $attribute ]['attribute'] ] = $sanitize($value);
146
+				}
147
+				if ($attribute !== $convert[ $attribute ]['attribute']) {
148
+					unset($attributes[ $attribute ]);
149
+				}
150
+			}
151
+		}
152
+		return $attributes;
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * returns the rendered HTML for the block
158
-     *
159
-     * @param array $attributes
160
-     * @return string
161
-     * @throws EE_Error
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     * @throws InvalidArgumentException
165
-     * @throws DomainException
166
-     */
167
-    public function renderBlock(array $attributes = array())
168
-    {
169
-        return $this->shortcode->processShortcode($this->parseAttributes($attributes));
170
-    }
156
+	/**
157
+	 * returns the rendered HTML for the block
158
+	 *
159
+	 * @param array $attributes
160
+	 * @return string
161
+	 * @throws EE_Error
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 * @throws InvalidArgumentException
165
+	 * @throws DomainException
166
+	 */
167
+	public function renderBlock(array $attributes = array())
168
+	{
169
+		return $this->shortcode->processShortcode($this->parseAttributes($attributes));
170
+	}
171 171
 }
Please login to merge, or discard this patch.
route_match/specifications/admin/EspressoStandardPostTypeEditor.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
 class EspressoStandardPostTypeEditor extends RouteMatchSpecification
16 16
 {
17 17
 
18
-    /**
19
-     * returns true if current request matches specification
20
-     *
21
-     * @since $VID:$
22
-     * @return boolean
23
-     */
24
-    public function isMatchingRoute()
25
-    {
26
-        return $this->request->getMatch('espresso_*') !== false
27
-               && (
28
-                   $this->request->getRequestParam('action') === 'edit'
29
-                   || $this->request->getRequestParam('action') === 'create_new'
30
-               );
31
-    }
18
+	/**
19
+	 * returns true if current request matches specification
20
+	 *
21
+	 * @since $VID:$
22
+	 * @return boolean
23
+	 */
24
+	public function isMatchingRoute()
25
+	{
26
+		return $this->request->getMatch('espresso_*') !== false
27
+			   && (
28
+				   $this->request->getRequestParam('action') === 'edit'
29
+				   || $this->request->getRequestParam('action') === 'create_new'
30
+			   );
31
+	}
32 32
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/EspressoPostTypeEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class EspressoPostTypeEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * EspressoEventEditor constructor.
23
-     *
24
-     * @param EspressoStandardPostTypeEditor $standard_route_match
25
-     * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
-     * @param RequestInterface          $request
27
-     * @throws InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        EspressoStandardPostTypeEditor $standard_route_match,
31
-        EspressoAttendeePostTypeEditor $attendee_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($standard_route_match, $attendee_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * EspressoEventEditor constructor.
23
+	 *
24
+	 * @param EspressoStandardPostTypeEditor $standard_route_match
25
+	 * @param EspressoAttendeePostTypeEditor $attendee_route_match
26
+	 * @param RequestInterface          $request
27
+	 * @throws InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		EspressoStandardPostTypeEditor $standard_route_match,
31
+		EspressoAttendeePostTypeEditor $attendee_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($standard_route_match, $attendee_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/admin/WordPressPageEditorAddNew.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class WordPressPageEditorAddNew extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
-            && $this->request->getRequestParam('post_type', 'post') === 'page';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return strpos($this->request->requestUri(), 'wp-admin/post-new.php') !== false
26
+			&& $this->request->getRequestParam('post_type', 'post') === 'page';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
domain/entities/route_match/specifications/admin/WordPressPageEditor.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,22 +18,22 @@
 block discarded – undo
18 18
  */
19 19
 class WordPressPageEditor extends MatchAnyRouteSpecification
20 20
 {
21
-    /**
22
-     * WordPressPostsEditor constructor.
23
-     *
24
-     * @param WordPressPostsEditorEdit $edit_page_route_match
25
-     * @param WordPressPostsEditorAddNew $create_page_route_match
26
-     * @param RequestInterface           $request
27
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
-     */
29
-    public function __construct(
30
-        WordPressPageEditorEdit $edit_page_route_match,
31
-        WordPressPageEditorAddNew $create_page_route_match,
32
-        RequestInterface $request
33
-    ) {
34
-        parent::__construct(
35
-            array($edit_page_route_match, $create_page_route_match),
36
-            $request
37
-        );
38
-    }
21
+	/**
22
+	 * WordPressPostsEditor constructor.
23
+	 *
24
+	 * @param WordPressPostsEditorEdit $edit_page_route_match
25
+	 * @param WordPressPostsEditorAddNew $create_page_route_match
26
+	 * @param RequestInterface           $request
27
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
28
+	 */
29
+	public function __construct(
30
+		WordPressPageEditorEdit $edit_page_route_match,
31
+		WordPressPageEditorAddNew $create_page_route_match,
32
+		RequestInterface $request
33
+	) {
34
+		parent::__construct(
35
+			array($edit_page_route_match, $create_page_route_match),
36
+			$request
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
route_match/specifications/admin/EspressoAttendeePostTypeEditor.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
  */
15 15
 class EspressoAttendeePostTypeEditor extends RouteMatchSpecification
16 16
 {
17
-    /**
18
-     * returns true if current request matches specification
19
-     *
20
-     * @since $VID:$
21
-     * @return boolean
22
-     */
23
-    public function isMatchingRoute()
24
-    {
25
-        return $this->request->getRequestParam('page') === 'espresso_registrations'
26
-               && $this->request->getRequestParam('action') === 'edit_attendee';
27
-    }
17
+	/**
18
+	 * returns true if current request matches specification
19
+	 *
20
+	 * @since $VID:$
21
+	 * @return boolean
22
+	 */
23
+	public function isMatchingRoute()
24
+	{
25
+		return $this->request->getRequestParam('page') === 'espresso_registrations'
26
+			   && $this->request->getRequestParam('action') === 'edit_attendee';
27
+	}
28 28
 }
Please login to merge, or discard this patch.