66use SilverStripe \Control \Director ;
77use SilverStripe \Core \Manifest \ModuleResourceLoader ;
88use SilverStripe \Core \Injector \Injector ;
9+ use SilverStripe \Model \List \ArrayList ;
910use SilverStripe \Security \Permission ;
1011use SilverStripe \Security \Security ;
1112use SilverStripe \CMS \Model \SiteTree ;
1213use SilverStripe \CMS \Controllers \ModelAsController ;
1314use SilverStripe \View \Requirements ;
14- use SilverStripe \View \ArrayData ;
15+ use SilverStripe \Model \ArrayData ;
1516use SilverStripe \ORM \FieldType \DBField ;
16- use SilverStripe \ORM \ArrayList ;
1717use SilverStripe \Forms \FieldList ;
1818use SilverStripe \Forms \TextField ;
1919use SilverStripe \Forms \NumericField ;
2323use SilverStripe \Forms \CheckboxSetField ;
2424use SilverStripe \Forms \OptionsetField ;
2525use SilverStripe \Forms \FormAction ;
26- use SilverStripe \Forms \RequiredFields ;
2726use SilverStripe \Forms \Form ;
2827use SilverStripe \Assets \File ;
28+ use SilverStripe \Core \Config \Config ;
29+ use SilverStripe \Forms \Validation \RequiredFieldsValidator ;
2930use SilverStripe \Subsites \Model \Subsite ;
31+ use SilverStripe \View \SSViewer ;
3032
3133/**
3234 * @package simple-styleguide
@@ -65,7 +67,14 @@ public function index()
6567
6668 // If the subsite module is installed then set the theme based on the current subsite
6769 if (class_exists (Subsite::class) && Subsite::currentSubsite ()) {
68- Config::inst ()->update ('SSViewer ' , 'theme ' , Subsite::currentSubsite ()->Theme );
70+ Config::modify ()->set (
71+ SSViewer::class,
72+ 'theme ' ,
73+ [
74+ Subsite::currentSubsite ()->Theme ,
75+ '$default '
76+ ]
77+ );
6978 }
7079
7180 $ page = Injector::inst ()->create (SiteTree::class);
@@ -83,11 +92,10 @@ public function index()
8392
8493 /**
8594 * Provides access to any custom function on the controller for use on the template output.
86- * @return ArrayData
8795 */
88- public function getStyleguideData ()
96+ public function getStyleguideData (): ArrayData
8997 {
90- $ data = new ArrayData ([
98+ $ data = ArrayData:: create ([
9199 'Title ' => 'Styleguide ' ,
92100 'Message ' => DBField::create_field (
93101 'HTMLText ' ,
@@ -107,9 +115,8 @@ public function getStyleguideData()
107115
108116 /**
109117 * Return a form with fields to match rendering through controller/template output.
110- * @return Form
111118 */
112- public function getTestForm ()
119+ public function getTestForm (): Form
113120 {
114121 $ fields = FieldList::create (
115122 TextField::create ('SimpleText ' , 'Simple Text Field ' ),
@@ -144,14 +151,14 @@ public function getTestForm()
144151 FormAction::create ('doForm ' , 'Submit ' )
145152 );
146153
147- $ required = new RequiredFields (
154+ $ required = RequiredFieldsValidator:: create (
148155 'SimpleText ' ,
149156 'Email ' ,
150157 'Checkbox ' ,
151158 'Dropdown '
152159 );
153160
154- $ form = new Form ($ this , 'TestForm ' , $ fields , $ actions , $ required );
161+ $ form = Form:: create ($ this , 'TestForm ' , $ fields , $ actions , $ required );
155162 $ form ->setMessage ('This is a form wide message. See the alerts component for site wide messages. ' , 'warning ' );
156163
157164 $ this ->extend ('updateForm ' , $ form );
@@ -161,9 +168,8 @@ public function getTestForm()
161168
162169 /**
163170 * Emulate an HTMLEditorField output useful for testing shortcodes and output extensions etc.
164- * @return HTMLText
165171 */
166- public function getContent ()
172+ public function getContent (): DBField
167173 {
168174 $ content = '' ;
169175
@@ -181,10 +187,7 @@ public function getContent()
181187 return DBField::create_field ('HTMLText ' , $ content );
182188 }
183189
184- /**
185- * @return ArrayList
186- */
187- public function getColorSwatches ()
190+ public function getColorSwatches (): ArrayList
188191 {
189192 $ list = ArrayList::create ();
190193 $ colors = $ this ->config ()->color_swatches ;
@@ -200,10 +203,7 @@ public function getColorSwatches()
200203 return $ list ;
201204 }
202205
203- /**
204- * @return string
205- */
206- public function getPlaceholderImageURL ()
206+ public function getPlaceholderImageURL (): ?string
207207 {
208208 $ url = $ this ->config ()->placeholder_image_url ;
209209 $ url = ModuleResourceLoader::singleton ()->resolveURL ($ url );
0 commit comments