Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.17] Update module resources path #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .github/workflows/php-test-v1.8.yml

This file was deleted.

35 changes: 35 additions & 0 deletions Events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\birthday;

use humhub\modules\birthday\widgets\BirthdaySidebarWidget;
use humhub\modules\dashboard\widgets\Sidebar;
use Yii;
use yii\base\Event;

class Events
{
/**
* On build of the dashboard sidebar widget, add the birthday widget if module is enabled.
*
* @param Event $event
*/
public static function onDashboardSidebarInit($event)
{
if (Yii::$app->user->isGuest) {
return;
}

/* @var Module $module */
$module = Yii::$app->getModule('birthday');

/* @var Sidebar $sidebar */
$sidebar = $event->sender;
$sidebar->addWidget(BirthdaySidebarWidget::class, [], ['sortOrder' => $module->sidebarSortOrder]);
}
}
28 changes: 2 additions & 26 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,20 @@

namespace humhub\modules\birthday;

use Yii;
use humhub\modules\birthday\widgets\BirthdaySidebarWidget;
use humhub\models\Setting;
use yii\helpers\Url;

/**
* BirthdayModule is responsible for the the birthday functions.
*
*
* @author Sebastian Stumpf
*/
class Module extends \humhub\components\Module
{
/**
* @inheritdoc
*/
public $resourcesPath = 'assets';

/** *
* @var int the sort order for the birthdays sidebar widget
*/
public $sidebarSortOrder = 200;

/**
* On build of the dashboard sidebar widget, add the birthday widget if module is enabled.
*
* @param type $event
*/
public static function onSidebarInit($event)
{
if (Yii::$app->user->isGuest) {
return;
}

$module = Yii::$app->getModule('birthday');
$event->sender->addWidget(BirthdaySidebarWidget::class, [], ['sortOrder' => $module->sidebarSortOrder]);
}
public int $sidebarSortOrder = 200;

/**
* @inheritdoc
Expand All @@ -57,5 +35,3 @@ public function enable()
}

}

?>
14 changes: 5 additions & 9 deletions Assets.php → assets/Assets.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<?php

/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\birthday;
namespace humhub\modules\birthday\assets;

use yii\web\AssetBundle;

class Assets extends AssetBundle
{

public function init()
{
$this->sourcePath = dirname(__FILE__) . '/assets';
parent::init();
}

/**
* @inheritdoc
*/
public $sourcePath = '@birthday/resources';
}
4 changes: 2 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

use humhub\modules\birthday\Events;
use humhub\modules\dashboard\widgets\Sidebar;

return [
'id' => 'birthday',
'class' => 'humhub\modules\birthday\Module',
'namespace' => 'humhub\modules\birthday',
'events' => [
array('class' => Sidebar::class, 'event' => Sidebar::EVENT_INIT, 'callback' => array('humhub\modules\birthday\Module', 'onSidebarInit')),
['class' => Sidebar::class, 'event' => Sidebar::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']],
],
];
?>
4 changes: 2 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Changelog
=========

1.0.16 - Unreleased
1.1.0 - Unreleased
-----------------------
- Enh #36: Tests for `next` version
- Fix #37: Set module resources path
- Fix #37: Update module resources path

1.0.15 - April 14, 2022
-----------------------
Expand Down
12 changes: 6 additions & 6 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"id": "birthday",
"name": "Birthday Widget",
"description": "Adds a widget to the dashbaord showing upcoming birthdays.",
"description": "Adds a widget to the dashboard showing upcoming birthdays.",
"keywords": [
"birthday",
"widget",
"dashboard"
],
"version": "1.0.16",
"version": "1.1.0",
"humhub": {
"minVersion": "1.8"
"minVersion": "1.17"
},
"homepage": "https://github.com/humhub-contrib/birthday",
"authors": [
Expand All @@ -18,8 +18,8 @@
}
],
"screenshots": [
"assets/screen1.PNG",
"assets/screen2.PNG",
"assets/screen3.PNG"
"resources/screen1.PNG",
"resources/screen2.PNG",
"resources/screen3.PNG"
]
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion widgets/views/birthdayPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @package humhub.modules.birthday.widgets.views
* @author Sebastian Stumpf
*/
$assets = \humhub\modules\birthday\Assets::register($this);
$assets = \humhub\modules\birthday\assets\Assets::register($this);
?>

<div class="panel panel-default panel-birthday" id="panel-birthday">
Expand Down
Loading