diff --git a/.travis.yml b/.travis.yml index 9e227cd..5030891 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,16 +8,8 @@ install: - composer config --global github-oauth.github.com "$GITHUB_TOKEN" - composer --version - composer clear-cache -# - composer global require "fxp/composer-asset-plugin:@stable" - export PATH="$HOME/.composer/vendor/bin:$PATH" - composer update --prefer-dist script: - composer test - -#after_script: -# - | -# if [ $TRAVIS_PHP_VERSION = '7.1' ]; then -# wget https://scrutinizer-ci.com/ocular.phar -# php ocular.phar code-coverage:upload --format=php-clover ./code-coverage/coverage.clover -# fi diff --git a/README.RU.md b/README.RU.md index 094422a..864ce9e 100644 --- a/README.RU.md +++ b/README.RU.md @@ -2,7 +2,7 @@ Генератор автодополнения для пользовательских компонентов в Yii2. -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b/big.png)](https://insight.sensiolabs.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b) +[![SensioLabsInsight](https://insight.symfony.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b/big.svg)](https://insight.symfony.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b) [![Latest Version on Packagist][ico-version]][link-packagist] [![Total Downloads][ico-downloads]][link-downloads] @@ -233,16 +233,34 @@ php yii my-custom-generator php yii ide-components --config=api ``` +### Настройка классов приложений + +В некоторых проектах иногда могут использоваться переопределенные классы приложений для web и console. + +Вы можете сделать это через соответствующую настройку в конфигурации. + +```php + 'bootstrap' => ['log', 'autocomplete'], + 'components' => [ + 'autocomplete' => [ + 'class' => 'iiifx\Yii2\Autocomplete\Component', + 'webAppClass' => '\full\namespace\to\WebApplicationClass', + 'consoleAppClass' => '\full\namespace\to\ConsoleApplicationClass', + ], + # ... + ] +``` + [ico-version]: https://img.shields.io/packagist/v/iiifx-production/yii2-autocomplete-helper.svg [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg [ico-downloads]: https://img.shields.io/packagist/dt/iiifx-production/yii2-autocomplete-helper.svg -[ico-travis]: https://travis-ci.org/iiifx-production/yii2-autocomplete-helper.svg +[ico-travis]: https://travis-ci.com/iiifx-production/yii2-autocomplete-helper.svg [ico-scrutinizer]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/badges/quality-score.png?b=master [ico-codecoverage]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/badges/coverage.png?b=master [link-packagist]: https://packagist.org/packages/iiifx-production/yii2-autocomplete-helper [link-downloads]: https://packagist.org/packages/iiifx-production/yii2-autocomplete-helper -[link-travis]: https://travis-ci.org/iiifx-production/yii2-autocomplete-helper +[link-travis]: https://travis-ci.com/iiifx-production/yii2-autocomplete-helper [link-scrutinizer]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/?branch=master diff --git a/README.md b/README.md index 59ec96e..b5e750c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Autocompletion generator for custom components in Yii2. -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b/big.png)](https://insight.sensiolabs.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b) +[![SensioLabsInsight](https://insight.symfony.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b/big.svg)](https://insight.symfony.com/projects/38baa1e0-54e8-4cf8-bd30-3c76e8a44d9b) [![Latest Version on Packagist][ico-version]][link-packagist] [![Total Downloads][ico-downloads]][link-downloads] @@ -232,15 +232,33 @@ Now you can generate autocompletion for the desired group: php yii ide-components --config=api ``` +### Configuring Application Classes + +Some projects can sometimes use overridden application classes for web and console. + +You can do this through the appropriate setting in the config. + +```php + 'bootstrap' => ['log', 'autocomplete'], + 'components' => [ + 'autocomplete' => [ + 'class' => 'iiifx\Yii2\Autocomplete\Component', + 'webAppClass' => '\full\namespace\to\WebApplicationClass', + 'consoleAppClass' => '\full\namespace\to\ConsoleApplicationClass', + ], + # ... + ] +``` + [ico-version]: https://img.shields.io/packagist/v/iiifx-production/yii2-autocomplete-helper.svg [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg [ico-downloads]: https://img.shields.io/packagist/dt/iiifx-production/yii2-autocomplete-helper.svg -[ico-travis]: https://travis-ci.org/iiifx-production/yii2-autocomplete-helper.svg +[ico-travis]: https://travis-ci.com/iiifx-production/yii2-autocomplete-helper.svg [ico-scrutinizer]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/badges/quality-score.png?b=master [ico-codecoverage]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/badges/coverage.png?b=master [link-packagist]: https://packagist.org/packages/iiifx-production/yii2-autocomplete-helper [link-downloads]: https://packagist.org/packages/iiifx-production/yii2-autocomplete-helper -[link-travis]: https://travis-ci.org/iiifx-production/yii2-autocomplete-helper +[link-travis]: https://travis-ci.com/iiifx-production/yii2-autocomplete-helper [link-scrutinizer]: https://scrutinizer-ci.com/g/iiifx-production/yii2-autocomplete-helper/?branch=master diff --git a/composer.json b/composer.json index b245e14..acd2ae2 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "yiisoft/yii2": "^2.0.36" }, "require-dev": { + "roave/security-advisories": "dev-latest", "phpunit/phpunit": "^9" }, "autoload": { @@ -36,9 +37,19 @@ "test": "phpunit tests" }, "config": { + "process-timeout": 1800, + "preferred-install": "dist", + "preferred-update": "dist", + "sort-packages": true, + "optimize-autoloader": true, "fxp-asset": { - "npm-asset-library": "vendor/npm-asset", - "bower-asset-library": "vendor/bower-asset" + "enabled": false } - } + }, + "repositories": [ + { + "type": "composer", + "url": "https://asset-packagist.org" + } + ] } diff --git a/source/Builder.php b/source/Builder.php index 8969669..975421c 100644 --- a/source/Builder.php +++ b/source/Builder.php @@ -14,6 +14,8 @@ class Builder extends BaseObject { public ?string $template = null; public array $components = []; + public ?string $webAppClass = null; + public ?string $consoleAppClass = null; public function build(string|false $file = null): bool|string { @@ -29,6 +31,14 @@ public function build(string|false $file = null): bool|string return $string; } + if ($m[0] === '%webapp%') { + return $this->webAppClass ?? '\yii\web\Application'; + } + + if ($m[0] === '%consoleapp%') { + return $this->consoleAppClass ?? '\yii\console\Application'; + } + return $m[0]; }, $this->template); diff --git a/source/Component.php b/source/Component.php index ab8cde9..e6de0d4 100644 --- a/source/Component.php +++ b/source/Component.php @@ -20,6 +20,8 @@ class Component extends BaseObject implements BootstrapInterface ]; public ?string $result = null; public ?array $config = null; + public ?string $webAppClass = null; + public ?string $consoleAppClass = null; /** * @inheritdoc diff --git a/source/Controller.php b/source/Controller.php index 375ab45..f848a70 100644 --- a/source/Controller.php +++ b/source/Controller.php @@ -69,6 +69,8 @@ public function actionIndex(): void $builder = new Builder([ 'components' => $config->getComponents(), 'template' => require __DIR__ . '/template.php', + 'webAppClass' => $component->webAppClass, + 'consoleAppClass' => $component->consoleAppClass, ]); if (null === $component->result) { diff --git a/source/template.php b/source/template.php index 3403a2c..564c8ae 100644 --- a/source/template.php +++ b/source/template.php @@ -28,8 +28,8 @@ class Yii extends \yii\BaseYii abstract class BaseApplication extends \yii\base\Application {} %phpdoc% -class WebApplication extends \yii\web\Application {} +class WebApplication extends %webapp% {} %phpdoc% -class ConsoleApplication extends \yii\console\Application {} +class ConsoleApplication extends %consoleapp% {} ';