-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from peckadesign/pdp-3114-nette3
#3114 Dopredne upravy pro nette3
- Loading branch information
Showing
4 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Pd\Supervisor\Adapter\Nette\DI; | ||
|
||
class CompilerExtensionAdapter | ||
{ | ||
|
||
/** | ||
* Nahrazuje volani metody $this->getConfig() s parametrem, ktery obsahuje vychozi hodnoty. | ||
* Zde je pouzita predchozi funkcionalita, nez byla z getConfig() odebrana. | ||
* V Nette3 se pro validaci configu pouziva Schema. To by jsme pak meli pouzit namisto teto funkce. | ||
* | ||
* @param array<mixed> $defaults | ||
* @return array<mixed>|string | ||
*/ | ||
public static function mergeConfigWithDefaults(\Nette\DI\CompilerExtension $extension, array $defaults) | ||
{ | ||
$defaultConfig = \Nette\DI\Helpers::expand($defaults, $extension->getContainerBuilder()->parameters); | ||
|
||
return \Nette\DI\Config\Helpers::merge($extension->getConfig(), $defaultConfig); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Pd\Supervisor\Adapter\Nette\DI; | ||
|
||
class DiStatementFactory | ||
{ | ||
public static function createDiStatement($entity, array $arguments = []) | ||
{ | ||
if (\class_exists(\Nette\DI\Definitions\Statement::class)) { | ||
return self::createDiStatementNette30($entity, $arguments); | ||
} else { | ||
return self::createDiStatementNette24($entity, $arguments); | ||
} | ||
} | ||
|
||
|
||
private static function createDiStatementNette24($entity, array $arguments = []) | ||
{ | ||
return new \Nette\DI\Statement($entity, $arguments); | ||
} | ||
|
||
|
||
private static function createDiStatementNette30($entity, array $arguments = []) | ||
{ | ||
return new \Nette\DI\Definitions\Statement($entity, $arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters