1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory CKEditor package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\CKEditorBundle\Model; |
13
|
|
|
|
14
|
|
|
use Ivory\CKEditorBundle\Exception\StylesSetManagerException; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author GeLo <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class StylesSetManager implements StylesSetManagerInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
private $stylesSets = []; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param array $stylesSets |
28
|
|
|
*/ |
29
|
170 |
|
public function __construct(array $stylesSets = []) |
30
|
|
|
{ |
31
|
170 |
|
$this->setStylesSets($stylesSets); |
32
|
170 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
30 |
|
public function hasStylesSets() |
38
|
|
|
{ |
39
|
30 |
|
return !empty($this->stylesSets); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
30 |
|
public function getStylesSets() |
46
|
|
|
{ |
47
|
30 |
|
return $this->stylesSets; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
170 |
|
public function setStylesSets(array $stylesSets) |
54
|
|
|
{ |
55
|
170 |
|
foreach ($stylesSets as $name => $styleSet) { |
56
|
30 |
|
$this->setStylesSet($name, $styleSet); |
57
|
136 |
|
} |
58
|
170 |
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
30 |
|
public function hasStylesSet($name) |
64
|
|
|
{ |
65
|
30 |
|
return isset($this->stylesSets[$name]); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
20 |
|
public function getStylesSet($name) |
72
|
|
|
{ |
73
|
20 |
|
if (!$this->hasStylesSet($name)) { |
74
|
10 |
|
throw StylesSetManagerException::stylesSetDoesNotExist($name); |
75
|
|
|
} |
76
|
|
|
|
77
|
10 |
|
return $this->stylesSets[$name]; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
*/ |
83
|
30 |
|
public function setStylesSet($name, array $stylesSet) |
84
|
|
|
{ |
85
|
30 |
|
$this->stylesSets[$name] = $stylesSet; |
86
|
30 |
|
} |
87
|
|
|
} |
88
|
|
|
|