File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 1818 * @author David Molineus <david.molineus@netzmacht.de>
1919 * @author binron <rtb@gmx.ch>
2020 * @author Sven Baumann <baumann.sv@gmail.com>
21+ * @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
2122 * @copyright 2012-2018 The MetaModels team.
2223 * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
2324 * @filesource
@@ -304,7 +305,7 @@ public function getEmptyConfig()
304305 */
305306 public function getEmptyModel ()
306307 {
307- $ objItem = new Item ($ this ->getMetaModel (), array () );
308+ $ objItem = new Item ($ this ->getMetaModel (), null );
308309 return new Model ($ objItem );
309310 }
310311
Original file line number Diff line number Diff line change @@ -61,10 +61,19 @@ class Item implements IItem
6161 *
6262 * @param IMetaModel $objMetaModel The model this item is represented by.
6363 *
64- * @param array $arrData The initial data that shall be injected into the new instance.
64+ * @param array|null $arrData The initial data that shall be injected into the new instance.
6565 */
6666 public function __construct (IMetaModel $ objMetaModel , $ arrData )
6767 {
68+ if (null === $ arrData ) {
69+ // Initialize attributes with empty values.
70+ $ arrData = [];
71+
72+ foreach ($ objMetaModel ->getAttributes () as $ attribute ) {
73+ $ arrData [$ attribute ->getColName ()] = null ;
74+ }
75+ }
76+
6877 $ this ->arrData = $ arrData ;
6978 $ this ->metaModel = $ objMetaModel ;
7079 }
You can’t perform that action at this time.
0 commit comments