Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used AdapterManager trait to extends Configurator
- Loading branch information
Showing
5 changed files
with
56 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.PHONY: test | ||
|
||
test: | ||
./vendor/bin/tester -c tests/php-unix.ini tests/ |
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
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,45 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (c) 2015 Petr Bilek (http://ww.sallyx.org) | ||
*/ | ||
|
||
namespace Sallyx\Nette; | ||
|
||
/** | ||
* Use this trait to extend \Nette\Configurator | ||
* Add ability to add adapters | ||
* | ||
*/ | ||
trait AdapterManager | ||
{ | ||
|
||
/** | ||
* @var array string => IAdapter|string | ||
*/ | ||
private $adapters = array(); | ||
|
||
/** | ||
* @param string $extension | ||
* @param string|Nette\DI\Config\IAdapter $adapter | ||
* @return self | ||
*/ | ||
public function addAdapter($extension, $adapter) | ||
{ | ||
$this->adapters[strtolower($extension)] = $adapter; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return DI\Config\Loader | ||
*/ | ||
protected function createLoader() | ||
{ | ||
$loader = parent::createLoader(); | ||
foreach ($this->adapters as $extension => $adapter) { | ||
$loader->addAdapter($extension, $adapter); | ||
} | ||
return $loader; | ||
} | ||
|
||
} |
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