Skip to content

Commit 26f8628

Browse files
committed
Move example config to bin, implement new config()
1 parent 85754f7 commit 26f8628

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

Alerts.php.example renamed to bin/Alerts.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
/***
44
*
5-
* This file contains example values to override or augment default library behavior.
5+
* This file contains example values to change the default library behavior.
66
* Recommended usage:
77
* 1. Copy the file to app/Config/Alerts.php
88
* 2. Set any override variables
9-
* 3. Remove any lines to fallback to defaults
9+
* 3. Remove any lines to fallback to library defaults
1010
*
1111
***/
1212

13-
use CodeIgniter\Config\BaseConfig;
14-
1513
class Alerts extends \Tatter\Alerts\Config\Alerts
1614
{
1715
// prefix for SESSION variables and HTML classes, to prevent collision

src/Alerts.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php namespace Tatter\Alerts;
22

33
/***
4-
* Name: Alerts
5-
* Author: Matthew Gatner
4+
* Name: Alerts
5+
* Author: Matthew Gatner
66
* Contact: mgatner@tattersoftware.com
77
* Created: 2019-02-13
88
*
@@ -17,8 +17,8 @@
1717
* Use Config/Alerts.php to override default behavior
1818
*
1919
* @package CodeIgniter4-Alerts
20-
* @author Matthew Gatner
21-
* @link https://github.com/tattersoftware/codeigniter4-alerts
20+
* @author Matthew Gatner
21+
* @link https://github.com/tattersoftware/codeigniter4-alerts
2222
*
2323
***/
2424

@@ -116,6 +116,6 @@ public function display()
116116
// should be injected into <head>
117117
public function css()
118118
{
119-
return $this->view->setVar('prefix', $this->config->prefix)->render("Tatter\Alerts\Views\css");
119+
return $this->view->setVar('prefix', $this->config->prefix)->render('Tatter\Alerts\Views\css');
120120
}
121121
}

src/Config/Services.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ public static function alerts(BaseConfig $config = null, RendererInterface $view
1111
return static::getSharedInstance('alerts', $config, $view);
1212
endif;
1313

14-
// prioritizes user config in app/Config if found
15-
if (empty($config)):
16-
if (class_exists('\Config\Alerts')):
17-
$config = new \Config\Alerts();
18-
else:
19-
$config = new \Tatter\Alerts\Config\Alerts();
20-
endif;
21-
endif;
14+
// If no config was injected then load one
15+
// Prioritizes app/Config if found
16+
if (empty($config))
17+
$config = config('Alerts');
2218

2319
return new \Tatter\Alerts\Alerts($config, $view);
2420
}

0 commit comments

Comments
 (0)