Zend Framework

Ability to extend sections using Zend_Config_Array

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.10.1
  • Fix Version/s: None
  • Component/s: Zend_Config
  • Labels:
    None

Description

I construct Zend_Config dynamically using data from a database. The problem is, that the only way to use section inheritance (extending section) is to use files Zend_Config_Ini or Zend_Config_Xml.

Zend_Config already includes a method setExtend (string $extendingSection, [string $extendedSection = null]) which could be used not only for the Zend_Config_Writer but also for creating Zend_Config using arrays with extended sections.

Example taken from Programmer's Reference Guide, Zend_Config_Writer (http://framework.zend.com/manual/en/zend.config.writer.introduction.html):

// Create the config object
$config = new Zend_Config(array(), true);
$config->production = array();
$config->staging = array();

$config->setExtend('staging', 'production');

$config->production->db = array();
$config->production->db->hostname = 'localhost';
$config->production->db->username = 'production';

$config->staging->db = array();
$config->staging->db->username = 'staging';

Zend_Debug::dump($config->staging->toArray());

shows:

array
'db' =>
array
'username' => string 'staging'

After extending 'staging' from 'production' using '$config->setExtend('staging', 'production');' the expected output would be:

array
'db' =>
array
'hostname' => string 'localhost'
'username' => string 'staging'

The only workaround i found is to use Zend_Config_Writer to produce a temporary config file and then loading it. It would be great, if we could just call the setExtend() and produce Zend_Config with extended sections using arrays.

Thank you.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: