-
-
Notifications
You must be signed in to change notification settings - Fork 372
/
ServicesProvider.php
70 lines (62 loc) · 2.16 KB
/
ServicesProvider.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
<?php
/*
* UserFrosting (http://www.userfrosting.com)
*
* @link https://github.com/userfrosting/UserFrosting
* @copyright Copyright (c) 2019 Alexander Weissman
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
*/
namespace UserFrosting\System;
use Psr\Container\ContainerInterface;
use RocketTheme\Toolbox\Event\EventDispatcher;
use UserFrosting\System\Sprinkle\SprinkleManager;
use UserFrosting\UniformResourceLocator\ResourceLocator;
/**
* UserFrosting system services provider.
*
* Registers system services for UserFrosting, such as file locator, event dispatcher, and sprinkle manager.
*
* @author Alex Weissman (https://alexanderweissman.com)
*/
class ServicesProvider
{
/**
* Register UserFrosting's system services.
*
* @param ContainerInterface $container A DI container implementing ArrayAccess and psr-container.
*/
public function register(ContainerInterface $container)
{
/*
* Set up the event dispatcher, required by Sprinkles to hook into the UF lifecycle.
*
* @return \RocketTheme\Toolbox\Event\EventDispatcher
*/
$container['eventDispatcher'] = function ($c) {
return new EventDispatcher();
};
/*
* Path/file locator service.
*
* Register custom streams for the application, and add paths for app-level streams.
*
* @return \UserFrosting\UniformResourceLocator\ResourceLocator
*/
$container['locator'] = function ($c) {
$locator = new ResourceLocator(\UserFrosting\ROOT_DIR);
// Register streams
$locator->registerStream('bakery', '', \UserFrosting\BAKERY_SYSTEM_DIR, true);
$locator->registerStream('bakery', '', \UserFrosting\BAKERY_DIR);
$locator->registerStream('sprinkles', '', '');
return $locator;
};
/*
* Set up sprinkle manager service.
*
* @return \UserFrosting\System\Sprinkle\SprinkleManager
*/
$container['sprinkleManager'] = function ($c) {
return new SprinkleManager($c);
};
}
}