Merge pull request #3352 from githubjeka/upload

More correct code for \humhub\modules\file\widgets\Upload::init()
This commit is contained in:
Lucas Bartholemy 2018-10-26 12:00:50 +02:00 committed by GitHub
commit c12c35305c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,9 @@
<?php
/**
* Created by PhpStorm.
* User: kingb
* Date: 08.10.2018
* Time: 17:27
* @link https://www.humhub.org/
* @copyright Copyright (c) 2016 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\file\widgets;
@ -163,7 +163,7 @@ class Upload extends Widget
* Static initializer
*
* @param array $cfg
* @return static
* @return static|object
* @throws \yii\base\InvalidConfigException
*/
public static function create($cfg = [])
@ -178,12 +178,16 @@ class Upload extends Widget
public function init()
{
parent::init();
if(!$this->id) {
if (!$this->id) {
$this->id = $this->getId(true);
}
if($this->max === true) {
$this->max = Yii::$app->getModule('content')->maxAttachedFiles;
if ($this->max === true) {
/** @var \humhub\modules\content\Module $contentModule */
$contentModule = Yii::$app->getModule('content');
if ($contentModule !== null) {
$this->max = $contentModule->maxAttachedFiles;
}
}
}