Skip to content

Commit

Permalink
Allow enabling the automatic spacer per region
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Dec 10, 2019
1 parent 5d5e07a commit 14dbb5e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function getConfigTreeBuilder()
->scalarNode('name')->end()
->scalarNode('span')->defaultValue(12)->end()
->scalarNode('template')->end()
->booleanNode('auto_spacer')->defaultFalse()->end()
->variableNode('rows')
->validate()->ifTrue(function ($element) {
return !\is_array($element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ private function buildRegion($rawRegion)
'name' => null,
'span' => 12,
'template' => null,
'auto_spacer' => false,
], $rawRegion);

return new Region($rawRegion['name'], $rawRegion['span'], $rawRegion['template'], $children, $rows);
return new Region($rawRegion['name'], $rawRegion['span'], $rawRegion['template'], $children, $rows, $rawRegion['auto_spacer']);
}

/**
Expand Down
26 changes: 25 additions & 1 deletion src/Kunstmaan/PagePartBundle/PageTemplate/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ class Region
*/
protected $rows;

/** @var bool */
private $autoSpacer;

/**
* @param string $name
* @param number $span
* @param string $template
* @param array $children
*/
public function __construct($name, $span, $template = null, $children = [], $rows = [])
public function __construct($name, $span, $template = null, $children = [], $rows = [], $autoSpacer = null)
{
$this->setName($name);
$this->setSpan($span);
$this->setTemplate($template);
$this->setChildren($children);
$this->setRows($rows);
$this->setAutoSpacer($autoSpacer ?? false);
}

/**
Expand Down Expand Up @@ -146,4 +150,24 @@ public function setRows($rows)

return $this;
}

/**
* @return bool
*/
public function isAutoSpacer(): bool
{
return $this->autoSpacer;
}

/**
* @param bool $autoSpacer
*
* @return Region
*/
public function setAutoSpacer($autoSpacer)
{
$this->autoSpacer = $autoSpacer;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
{% endfor %}
</div>
{% else %}
<div class="col-md-{{ region.span }}">
<div class="col-md-{{ region.span }} {% if region.autoSpacer is defined and region.autoSpacer %}js-auto-spacer{% endif %}">
<div class="page-template__region" id="{{ region.name|trans|title }}">
<header>
<h5 class="page-template__region__header">
Expand Down

0 comments on commit 14dbb5e

Please sign in to comment.