| 56 | | public function __construct($group = NULL, $config = array()) |
| 57 | | { |
| 58 | | // No group name given, only array with custom config items |
| 59 | | // Allows for backward compatibility as well |
| 60 | | if (is_array($group)) |
| 61 | | { |
| 62 | | $config = $group; |
| 63 | | $group = 'default'; |
| 64 | | } |
| 65 | | // Use default group |
| 66 | | elseif ($group === NULL) |
| 67 | | { |
| 68 | | $group = 'default'; |
| 69 | | } |
| 70 | | |
| 71 | | // Load and validate config group |
| 72 | | if ( ! is_array($group_config = Config::item('pagination.'.$group))) |
| 73 | | throw new Kohana_Exception('pagination.undefined_group', $group); |
| 74 | | |
| 75 | | // All pagination config groups inherit default config group |
| 76 | | if ($group !== 'default') |
| 77 | | { |
| 78 | | // Load and validate default config group |
| 79 | | if ( ! is_array($default_config = Config::item('pagination.default'))) |
| 80 | | throw new Kohana_Exception('pagination.undefined_group', 'default'); |
| 81 | | |
| 82 | | // Merge config group with default config group |
| 83 | | $group_config += $default_config; |
| 84 | | } |
| 85 | | |
| 86 | | // Merge custom config items with config group |
| 87 | | $config += $group_config; |
| | 54 | public function __construct($config = array()) |
| | 55 | { |
| | 56 | // No custom group name given |
| | 57 | if ( ! isset($config['group'])) |
| | 58 | { |
| | 59 | $config['group'] = 'default'; |
| | 60 | } |
| | 76 | // Load config group |
| | 77 | if (isset($config['group'])) |
| | 78 | { |
| | 79 | // Load and validate config group |
| | 80 | if ( ! is_array($group_config = Config::item('pagination.'.$config['group']))) |
| | 81 | throw new Kohana_Exception('pagination.undefined_group', $config['group']); |
| | 82 | |
| | 83 | // All pagination config groups inherit default config group |
| | 84 | if ($config['group'] !== 'default') |
| | 85 | { |
| | 86 | // Load and validate default config group |
| | 87 | if ( ! is_array($default_config = Config::item('pagination.default'))) |
| | 88 | throw new Kohana_Exception('pagination.undefined_group', 'default'); |
| | 89 | |
| | 90 | // Merge config group with default config group |
| | 91 | $group_config += $default_config; |
| | 92 | } |
| | 93 | |
| | 94 | // Merge custom config items with config group |
| | 95 | $config += $group_config; |
| | 96 | } |
| | 97 | |