cvs: pear /Config/Config Container.php
| From: | Bertrand Mansion | Date: | Tue, 18 Feb 2003 15:26:48 +0000 |
| Subject: | cvs: pear /Config/Config Container.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8943@lists.php.net to get a copy of this message | ||
mansion Tue Feb 18 10:26:48 2003 EDT
Modified files:
/pear/Config/Config Container.php
Log:
Don't create 2 sections with the same name.
Patch by Laurent Laville.
Index: pear/Config/Config/Container.php
diff -u pear/Config/Config/Container.php:1.13 pear/Config/Config/Container.php:1.14
--- pear/Config/Config/Container.php:1.13 Tue Feb 18 10:19:24 2003
+++ pear/Config/Config/Container.php Tue Feb 18 10:26:48 2003
@@ -15,7 +15,7 @@
// | Author: Bertrand Mansion <bmansion@mamasam.com> |
// +---------------------------------------------------------------------+
//
-// $Id: Container.php,v 1.13 2003/02/18 15:19:24 mansion Exp $
+// $Id: Container.php,v 1.14 2003/02/18 15:26:48 mansion Exp $
require_once('Config.php');
@@ -180,13 +180,20 @@
/**
* Adds a section to this item.
* This is a helper method that calls createItem
+ * If the section already exists, it won't create a new one.
+ * It will return reference to existing item.
*
- * @param mixed name Name of new section or container object
- * @return object reference to new item
+ * @param string name Name of new section
+ * @return object reference to new item or Pear_Error
*/
- function &createSection($section, $content = null, $where = 'bottom', $target =
null)
+ function &createSection($name, $where = 'bottom', $target = null)
{
- $item =& $this->createItem('section', $section, $content, $where,
$target);
+ $item =& $this->getItem('section', $name);
+ if (!$item) {
+ // Section does not exist, will create one
+ unset($item);
+ $item =& $this->createItem('section', $name, null, $where, $target);
+ }
return $item;
} // end func &createSection