Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Quick Config Question

I have a config DI that is setting a date format

I want, in a Model, to do a showDate() function using the $this->config->dateFormat however DI items do not seem to appear within Models.

How would the Phalcon community best implement a global format like that? I can't do afterFetch format this way right now.


Just noticed another discussion stating something like this




If you gonna access it/config many times then you can do something like:

abstract class AbstractModel extends \Phalcon\Mvc\Model
    protected $_config; // or even $_timeFormat

    public function onConstruct()
        $this->_config = $this->getDi()->get('config');
edited Jun '16

Thank you for the response Wojciech. I actually put that in because it cleans up my ongoing development !! :)