for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Copyright (c) Flipbox Digital Limited
* @license https://flipboxfactory.com/software/patron/license
* @link https://www.flipboxfactory.com/software/patron/
*/
namespace flipbox\organizations\events\handlers;
use craft\events\RegisterElementSourcesEvent;
use flipbox\organizations\Organizations;
use flipbox\organizations\records\UserType;
* @author Flipbox Factory <[email protected]>
* @since 1.0.0
class RegisterUserElementSources
{
* @param RegisterElementSourcesEvent $event
public static function handle(RegisterElementSourcesEvent $event)
if ($event->context === 'organizations') {
$event->sources[] = [
'heading' => "Organization Types"
];
$types = UserType::findAll([]);
foreach ($types as $type) {
'key' => 'type:' . $type->id,
'label' => \Craft::t('organizations', $type->name),
'criteria' => ['organization' => ['userType' => $type->id]],
'hasThumbs' => true
}
'heading' => "Organization States"
$states = Organizations::getInstance()->getSettings()->getUserStates();
foreach ($states as $state => $label) {
'key' => 'state:' . $state,
'label' => $label,
'criteria' => ['organization' => ['userState' => $state]],