-
Notifications
You must be signed in to change notification settings - Fork 7
/
FuelServiceProvider.php
108 lines (88 loc) · 2.67 KB
/
FuelServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* @package Fuel\Common
* @version 2.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2015 Fuel Development Team
* @link http://fuelphp.com
*/
namespace Fuel\Common\Providers;
use League\Container\ServiceProvider;
use Fuel\Common;
/**
* Fuel ServiceProvider class for Common
*
* @package Fuel\Common
*
* @since 2.0
*/
class FuelServiceProvider extends ServiceProvider
{
/**
* @var array
*/
protected $provides = [
'arr',
'datacontainer',
'cookiejar',
'format',
'date',
'num',
'str',
'inflector',
'debug'
];
/**
* {@inheritdoc}
*/
public function register()
{
$this->container->add('arr', 'Fuel\Common\Arr');
$this->container->add('datacontainer', function (array $data = [], $readOnly = false)
{
return new Common\DataContainer($data, $readOnly);
});
// \Fuel\Common\CookieJar
$this->container->add('cookiejar', function (array $config = [], array $data = [])
{
return new Common\CookieJar($config, $data);
});
$this->container->add('format', function ($data = null, $fromType = null, array $config = [])
{
$configInstance = $this->container->get('configInstance');
$input = $this->container->get('inputInstance');
$config = \Arr::merge($configInstance->load('format', true), $config);
$inflector = $this->container->get('inflector');
return new Common\Format($data, $fromType, $config, $input, $inflector);
});
$this->container->add('pagination', function ($view)
{
$input = $this->container->get('inputInstance');
$viewManager = $this->container->get('viewManagerInstance');
return new Common\Pagination($viewManager, $input, $view);
});
$this->container->add('date', function ($time = "now", $timezone = null, array $config = [])
{
$configInstance = $this->container->get('configInstance');
$config = \Arr::merge($configInstance->load('date', true), $config);
return new Common\Date($time, $timezone, $config);
});
$this->container->add('num', function (array $config = [], array $lang = [])
{
$configInstance = $this->container->get('configInstance');
$langInstance = $this->container->get('langInstance');
$config = \Arr::merge($configInstance->load('num', true), $config);
$lang = \Arr::merge($langInstance->load('byteunits', true), $lang);
return new Common\Num($config, $lang);
});
$this->container->singleton('str', 'Fuel\Common\Str');
$this->container->singleton('inflector', 'Fuel\Common\Inflector')
->withArgument(null)
->withArgument('security')
->withArgument('str');
$this->container->singleton('debug', 'Fuel\Common\Debug')
->withArgument(null)
->withArgument('inflector');
}
}