File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Craft ;
3+
4+ use Craft \Plugins \Postmaster \Interfaces \ParseInterface ;
5+
6+ class Postmaster_BaseSettingsModel extends BaseModel implements ParseInterface
7+ {
8+ public function parse (Array $ data = array ())
9+ {
10+ $ this ->setAttributes ($ this ->parseArray ($ this ->getAttributes (), $ data ));
11+
12+ return $ this ;
13+ }
14+
15+ public function render ($ value , Array $ data = array ())
16+ {
17+ return craft ()->templates ->renderString ($ value , $ data );
18+ }
19+
20+ public function parseArray ($ subject , Array $ data = array ())
21+ {
22+ if (is_string ($ subject ) && !empty ($ subject ))
23+ {
24+ $ subject = $ this ->render ($ subject , $ data );
25+ }
26+ else if (is_array ($ subject ) || is_object ($ subject ))
27+ {
28+ foreach ($ subject as $ index => $ value )
29+ {
30+ $ subject [$ index ] = $ this ->parseArray ($ value , $ data );
31+ }
32+ }
33+
34+ return $ subject ;
35+ }
36+
37+ protected function defineAttributes ()
38+ {
39+ return array ();
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments