1 | <?php |
||
26 | class ChainMail |
||
27 | { |
||
28 | |||
29 | const DEFAULT_CONFIG = __DIR__ . '/../config/defaults.php'; |
||
30 | |||
31 | /** |
||
32 | * Configuration Settings. |
||
33 | * |
||
34 | * @since 1.0.0 |
||
35 | * |
||
36 | * @var ConfigInterface |
||
37 | */ |
||
38 | protected $config; |
||
39 | |||
40 | /** |
||
41 | * Instantiate a ChainMail object. |
||
42 | * |
||
43 | * @since 1.0.0 |
||
44 | * |
||
45 | * @param ConfigInterface|null $config Optional. Configuration settings. |
||
46 | */ |
||
47 | 16 | public function __construct(ConfigInterface $config = null) |
|
48 | { |
||
49 | |||
50 | 16 | $defaults = ConfigFactory::create(include(self::DEFAULT_CONFIG)); |
|
51 | |||
52 | 16 | if ( ! $config) { |
|
53 | 16 | $this->config = $defaults; |
|
54 | |||
55 | 16 | return; |
|
56 | } |
||
57 | |||
58 | $this->config = ConfigFactory::create(array_replace_recursive( |
||
59 | (array)$defaults, |
||
60 | (array)$config) |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Render a specific section. |
||
66 | * |
||
67 | * @since 1.0.0 |
||
68 | * |
||
69 | * @param string $sectionType Type of section to render. |
||
70 | * @param array $context The context in which to render the section. |
||
71 | * |
||
72 | * @return string Rendered HTML. |
||
73 | */ |
||
74 | 8 | public static function renderSection($sectionType, array $context) |
|
81 | |||
82 | /** |
||
83 | * Get an array of strings representing the sections that are used by the |
||
84 | * template. |
||
85 | * |
||
86 | * @since 1.0.0 |
||
87 | * |
||
88 | * @param array $context The context in which to render the section. |
||
89 | * |
||
90 | * @return array Array of strings with section types. |
||
91 | */ |
||
92 | 8 | public static function getUsedSections(array $context) |
|
99 | |||
100 | /** |
||
101 | * Render all used sections. |
||
102 | * |
||
103 | * @since 1.0.0 |
||
104 | * |
||
105 | * @param array $context The context in which to render the section. |
||
106 | * |
||
107 | * @return string Rendered HTML. |
||
108 | */ |
||
109 | 8 | public static function renderSections(array $context) |
|
119 | |||
120 | /** |
||
121 | * Create a new mail object. |
||
122 | * |
||
123 | * @since 1.0.0 |
||
124 | * |
||
125 | * @param string $format Optional. Format to use. |
||
126 | * @param string|Template $template Optional. Template to be used. |
||
127 | * |
||
128 | * @return Mail |
||
129 | */ |
||
130 | 16 | public function createMail($format = 'html', $template = 'BasicTemplate') |
|
139 | } |
||
140 |