Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • Compiler
  • CompilerExtension
  • Configurator
  • Helpers
  • Loader

Interfaces

  • IAdapter
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  *
 6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 7:  *
 8:  * For the full copyright and license information, please view
 9:  * the file license.txt that was distributed with this source code.
10:  */
11: 
12: namespace Nette\Config;
13: 
14: use Nette;
15: 
16: 
17: 
18: /**
19:  * Configuration helpers.
20:  *
21:  * @author     David Grudl
22:  */
23: class Helpers
24: {
25:     const EXTENDS_KEY = '_extends',
26:         OVERWRITE = TRUE;
27: 
28: 
29:     /**
30:      * Merges configurations. Left has higher priority than right one.
31:      * @return array
32:      */
33:     public static function merge($left, $right)
34:     {
35:         if (is_array($left) && is_array($right)) {
36:             foreach ($left as $key => $val) {
37:                 if (is_int($key)) {
38:                     $right[] = $val;
39:                 } else {
40:                     if (is_array($val) && isset($val[self::EXTENDS_KEY])) {
41:                         if ($val[self::EXTENDS_KEY] === self::OVERWRITE) {
42:                             unset($val[self::EXTENDS_KEY]);
43:                         }
44:                     } elseif (isset($right[$key])) {
45:                         $val = static::merge($val, $right[$key]);
46:                     }
47:                     $right[$key] = $val;
48:                 }
49:             }
50:             return $right;
51: 
52:         } elseif ($left === NULL && is_array($right)) {
53:             return $right;
54: 
55:         } else {
56:             return $left;
57:         }
58:     }
59: 
60: 
61: 
62:     /**
63:      * Finds out and removes information about the parent.
64:      * @return mixed
65:      */
66:     public static function takeParent(& $data)
67:     {
68:         if (is_array($data) && isset($data[self::EXTENDS_KEY])) {
69:             $parent = $data[self::EXTENDS_KEY];
70:             unset($data[self::EXTENDS_KEY]);
71:             return $parent;
72:         }
73:     }
74: 
75: 
76: 
77:     /**
78:      * @return bool
79:      */
80:     public static function isOverwriting(& $data)
81:     {
82:         return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] === self::OVERWRITE;
83:     }
84: 
85: 
86: 
87:     /**
88:      * @return bool
89:      */
90:     public static function isInheriting(& $data)
91:     {
92:         return is_array($data) && isset($data[self::EXTENDS_KEY]) && $data[self::EXTENDS_KEY] !== self::OVERWRITE;
93:     }
94: 
95: }
96: 
Nette Framework 2.0.5 API API documentation generated by ApiGen 2.7.0