-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data.php
200 lines (179 loc) · 4.55 KB
/
Data.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/**
* @package vdm/data
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git VDM Data Library <https://git.vdm.dev/joomla/vdm-data>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VastDevelopmentMethod\Joomla\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VastDevelopmentMethod\Joomla\Data\Action\Load;
use VastDevelopmentMethod\Joomla\Data\Action\Insert;
use VastDevelopmentMethod\Joomla\Data\Action\Update;
use VastDevelopmentMethod\Joomla\Data\Action\Delete;
use VastDevelopmentMethod\Joomla\Data\Item;
use VastDevelopmentMethod\Joomla\Data\Items;
use VastDevelopmentMethod\Joomla\Data\Subform;
use VastDevelopmentMethod\Joomla\Data\MultiSubform;
/**
* Data Service Provider
*
* @since 3.2.0
*/
class Data implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Load::class, 'Data.Load')
->share('Data.Load', [$this, 'getLoad'], true);
$container->alias(Insert::class, 'Data.Insert')
->share('Data.Insert', [$this, 'getInsert'], true);
$container->alias(Update::class, 'Data.Update')
->share('Data.Update', [$this, 'getUpdate'], true);
$container->alias(Delete::class, 'Data.Delete')
->share('Data.Delete', [$this, 'getDelete'], true);
$container->alias(Item::class, 'Data.Item')
->share('Data.Item', [$this, 'getItem'], true);
$container->alias(Items::class, 'Data.Items')
->share('Data.Items', [$this, 'getItems'], true);
$container->alias(Subform::class, 'Data.Subform')
->share('Data.Subform', [$this, 'getSubform'], true);
$container->alias(MultiSubform::class, 'Data.MultiSubform')
->share('Data.MultiSubform', [$this, 'getMultiSubform'], true);
}
/**
* Get The Load Class.
*
* @param Container $container The DI container.
*
* @return Load
* @since 3.2.0
*/
public function getLoad(Container $container): Load
{
return new Load(
$container->get('Model.Load'),
$container->get('Load')
);
}
/**
* Get The Insert Class.
*
* @param Container $container The DI container.
*
* @return Insert
* @since 3.2.0
*/
public function getInsert(Container $container): Insert
{
return new Insert(
$container->get('Model.Upsert'),
$container->get('Insert')
);
}
/**
* Get The Update Class.
*
* @param Container $container The DI container.
*
* @return Update
* @since 3.2.0
*/
public function getUpdate(Container $container): Update
{
return new Update(
$container->get('Model.Upsert'),
$container->get('Update')
);
}
/**
* Get The Delete Class.
*
* @param Container $container The DI container.
*
* @return Delete
* @since 3.2.0
*/
public function getDelete(Container $container): Delete
{
return new Delete(
$container->get('Delete')
);
}
/**
* Get The Item Class.
*
* @param Container $container The DI container.
*
* @return Item
* @since 3.2.0
*/
public function getItem(Container $container): Item
{
return new Item(
$container->get('Data.Load'),
$container->get('Data.Insert'),
$container->get('Data.Update'),
$container->get('Data.Delete'),
$container->get('Load')
);
}
/**
* Get The Items Class.
*
* @param Container $container The DI container.
*
* @return Items
* @since 3.2.0
*/
public function getItems(Container $container): Items
{
return new Items(
$container->get('Data.Load'),
$container->get('Data.Insert'),
$container->get('Data.Update'),
$container->get('Data.Delete'),
$container->get('Load')
);
}
/**
* Get The Subform Class.
*
* @param Container $container The DI container.
*
* @return Subform
* @since 3.2.0
*/
public function getSubform(Container $container): Subform
{
return new Subform(
$container->get('Data.Items')
);
}
/**
* Get The MultiSubform Class.
*
* @param Container $container The DI container.
*
* @return MultiSubform
* @since 3.2.0
*/
public function getMultiSubform(Container $container): MultiSubform
{
return new MultiSubform(
$container->get('Data.Subform')
);
}
}