Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Dec 9, 2019
2 parents 3286b88 + cb2fdfd commit b19dd1a
Show file tree
Hide file tree
Showing 27 changed files with 668 additions and 205 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -10,12 +10,14 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4
- nightly

matrix:
allow_failures:
- php: 5.6
- php: 7.0
- php: 7.4
- php: nightly

sudo: false
Expand Down
480 changes: 341 additions & 139 deletions composer.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions core/CHANGELOG.md
Expand Up @@ -6,6 +6,14 @@ In order to read more about upgrading and BC breaks have a look at the [UPGRADE
## 1.0.24

+ [#1969](https://github.com/luyadev/luya/pull/1969) Fixed exception handling while loading empty theme directories.
+ [#1977](https://github.com/luyadev/luya/pull/1977) Added new `ArrayHelper::combine()` method to generate an array with the same keys and values.
+ [#1977](https://github.com/luyadev/luya/pull/1978) Added support for ActiveForm context to SubmitButtonWidget. Supporting multi form (including pjax) on same page.

## 1.0.23 (27. November 2019)

+ [#1975](https://github.com/luyadev/luya/pull/1975) Added new luya\Config `callback(fn)` function to run define('YII_DEBUG', true) commands.
+ [#1974](https://github.com/luyadev/luya/issues/1974) Register module components in bootstrap section before run luyaBootstrap method.
+ [#1971](https://github.com/luyadev/luya/issues/1971) Add opcache reset to health command.

## 1.0.22 (22. October 2019)

Expand Down
23 changes: 20 additions & 3 deletions core/Config.php
Expand Up @@ -178,6 +178,18 @@ public function module($id, $config)
return $this->addDefinition(new ConfigDefinition(ConfigDefinition::GROUP_MODULES, $id, $config));
}

/**
* Run a callable functions for the defined env when toArray() is called.
*
* @param callable $fn The function to run, the first argument of the closure is the {{luya\Config}} object.
* @return ConfigDefinition
* @since 1.0.23
*/
public function callback(callable $fn)
{
return $this->addDefinition(New ConfigDefinition(ConfigDefinition::GROUP_CALLABLE, false, $fn));
}

/**
* Register a component
*
Expand Down Expand Up @@ -218,7 +230,7 @@ public function consoleComponent($id, $config)
private $_definitions = [];

/**
* Add a defintion into the defintions bag.
* Add a definition into the definitions bag.
*
* @param ConfigDefinition $definition
* @return ConfigDefinition
Expand Down Expand Up @@ -291,7 +303,7 @@ public function toArray(array $envs = [])
}

/**
* Append a given defintion int othe config
* Append a given definition int othe config
*
* @param array $config
* @param ConfigDefinition $definition
Expand Down Expand Up @@ -319,11 +331,16 @@ private function appendConfig(&$config, ConfigDefinition $definition)
foreach ($definition->getConfig() as $v) {
$config['bootstrap'][] = $v;
}
break;

case ConfigDefinition::GROUP_CALLABLE:
call_user_func($definition->getConfig(), $this);
break;
}
}

/**
* Add a array key based component defintion.
* Add a array key based component definition.
*
* @param array $config
* @param ConfigDefinition $definition
Expand Down
6 changes: 4 additions & 2 deletions core/ConfigDefinition.php
Expand Up @@ -30,11 +30,13 @@ class ConfigDefinition
*/
const GROUP_BOOTSTRAPS = 4;

const GROUP_CALLABLE = 5;

private $_group;

private $_key;

private $_config = [];
private $_config;

/**
* Consturctor
Expand All @@ -47,7 +49,7 @@ public function __construct($group, $key, $config)
{
$this->_group = $group;
$this->_key = $key;
$this->_config = is_array($config) ? $config : ['class' => $config];
$this->_config = is_scalar($config) ? ['class' => $config] : $config;
}

private $_env = Config::ENV_ALL;
Expand Down
4 changes: 2 additions & 2 deletions core/base/BaseBootstrap.php
Expand Up @@ -103,15 +103,15 @@ private function startModules($app)
// set an alias for all user modules
Yii::setAlias('@'.$id, $module->getBasePath());

$module->luyaBootstrap($app);

// see if the module has a registerComponents method
foreach ($module->registerComponents() as $componentId => $definition) {
if (!$app->has($componentId)) {
Yii::trace('Register component ' . $componentId, __METHOD__);
$app->set($componentId, $definition);
}
}

$module->luyaBootstrap($app);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/base/Boot.php
Expand Up @@ -24,7 +24,7 @@ abstract class Boot
/**
* @var string The current LUYA version (see: https://github.com/luyadev/luya/blob/master/core/CHANGELOG.md)
*/
const VERSION = '1.0.23';
const VERSION = '1.0.24';

/**
* @var string The path to the config file, which returns an array containing you configuration.
Expand Down
58 changes: 27 additions & 31 deletions core/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions core/console/commands/HealthController.php
Expand Up @@ -39,6 +39,11 @@ class HealthController extends \luya\console\Command
*/
public function actionIndex()
{
// opcache reset should run in web context, but might be helpfull as well.
if (function_exists('opcache_reset')) {
@opcache_reset();
}

$error = false;

@chdir(Yii::getAlias('@app'));
Expand Down
21 changes: 21 additions & 0 deletions core/helpers/ArrayHelper.php
Expand Up @@ -81,6 +81,8 @@ public static function coverSensitiveValues(array $data, array $keys = [])

/**
* Prepend an assoc array item as first entry for a given array.
*
* Adds the given key with value as first entry to $arr
*
* @param array $arr The array where the value should be prepend
* @param string $key The new array key
Expand Down Expand Up @@ -278,4 +280,23 @@ public static function generateRange($from, $to, $text = null)

return $array;
}

/**
* Helper method to generate an array with the same keys and values.
*
* ```php
* $data = ArrayHelper::combine(['foo', 'bar']);
*
* // generates
* ['foo' => 'foo', 'bar' => 'bar'];
* ```
*
* @param array $array The array to combine.
* @return array
* @since 1.0.24
*/
public static function combine(array $array)
{
return array_combine($array, $array);
}
}
16 changes: 15 additions & 1 deletion core/helpers/StringHelper.php
Expand Up @@ -126,9 +126,23 @@ public static function replaceFirst($search, $replace, $subject)
*
* If an array of needle words is provided the $strict parameter defines whether all need keys must be found
* in the string to get the `true` response or if just one of the keys are found the response is already `true`.
*
* ```php
* if (StringHelper::contains('foo', 'the foo bar Bar'')) {
* echo "yes!";
* }
* ```
*
* check if one of the given needles exists:
*
* ```php
* if (StringHelper::contains(['jungle', 'hell0], 'Welcome to the jungle!)) {
* echo "yes!";
* }
* ```
*
* @param string|array $needle The char or word to find in the $haystack. Can be an array to multi find words or char in the string.
* @param string $haystack The haystack where the $needle string should be looked up.
* @param string $haystack The haystack where the $needle string should be looked up. A string or phrase with words.
* @param boolean $strict If an array of needles is provided the $strict parameter defines whether all keys must be found ($strict = true) or just one result must be found ($strict = false).
* @return boolean If an array of values is provided the response may change depending on $findAll.
*/
Expand Down
2 changes: 2 additions & 0 deletions core/web/Application.php
Expand Up @@ -16,6 +16,8 @@
* @property \luya\web\View $view The view component.
* @property \luya\web\Request $request The request component.
* @property \luya\web\ErrorHandler $errorHandler The error handler component.
* @property \luya\admin\components\Jwt $jwt The admin JWT handler component, if enabled in the Admin module.
* @property \yii\queue\db\Queue $adminqueue The yii queue component configured for the Admin module.
*
* @author Basil Suter <basil@nadar.io>
* @since 1.0.0
Expand Down

0 comments on commit b19dd1a

Please sign in to comment.