Skip to content

Commit c3767a5

Browse files
committed
Coding standards.
1 parent 1f7fef0 commit c3767a5

11 files changed

Lines changed: 99 additions & 61 deletions

modules/layout_paragraphs/css/layout_paragraphs.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,19 @@
243243
flex-grow: 12;
244244
}
245245
}
246+
247+
.layout-editor-region {
248+
display: flex;
249+
flex-direction: column;
250+
251+
.layout-editor-region-title {
252+
flex-grow: 0;
253+
}
254+
.layout-editor-region-content {
255+
flex-grow: 1;
256+
}
257+
}
258+
259+
.layout--paragraphs-edit-main {
260+
margin-block-end: 3rem;
261+
}

modules/layout_paragraphs/includes/block.paragraphs.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class BlockParagraphs extends Block {
6464
$this->is_orphaned = !empty($data['orphan']);
6565

6666
// $this->host_entity_id = end(preg_split('/./', $data['layout_name']));
67-
6867
$this->field_instance = _layout_paragraphs_get_field_instance($data['layout_name']);
6968
$this->bundle = paragraphs_bundle_load($this->delta);
7069
if (!empty($data['paragraphs_item_id'])) {
@@ -118,7 +117,7 @@ class BlockParagraphs extends Block {
118117
}
119118

120119
/**
121-
* Paragraphs don't have front-facing titles, so this returns an empty string.
120+
* Paragraphs don't have front-facing titles, so return an empty string.
122121
*/
123122
public function getTitle() {
124123
return '';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
<?php
2+
/**
3+
* @file
4+
*/

modules/layout_paragraphs/layout_paragraphs.module

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ function layout_paragraphs_tempstore_block_load(string $layout_block_uuid, strin
320320
* @param Layout $layout
321321
* The layout instance to load the block from.
322322
*
323+
* @return BlockParagraphs|bool
324+
*
323325
*/
324326
function layout_paragraphs_tempstore_block_retrieve(string $layout_block_uuid, Layout $layout) {
325327
$block = FALSE;
@@ -694,6 +696,7 @@ function layout_paragraphs_layout_flexible_types_alter(&$types) {
694696
*/
695697
function layout_paragraphs_reset_caches() {
696698
layout_flexible_reset_caches('paragraphs');
699+
cache('cache')->delete('layout_paragraphs_info');
697700
}
698701

699702
/**
@@ -977,6 +980,7 @@ function layout_paragraphs_entity_presave($entity, $entity_type) {
977980
foreach ($uuids as $block_index => $uuid) {
978981
if (!empty($uuid)) {
979982
// Load block with Paragraphs item attached from tempstore.
983+
/* var BlockParagraphs $block */
980984
$block = $layout->content[$uuid] ?? layout_paragraphs_tempstore_block_retrieve($uuid, $layout);
981985
if (!empty($block->paragraphs_item)) {
982986
$block_save_needed = ($block->is_new || $block->paragraphs_item->being_edited);

modules/layout_paragraphs/plugins/renderers/layout_renderer_editor_paragraphs.inc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
1717
/**
1818
* {@inheritdoc}
1919
*/
20-
function __construct(Layout $layout, array $renderer_plugin) {
20+
public function __construct(Layout $layout, array $renderer_plugin) {
2121
$template_id = $layout->layout_template ?? 'default';
2222

2323
$template_info = layout_paragraphs_get_layout_template_info($template_id);
@@ -39,7 +39,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
function addMeta() {
42+
public function addMeta() {
4343
parent::addMeta();
4444
backdrop_add_library('system', 'ui.sortable');
4545
backdrop_add_js(backdrop_get_path('module', 'layout') . '/js/layout.admin.js');
@@ -49,7 +49,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
function render() {
52+
public function render() {
5353
$this->addMeta();
5454

5555
$output = '<div class="layout--paragraphs-edit-main">';
@@ -71,7 +71,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
7171
* @return string
7272
* The HTML string representing the entire rendered, themed layout.
7373
*/
74-
function renderLayout() {
74+
public function renderLayout() {
7575
if (empty($this->prep_run)) {
7676
$this->prepare();
7777
}
@@ -102,7 +102,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
function renderRegion($region_id, $blocks) {
105+
public function renderRegion($region_id, $blocks) {
106106
$output = '';
107107
$content = implode('', $blocks);
108108
$region_buttons = $this->getRegionLinks($region_id);
@@ -121,7 +121,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
121121
/**
122122
* Render the Page Title region in the Layout Editor.
123123
*/
124-
function renderTitleRegion($region_id) {
124+
public function renderTitleRegion($region_id) {
125125
$region_buttons = $this->getRegionLinks($region_id);
126126
$description = layout_get_title_description($this->layout);
127127

@@ -139,7 +139,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
139139
/**
140140
* {@inheritdoc}
141141
*/
142-
function renderBlock($block) {
142+
public function renderBlock($block) {
143143
$aria_label = $this->getAriaLabel($block);
144144
$buttons = $this->getBlockLinks($block);
145145
$content = $block->getAdminPreview();
@@ -175,7 +175,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
175175
* Overrides LayoutRendererStandard::prepareBlocks() to process Layout
176176
* Paragraphs blocks.
177177
*/
178-
function prepareBlocks(array $blocks) {
178+
public function prepareBlocks(array $blocks) {
179179
// Use local variables as writing to them is very slightly faster.
180180
$first = $normal = $last = array();
181181

@@ -234,7 +234,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
234234
/**
235235
* {@inheritdoc}
236236
*/
237-
function renderBlocks() {
237+
public function renderBlocks() {
238238
$this->rendered['blocks'] = array();
239239
foreach ($this->prepared['blocks'] as $uuid => $block) {
240240
$block->uuid = $uuid;
@@ -246,7 +246,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
246246
/**
247247
* Returns an aria label for a block.
248248
*/
249-
function getAriaLabel($block) {
249+
public function getAriaLabel($block) {
250250
return t('Draggable block !title', array('!title' => strip_tags($block->getAdminTitle())));
251251
}
252252

@@ -262,7 +262,7 @@ class LayoutRendererEditorParagraphs extends LayoutRendererEditor {
262262
* @return string
263263
* A Backdrop menu path.
264264
*/
265-
function getUrl($command) {
265+
public function getUrl($command) {
266266
$args = func_get_args();
267267
$command = array_shift($args);
268268
$url = 'admin/structure/paragraphs/layouts/manage/' . $this->layout->name . '/' . $command . '/' . $this->plugin['name'];

modules/layout_paragraphs/plugins/renderers/layout_renderer_paragraphs.inc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,57 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
88
*
99
* @var Layout
1010
*/
11-
var $layout;
11+
public $layout;
1212

1313
/**
1414
* Deprecated. Now replaced by $layout_template_info.
1515
*
1616
* @var NULL
1717
* @deprecated since 1.29.0
1818
*/
19-
var $layout_info;
19+
public $layout_info;
2020

2121
/**
2222
* The information from hook_layout_template_info() for the layout template.
2323
*
2424
* @var array
2525
*/
26-
var $layout_template_info;
26+
public $layout_template_info;
2727

2828
/**
2929
* The complete rendered editor.
3030
*
3131
* @var array
3232
*/
33-
var $rendered_editor = array();
33+
public $rendered_editor = array();
3434

3535
/**
3636
* TRUE if this renderer is rendering in administrative mode.
3737
*
3838
* @var bool
3939
*/
40-
var $admin = TRUE;
40+
public $admin = TRUE;
4141

4242
/**
4343
* Include rendered HTML prior to the layout.
4444
*
4545
* @var string
4646
*/
47-
var $prefix = '';
47+
public $prefix = '';
4848

4949
/**
5050
* Include rendered HTML after the layout.
5151
*
5252
* @var string
5353
*/
54-
var $suffix = '';
54+
public $suffix = '';
5555

5656
/**
5757
* An array of dropbutton links to administrative actions on editor rows.
5858
*
5959
* @var array
6060
*/
61-
var $region_buttons = array();
61+
public $region_buttons = array();
6262

6363
/**
6464
* Construct the object that will be used to render the editor.
@@ -68,7 +68,7 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
6868
* @param array $renderer_plugin
6969
* The definition of the renderer plugin.
7070
*/
71-
function __construct(Layout $layout, array $renderer_plugin = array()) {
71+
public function __construct(Layout $layout, array $renderer_plugin = array()) {
7272
$template_id = $layout->layout_template;
7373

7474
$template_info = layout_paragraphs_get_layout_template_info($template_id);
@@ -90,7 +90,7 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
9090
* @return string
9191
* Themed & rendered HTML output.
9292
*/
93-
function render() {
93+
public function render() {
9494
$this->addMeta();
9595

9696
$output = '<div id="layout-paragraphs-edit-main">';
@@ -109,7 +109,7 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
109109
* @return string
110110
* The HTML string representing the entire rendered, themed template editor.
111111
*/
112-
function renderEditor() {
112+
public function renderEditor() {
113113
$this->renderRowButtons();
114114

115115
module_load_include('inc', 'layout', 'layout.theme');
@@ -134,7 +134,7 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
134134
/**
135135
* Attach page metadata.
136136
*/
137-
function addMeta() {
137+
public function addMeta() {
138138
backdrop_add_library('system', 'backdrop.ajax');
139139
backdrop_add_library('system', 'ui.sortable');
140140
backdrop_add_js(backdrop_get_path('module', 'layout') . '/js/layout.admin.js');
@@ -145,7 +145,7 @@ class LayoutRendererParagraphs extends LayoutRendererFlexible {
145145
/**
146146
* Render row dropbuttons.
147147
*/
148-
function renderRowButtons() {
148+
public function renderRowButtons() {
149149
foreach ($this->layout_template_info['regions'] as $region_id => $title) {
150150
$this->region_buttons[$region_id] = $this->getRowButtons($region_id);
151151
}

modules/layout_paragraphs/plugins/renderers/layout_renderer_standard_paragraphs.inc

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
2222
*
2323
* @param Layout $layout
2424
* The layout object to be rendered.
25-
* @param array $plugin
25+
* @param array $renderer_plugin
2626
* The definition of the renderer plugin.
2727
*
2828
* @throws LayoutMissingException
2929
*/
30-
function __construct(Layout $layout, array $renderer_plugin) {
30+
public function __construct(Layout $layout, array $renderer_plugin) {
3131
$this->plugin = $renderer_plugin;
3232
$layout_template_info = layout_paragraphs_get_layout_template_info($layout->layout_template);
3333
$this->layout = &$layout;
3434

3535
if (empty($layout_template_info)) {
36-
throw new LayoutMissingException(t('The layout plugin "@plugin" could not been found to display the "@title" layout.', array('@plugin' => $layout->layout_template, '@title' => $layout->title)));
36+
throw new LayoutMissingException(t('The layout plugin "@plugin" could not been found to display the "@title" layout.', array(
37+
'@plugin' => $layout->layout_template,
38+
'@title' => $layout->title,
39+
)));
3740
}
3841
else {
3942
$this->layout_template_info = $layout_template_info;
@@ -46,7 +49,7 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
4649
* @return array
4750
* An array of regions prepared for rendering.
4851
*/
49-
function prepareRegions(array $region_block_list, array $settings) {
52+
public function prepareRegions(array $region_block_list, array $settings) {
5053
// Initialize defaults to be used for regions without their own explicit
5154
// settings. Use display settings if they exist, else hardcoded defaults.
5255
$default = array(
@@ -173,7 +176,11 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
173176
$classes = array_filter($classes);
174177
}
175178

176-
return theme('layout_region_inner', array('blocks' => $blocks, 'tag' => $tag, 'classes' => $classes));
179+
return theme('layout_region_inner', array(
180+
'blocks' => $blocks,
181+
'tag' => $tag,
182+
'classes' => $classes,
183+
));
177184
}
178185

179186
/**
@@ -197,7 +204,7 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
197204
/**
198205
* Overrides LayoutRendererStandard::renderBlock().
199206
*
200-
* @param Block $block
207+
* @param mixed $block
201208
* The block to be rendered.
202209
*
203210
* @return string
@@ -215,7 +222,10 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
215222
);
216223
}
217224
// Add the contextual links.
218-
$content['#contextual_links']['layout'] = array('admin/structure/layouts/manage/' . $this->layout->name . '/modal', array($block->uuid));
225+
$content['#contextual_links']['layout'] = array(
226+
'admin/structure/layouts/manage/' . $this->layout->name . '/modal',
227+
array($block->uuid),
228+
);
219229

220230
$data = array(
221231
'content' => $content,
@@ -227,14 +237,23 @@ class LayoutRendererStandardParagraphs extends LayoutRendererStandard {
227237
);
228238

229239
if (isset($style) && isset($style['block theme'])) {
230-
$output = theme($style['block theme'] . '__' . $block->module . '__' . strtr($block->delta, '-', '_'), array('content' => $content, 'layout' => $this->layout, 'block' => $block, 'style' => $style, 'settings' => $block->style->settings));
240+
$output = theme($style['block theme'] . '__' . $block->module . '__' . strtr($block->delta, '-', '_'), array(
241+
'content' => $content,
242+
'layout' => $this->layout,
243+
'block' => $block,
244+
'style' => $style,
245+
'settings' => $block->style->settings,
246+
));
231247
}
232248
else {
233249
// Fallback.
234-
$output = theme('block', array('content' => $content, 'layout' => $this->layout, 'block' => $block));
250+
$output = theme('block', array(
251+
'content' => $content,
252+
'layout' => $this->layout,
253+
'block' => $block,
254+
));
235255
}
236256
}
237257
return $output;
238258
}
239-
240259
}

modules/layout_paragraphs/plugins/styles/layout_style_paragraphs.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
* @file
44
* Class providing forms and settings for Layout Paragraphs block style.
55
*/
6+
7+
/**
8+
* Placeholder class.
9+
*/
610
class LayoutStyleParagraphs extends LayoutStyle {
711
}

modules/layout_paragraphs/templates/block_paragraphs.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="<?php print implode(' ', $classes); ?>"<?php print backdrop_attributes($attributes); ?>>
1616

1717
<?php print render($title_prefix); ?>
18-
<?php if ($title): ?>
18+
<?php if ($title) : ?>
1919
<h2 class="block-title"><?php print $title; ?></h2>
2020
<?php endif; ?>
2121
<?php print render($title_suffix); ?>

0 commit comments

Comments
 (0)