1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Twig\Extension\Grid; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\BootstrapBundle\Twig\Extension\AbstractBootstrapTwigExtension; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Abstract grid Twig extension. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Grid |
21
|
|
|
* @abstract |
22
|
|
|
*/ |
23
|
|
|
abstract class AbstractGridTwigExtension extends AbstractBootstrapTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Constructor. |
27
|
|
|
*/ |
28
|
|
|
protected function __construct() { |
29
|
|
|
parent::__construct(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Displays a Bootstrap column. |
34
|
|
|
* |
35
|
|
|
* @param string $lg The large column size. |
36
|
|
|
* @param string $md The medium column size. |
37
|
|
|
* @param string $sm The small column size. |
38
|
|
|
* @param string $xs The extra-small column size. |
39
|
|
|
* @param string $prefix The column prefix. |
40
|
|
|
* @return string Returns the Bootstrap grid. |
41
|
|
|
*/ |
42
|
|
|
final protected function bootstrapGrid($lg, $md, $sm, $xs, $prefix = "") { |
43
|
|
|
|
44
|
|
|
// Initialize the columns. |
45
|
|
|
$columns = []; |
46
|
|
|
|
47
|
|
|
// Stacked. |
48
|
|
|
$columns[] = 1 <= $lg && $lg <= 12 ? "col-lg-" . $prefix . $lg : null; |
49
|
|
|
$columns[] = 1 <= $md && $md <= 12 ? "col-md-" . $prefix . $md : null; |
50
|
|
|
$columns[] = 1 <= $sm && $sm <= 12 ? "col-sm-" . $prefix . $sm : null; |
51
|
|
|
$columns[] = 1 <= $xs && $xs <= 12 ? "col-xs-" . $prefix . $xs : null; |
52
|
|
|
|
53
|
|
|
// Return the columns. |
54
|
|
|
return trim(implode(" ", $columns)); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|