-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 #1215 from bcit-ci/autodiscovery
Autodiscovery for Modules
- Loading branch information
Showing
23 changed files
with
263 additions
and
179 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,54 @@ | ||
<?php namespace Config; | ||
|
||
// Cannot extend BaseConfig or looping resources occurs. | ||
class Modules | ||
{ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Auto-Discovery Enabled? | ||
|-------------------------------------------------------------------------- | ||
| | ||
| If true, then auto-discovery will happen across all elements listed in | ||
| $activeExplorers below. If false, no auto-discovery will happen at all, | ||
| giving a slight performance boost. | ||
*/ | ||
public $enabled = true; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Auto-discover Rules | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Lists the aliases of all discovery classes that will be active | ||
| and used during the current application request. If it is not | ||
| listed here, only the base application elements will be used. | ||
*/ | ||
public $activeExplorers = [ | ||
'events', | ||
'registrars', | ||
'routes', | ||
'services', | ||
]; | ||
|
||
/** | ||
* Should the application auto-discover the requested resources. | ||
* | ||
* Valid values are: | ||
* - events | ||
* - registrars | ||
* - routes | ||
* - services | ||
* | ||
* @param string $alias | ||
* | ||
* @return bool | ||
*/ | ||
public function shouldDiscover(string $alias) | ||
{ | ||
if (! $this->enabled) return false; | ||
|
||
$alias = strtolower($alias); | ||
|
||
return in_array($alias, $this->activeExplorers); | ||
} | ||
} |
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
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
Oops, something went wrong.