Skip to content

Commit

Permalink
Merge branch 'release/v3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
iiifx committed May 30, 2021
2 parents 4446e3b + 6e432ca commit f73f993
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 21 additions & 3 deletions README.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
17 changes: 14 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"yiisoft/yii2": "^2.0.36"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"phpunit/phpunit": "^9"
},
"autoload": {
Expand All @@ -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"
}
]
}
10 changes: 10 additions & 0 deletions source/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions source/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions source/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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% {}
';

0 comments on commit f73f993

Please sign in to comment.