This repository was archived by the owner on Nov 14, 2024. It is now read-only.
File tree 7 files changed +66
-21
lines changed
7 files changed +66
-21
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ Some of features:
11
11
- Readable and centralized Theme Configs
12
12
- Enhanced [ Templating] ( https://en.wikibooks.org/wiki/PHP_Programming/Why_Templating ) with support for passing data
13
13
14
+ ### Documentation
15
+
16
+ Comprehensive documentation is available at http://labs.tonik.pl/theme/
17
+
14
18
## Contributing
15
19
16
20
Great that you are considering supporting the project. You have a lot of ways to help us grow. We appreciate all contributions, even the smallest.
@@ -23,4 +27,4 @@ Great that you are considering supporting the project. You have a lot of ways to
23
27
24
28
## License
25
29
26
- Licensed under the [ MIT license] ( http://opensource.org/licenses/MIT ) .
30
+ Licensed under the [ MIT license] ( http://opensource.org/licenses/MIT ) .
Original file line number Diff line number Diff line change 2
2
3
3
namespace Tonik \Gin \Asset ;
4
4
5
- use Tonik \Gin \Foundation \ Config ;
5
+ use Tonik \Gin \Contract \ ConfigInterface ;
6
6
use Tonik \Gin \Foundation \Exception \FileNotFoundException ;
7
- use Tonik \Gin \Foundation \Theme ;
8
7
9
8
class Asset
10
9
{
11
10
/**
12
11
* Theme config instance.
13
12
*
14
- * @var \Tonik\Gin\Foundation\Config
13
+ * @var \Tonik\Gin\Foundation\ConfigInterface
15
14
*/
16
15
protected $ config ;
17
16
@@ -25,9 +24,9 @@ class Asset
25
24
/**
26
25
* Construct asset.
27
26
*
28
- * @param \Tonik\Gin\Foundation\Config $config
27
+ * @param \Tonik\Gin\Foundation\ConfigInterface $config
29
28
*/
30
- public function __construct (Config $ config )
29
+ public function __construct (ConfigInterface $ config )
31
30
{
32
31
$ this ->config = $ config ;
33
32
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tonik \Gin \Contract ;
4
+
5
+ interface ConfigInterface
6
+ {
7
+ /**
8
+ * Get all of the configuration items for the application.
9
+ *
10
+ * @return array
11
+ */
12
+ public function all ();
13
+
14
+ /**
15
+ * Get the specified configuration value.
16
+ *
17
+ * @param string $key
18
+ * @param mixed $default
19
+ *
20
+ * @return mixed
21
+ */
22
+ public function get ($ key , $ default );
23
+
24
+ /**
25
+ * Set a given configuration value.
26
+ *
27
+ * @param array|string $key
28
+ * @param mixed $value
29
+ *
30
+ * @return void
31
+ */
32
+ public function set ($ key , $ value );
33
+
34
+ /**
35
+ * Determine if the given configuration value exists.
36
+ *
37
+ * @param string $key
38
+ *
39
+ * @return bool
40
+ */
41
+ public function has ($ key );
42
+ }
Original file line number Diff line number Diff line change 2
2
3
3
namespace Tonik \Gin \Foundation ;
4
4
5
+ use Tonik \Gin \Contract \ConfigInterface ;
5
6
use Tonik \Gin \Foundation \Exception \FileNotFoundException ;
6
- use Tonik \Gin \Foundation \Theme ;
7
7
8
8
class Autoloader
9
9
{
10
10
/**
11
11
* Theme config instance.
12
12
*
13
- * @var array
13
+ * @var \Tonik\Gin\Contract\ConfigInterface
14
14
*/
15
15
protected $ config ;
16
16
17
17
/**
18
18
* Construct autoloader.
19
19
*
20
- * @param \Tonik\Gin\Foundation\Theme $theme
20
+ * @param \Tonik\Gin\Contract\ConfigInterface $config
21
21
*/
22
- public function __construct ($ config )
22
+ public function __construct (ConfigInterface $ config )
23
23
{
24
24
$ this ->config = $ config ;
25
25
}
Original file line number Diff line number Diff line change 3
3
namespace Tonik \Gin \Foundation ;
4
4
5
5
use ArrayAccess ;
6
+ use Tonik \Gin \Contract \ConfigInterface ;
6
7
7
- class Config implements ArrayAccess
8
+ class Config implements ConfigInterface, ArrayAccess
8
9
{
9
10
/**
10
11
* All of the configuration items.
Original file line number Diff line number Diff line change 2
2
3
3
namespace Tonik \Gin \Foundation ;
4
4
5
- use Closure ;
6
5
use ArrayAccess ;
6
+ use Closure ;
7
7
use Tonik \Gin \Foundation \Exception \BindingResolutionException ;
8
8
9
9
class Theme extends Singleton implements ArrayAccess
@@ -92,7 +92,7 @@ public function get($key, array $parameters = [])
92
92
if (isset ($ this ->services [$ key ])) {
93
93
// Resolve service jf we don't have
94
94
// a deposit for this service.
95
- if (! isset ($ this ->deposit [$ key ])) {
95
+ if ( ! isset ($ this ->deposit [$ key ])) {
96
96
$ this ->deposit [$ key ] = $ this ->resolve ($ this ->services [$ key ], $ parameters );
97
97
}
98
98
@@ -148,7 +148,7 @@ public function offsetGet($key)
148
148
*/
149
149
public function offsetSet ($ key , $ service )
150
150
{
151
- if (! is_callable ($ service )) {
151
+ if ( ! is_callable ($ service )) {
152
152
throw new BindingResolutionException ("Service definition [ {$ service }] is not an instance of Closure " );
153
153
}
154
154
Original file line number Diff line number Diff line change 2
2
3
3
namespace Tonik \Gin \Template ;
4
4
5
- use Tonik \Gin \Foundation \ Config ;
5
+ use Tonik \Gin \Contract \ ConfigInterface ;
6
6
use Tonik \Gin \Foundation \Exception \FileNotFoundException ;
7
- use Tonik \Gin \Foundation \Theme ;
8
7
9
8
class Template
10
9
{
11
10
/**
12
11
* Theme config instance.
13
12
*
14
- * @var array
13
+ * @var \Tonik\Gin\Contract\ConfigInterface
15
14
*/
16
15
protected $ config ;
17
16
@@ -25,9 +24,9 @@ class Template
25
24
/**
26
25
* Construct template.
27
26
*
28
- * @param \Tonik\Gin\Foundation\Config $config
27
+ * @param \Tonik\Gin\Contract\ConfigInterface $config
29
28
*/
30
- public function __construct (Config $ config )
29
+ public function __construct (ConfigInterface $ config )
31
30
{
32
31
$ this ->config = $ config ;
33
32
}
@@ -149,13 +148,13 @@ public function isNamed()
149
148
{
150
149
// If file is not array, then template
151
150
// is not named for sure.
152
- if (! is_array ($ this ->file )) {
151
+ if ( ! is_array ($ this ->file )) {
153
152
return false ;
154
153
}
155
154
156
155
// Return false if template is named,
157
156
// but name is bool or null.
158
- if (isset ($ this ->file [1 ]) && is_bool ($ this ->file [1 ]) || is_null ( $ this ->file [1 ]) ) {
157
+ if (isset ($ this ->file [1 ]) && is_bool ($ this ->file [1 ]) || null === $ this ->file [1 ]) {
159
158
return false ;
160
159
}
161
160
You can’t perform that action at this time.
0 commit comments