Search code examples
phpzend-frameworkapp-configzend-date

Is it possible to set Zend_Date options in application.ini config?


Is it possible to set Zend_Date options in application.ini config like this:

resources.date.options.format_type = php

in Zend Framework v 1.* ?


Solution

  • By default such resource it not available: http://framework.zend.com/manual/1.12/en/zend.application.available-resources.html

    However, nothing stops you from creating your own resource:

    1.In application.ini specify resource path & date settings

    pluginPaths.My_Application_Resource = "My/Application/Resource"
    resources.date.options.format_type = "php"
    

    2.Creating resource

    <?php
    class My_Application_Resource_Date extends Zend_Application_Resource_ResourceAbstract
    {
        public function init()
        {
            $options = $this->getOptions();
            Zend_Date::setOptions($options['options']);
        }    
    }