Skip to content

Commit

Permalink
Merge pull request #12443 from craftcms/MarcusGaius/develop
Browse files Browse the repository at this point in the history
Marcus gaius/develop
  • Loading branch information
brandonkelly authored Jan 11, 2023
2 parents 8245621 + cfd1df3 commit a0ac0c5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- Added `craft\elements\conditions\entries\ViewableConditionRule`. ([#12266](https://github.com/craftcms/cms/pull/12266))
- Added `craft\elemens\Entry::EVENT_DEFINE_PARENT_SELECTION_CRITERIA`. ([#12475](https://github.com/craftcms/cms/discussions/12475))
- Added `craft\events\DefineInputOptionsEvent`. ([#12351](https://github.com/craftcms/cms/pull/12351))
- Added `craft\events\ListVolumesEvent`.
- Added `craft\events\UserPhotoEvent`. ([#12360](https://github.com/craftcms/cms/pull/12360))
- Added `craft\fields\BaseOptionsField::EVENT_DEFINE_OPTIONS`. ([#12351](https://github.com/craftcms/cms/pull/12351))
- Added `craft\fields\BaseRelationField::$branchLimit`.
Expand All @@ -67,6 +68,7 @@
- Added `craft\services\Users::EVENT_AFTER_SAVE_USER_PHOTO`. ([#12360](https://github.com/craftcms/cms/pull/12360))
- Added `craft\services\Users::EVENT_BEFORE_DELETE_USER_PHOTO`. ([#12360](https://github.com/craftcms/cms/pull/12360))
- Added `craft\services\Users::EVENT_BEFORE_SAVE_USER_PHOTO`. ([#12360](https://github.com/craftcms/cms/pull/12360))
- Added `craft\utilities\AssetIndexes::EVENT_LIST_VOLUMES`. ([#12383](https://github.com/craftcms/cms/pull/12383), [#12443](https://github.com/craftcms/cms/pull/12443))
- Renamed `craft\elements\conditions\assets\EditableConditionRule` to `SavableConditionRule`, while preserving the original class name with an alias. ([#12266](https://github.com/craftcms/cms/pull/12266))
- Renamed `craft\elements\conditions\entries\EditableConditionRule` to `SavableConditionRule`, while preserving the original class name with an alias. ([#12266](https://github.com/craftcms/cms/pull/12266))
- Deprecated `craft\queue\jobs\GeneratePendingTransforms`. `GenerateImageTransform` should be used instead. ([#12340](https://github.com/craftcms/cms/pull/12340))
Expand Down
25 changes: 25 additions & 0 deletions src/events/ListVolumesEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/

namespace craft\events;

use craft\models\Volume;
use yii\base\Event;

/**
* ListVolumesEvent class.
*
* @author Pixel & Tonic, Inc. <[email protected]>
* @since 4.4.0
*/
class ListVolumesEvent extends Event
{
/**
* @var Volume[] The volumes to be listed.
*/
public array $volumes = [];
}
17 changes: 15 additions & 2 deletions src/utilities/AssetIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

use Craft;
use craft\base\Utility;
use craft\events\ListVolumesEvent;
use craft\helpers\Html;
use craft\i18n\Locale;
use craft\web\assets\assetindexes\AssetIndexesAsset;
use yii\base\Event;

/**
* AssetIndexes represents a AssetIndexes dashboard widget.
Expand All @@ -21,6 +23,12 @@
*/
class AssetIndexes extends Utility
{
/**
* @event ListVolumesEvent The event that is triggered when listing the available volumes to index.
* @since 4.4.0
*/
public const EVENT_LIST_VOLUMES = 'listVolumes';

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -50,10 +58,15 @@ public static function iconPath(): ?string
*/
public static function contentHtml(): string
{
$volumes = Craft::$app->getVolumes()->getAllVolumes();
// Fire a 'listVolumes' event
$event = new ListVolumesEvent([
'volumes' => Craft::$app->getVolumes()->getAllVolumes(),
]);
Event::trigger(self::class, self::EVENT_LIST_VOLUMES, $event,);

$volumeOptions = [];

foreach ($volumes as $volume) {
foreach ($event->volumes as $volume) {
$volumeOptions[] = [
'label' => Html::encode($volume->name),
'value' => $volume->id,
Expand Down

0 comments on commit a0ac0c5

Please sign in to comment.