Interesting! And when shoud I load? initialize()
method? onContruct()
? Or when I declare/load services and components?
I have just inserted in DI and worked perfectly:
// In services declaration
ColorSet::$color_sets = new \Phalcon\Config\Adapter\Php(APPLICATION_PATH . '/app/Config/colorSet.php');
// colorSet.php in config folder
return [
[ 0 ],
[ 1, 'Red 1', '#FFEBEE', '#FF8A80', 1, 0 ],
[ 2, 'Red 2', '#FFEBEE', '#FF5252', 1, 0 ],
[ 3, 'Red 3', '#FFEBEE', '#FF1744', 1, 0 ],
...
```php
>Just move this data to be loaded into a config object through the DI:
>
>```php
>
> // Icky static data stored in the model should be moved to a config.
> public static $color_sets = [
> [ 0 ], // There is no id 0. This key will be unset later
> [ 1, 'Red 1', '#FFEBEE', '#FF8A80', 1, 0 ],
> [ 2, 'Red 2', '#FFEBEE', '#FF5252', 1, 0 ],
> [ 3, 'Red 3', '#FFEBEE', '#FF1744', 1, 0 ],
> [ 4, 'Red 4', '#FFEBEE', '#D50000', 1, 0 ],
> [ 5, 'Pink 1', '#FCE4EC', '#FF80AB', 1, 0 ],
> [ 6, 'Pink 2', '#FCE4EC', '#FF4081', 1, 0 ],
> [ 7, 'Pink 3', '#FCE4EC', '#F50057', 1, 0 ],
> ...
> ];
>```
The main reason is that I can call $model->getColorSet() and take benefits from loading related "model".
>Why does it need to be a model if you are aren't going to be calling update, insert or delete on the records? Additionally it won't be receiving events either since it is static data.