15 private $diContainerConfig;
22 private $sharedInstancePattern = [
31 private $notSharedInstancePattern = [
40 private $valuePattern = [
49 private $nullValuePattern = [
58 private $configuredArrayValuePattern = [
67 private $configuredPattern = [
77 $this->diContainerConfig = $diContainerConfig;
87 public function getResolvedConstructorArguments($instanceType, $constructor)
92 $configuredArguments = $this->getConfiguredArguments($instanceType);
96 foreach ($constructor as $constructorArgument) {
97 $argument = $this->getNonObjectArgument(
null);
98 if (!$constructorArgument->isRequired()) {
99 $argument = $this->getNonObjectArgument($constructorArgument->getDefaultValue());
100 }
elseif ($constructorArgument->getType()) {
101 $argument = $this->getInstanceArgument($constructorArgument->getType());
104 if (isset($configuredArguments[$constructorArgument->getName()])) {
105 $argument = $this->getConfiguredArgument(
106 $configuredArguments[$constructorArgument->getName()],
110 $arguments[$constructorArgument->getName()] = $argument;
122 private function getConfiguredArgument($configuredArgument, ConstructorArgument $constructorArgument)
124 if ($constructorArgument->getType()) {
125 $argument = $this->getConfiguredInstanceArgument($configuredArgument);
127 }
elseif (isset($configuredArgument[
'argument'])) {
128 return $this->getGlobalArgument($configuredArgument[
'argument'], $constructorArgument->getDefaultValue());
131 return $this->getNonObjectArgument($configuredArgument);
140 private function getConfiguredArrayAttribute($array)
142 foreach ($array as $key =>
$value) {
147 if (isset(
$value[
'instance'])) {
148 $array[$key] = $this->getConfiguredInstanceArgument(
$value);
152 if (isset(
$value[
'argument'])) {
153 $array[$key] = $this->getGlobalArgument(
$value[
'argument'],
null);
157 $array[$key] = $this->getConfiguredArrayAttribute(
$value);
169 private function getConfiguredInstanceArgument(array
$config)
171 $argument = $this->getInstanceArgument(
$config[
'instance']);
172 if (isset(
$config[
'shared'])) {
174 $pattern = $this->sharedInstancePattern;
175 $pattern[
'_i_'] = current($argument);
177 $pattern = $this->notSharedInstancePattern;
178 $pattern[
'_ins_'] = current($argument);
191 private function getConfiguredArguments($instanceType)
193 $configuredArguments = $this->diContainerConfig->getArguments($instanceType);
196 if (isset(
$type[
'instance'])) {
197 $type[
'instance'] = ltrim(
$type[
'instance'],
'\\');
212 private function getInstanceArgument($instanceType)
214 if ($this->diContainerConfig->isShared($instanceType)) {
215 $argument = $this->sharedInstancePattern;
216 $argument[
'_i_'] = $instanceType;
218 $argument = $this->notSharedInstancePattern;
219 $argument[
'_ins_'] = $instanceType;
230 private function getNonObjectArgument(
$value)
233 return $this->nullValuePattern;
236 $argument = $this->valuePattern;
238 if ($this->isConfiguredArray(
$value)) {
240 $argument = $this->configuredArrayValuePattern;
241 $argument[
'_vac_'] =
$value;
246 $argument[
'_v_'] =
$value;
256 private function isConfiguredArray(
$value)
258 foreach (
$value as $configuredValue) {
259 if (!is_array($configuredValue)) {
263 if (array_key_exists(
'instance', $configuredValue) || array_key_exists(
'argument', $configuredValue)) {
267 if ($this->isConfiguredArray($configuredValue)) {
282 private function getGlobalArgument(
$value, $default)
284 $argument = $this->configuredPattern;
285 $argument[
'_a_'] =
$value;
286 $argument[
'_d_'] = $default;
elseif(isset( $params[ 'redirect_parent']))
__construct(\Magento\Framework\ObjectManager\ConfigInterface $diContainerConfig)