This repository was archived by the owner on Mar 27, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathAbstractBaseModularModule.php
More file actions
94 lines (86 loc) · 2.91 KB
/
Copy pathAbstractBaseModularModule.php
File metadata and controls
94 lines (86 loc) · 2.91 KB
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
<?php
namespace RebelCode\Modular\Module;
use ArrayAccess;
use Dhii\Data\Container\ContainerFactoryInterface;
use Dhii\Util\String\StringableInterface as Stringable;
use Psr\Container\ContainerInterface;
use stdClass;
use Traversable;
/**
* Base functionality for modular modules.it
*
* @since [*next-version*]
*/
abstract class AbstractBaseModularModule extends AbstractBaseModule
{
/*
* Provides modular functionality for modules.
*
* @since [*next-version*]
*/
use ModularModuleTrait;
/**
* The factory to use for creating composite containers.
*
* @since [*next-version*]
*
* @var ContainerFactoryInterface
*/
protected $compContainerFactory;
/**
* Initializes the modular module with all required information.
*
* @since [*next-version*]
*
* @param ContainerFactoryInterface $compContainerFactory The composite container factory.
* @param ContainerFactoryInterface $containerFactory The container factory.
* @param string|Stringable $key The module key.
* @param string[]|Stringable[] $dependencies The module dependencies.
* @param array|ArrayAccess|stdClass|ContainerInterface $config The module config.
*/
protected function _initModularModule(
ContainerFactoryInterface $compContainerFactory,
ContainerFactoryInterface $containerFactory,
$key,
$dependencies = [],
$config = []
) {
$this->_setCompositeContainerFactory($compContainerFactory);
$this->_initModule($containerFactory, $key, $dependencies, $config);
}
/**
* Retrieves the composite container factory associated with this module.
*
* @since [*next-version*]
*
* @return ContainerFactoryInterface The composite container factory instance.
*/
protected function _getCompositeContainerFactory()
{
return $this->compContainerFactory;
}
/**
* Sets the composite container factory for this module.
*
* @since [*next-version*]
*
* @param ContainerFactoryInterface $compContainerFactory The composite container factory instance.
*/
protected function _setCompositeContainerFactory(ContainerFactoryInterface $compContainerFactory)
{
$this->compContainerFactory = $compContainerFactory;
}
/**
* Creates a composite container with the given children container instances.
*
* @since [*next-version*]
*
* @param ContainerInterface[]|Traversable $containers The children container instances.
*
* @return ContainerInterface The created composite container instance.
*/
protected function _createCompositeContainer($containers)
{
return $this->_getCompositeContainerFactory()->make(['containers' => $containers]);
}
}