Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Utils
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • Helpers
  • Loader

Interfaces

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