-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scope.php
40 lines (35 loc) · 922 Bytes
/
Scope.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
<?php
/**
*
*/
namespace Mvc5\Plugin;
use Mvc5\App;
use Mvc5\Service\Manager;
use Mvc5\Service\Service;
use const Mvc5\SERVICES;
/**
* Creates a model with a scopable plugins container and sets the model as the scope of the anonymous functions.
*/
class Scope
extends Call
{
/**
* @param array $plugins
* @param string $name
*/
function __construct(array $plugins, string $name)
{
parent::__construct([$this, 'scope'], [
new Plugin(App::class, [[SERVICES => $plugins], null, true, true]), new Link, $name]);
}
/**
* @param Manager $context
* @param Service $service
* @param string $name
* @return callable|object|null
*/
function scope(Manager $context, Service $service, string $name)
{
return $context->plugin(new ScopedCall(fn() => fn() => $this->scope = $service->plugin($name, [$this, $service])));
}
}