-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from tattersoftware/register
Reinstate handler registration
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 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,64 @@ | ||
# When a PR is opened or a push is made, perform | ||
# a static analysis check on the code using PHPStan. | ||
name: PHPStan | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'develop' | ||
paths: | ||
- 'src/**' | ||
- 'tests/**' | ||
- 'phpstan*' | ||
- '.github/workflows/analyze.yml' | ||
push: | ||
branches: | ||
- 'develop' | ||
paths: | ||
- 'src/**' | ||
- 'tests/**' | ||
- 'phpstan*' | ||
- '.github/workflows/analyze.yml' | ||
|
||
jobs: | ||
build: | ||
name: Analyze code (PHPStan) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
extensions: intl | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Create PHPStan result cache directory | ||
run: mkdir -p build/phpstan | ||
|
||
- name: Cache PHPStan result | ||
uses: actions/cache@v2 | ||
with: | ||
path: build/phpstan | ||
key: ${{ runner.os }}-phpstan-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-phpstan- | ||
|
||
- name: Install dependencies | ||
run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader | ||
env: | ||
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} | ||
|
||
- name: Run static analysis | ||
run: vendor/bin/phpstan analyze |
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 namespace Tatter\Handlers\Commands; | ||
|
||
use CodeIgniter\CLI\BaseCommand; | ||
use CodeIgniter\CLI\CLI; | ||
use Tatter\Handlers\Handlers; | ||
|
||
class HandlersRegister extends BaseCommand | ||
{ | ||
protected $group = 'Handlers'; | ||
protected $name = 'handlers:register'; | ||
protected $description = 'Regsiter all discovered handlers'; | ||
protected $usage = 'handlers:register'; | ||
|
||
public function run(array $params = []) | ||
{ | ||
// Load the library | ||
$handlers = new Handlers(); | ||
|
||
// Make sure auto-discovery is enabled | ||
if (empty($handlers->getConfig()->autoDiscover)) | ||
{ | ||
CLI::write('No paths are set for automatic discovery. See the config file for Tatter\Handlers.', 'yellow'); | ||
return; | ||
} | ||
|
||
// Process each path | ||
foreach ($handlers->getConfig()->autoDiscover as $path) | ||
{ | ||
$handlers->setPath($path); | ||
CLI::write($path, 'black', 'light_gray'); | ||
|
||
if (! $classes = $handlers->all()) | ||
{ | ||
CLI::write('No new handlers registered.', 'yellow'); | ||
continue; | ||
} | ||
|
||
// Display each class | ||
foreach ($classes as $class) | ||
{ | ||
CLI::write($class); | ||
} | ||
} | ||
} | ||
} |
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