phpvms/app/Services/AwardService.php

37 lines
939 B
PHP
Raw Normal View History

2018-03-17 12:59:53 +08:00
<?php
namespace App\Services;
use App\Support\ClassLoader;
2018-03-17 12:59:53 +08:00
use Module;
2018-03-18 01:17:38 +08:00
class AwardService
2018-03-17 12:59:53 +08:00
{
/**
* Find any of the award classes
2018-03-18 01:17:38 +08:00
* @return \App\Interfaces\AwardInterface[]
2018-03-17 12:59:53 +08:00
*/
public function findAllAwardClasses()
{
$awards = [];
2018-03-18 01:17:38 +08:00
$formatted_awards = [];
# Find the awards in the app/Awards directory
$classes = ClassLoader::getClassesInPath(app_path('/Awards'));
$awards = array_merge($awards, $classes);
2018-03-18 01:17:38 +08:00
# Look throughout all the other modules, in the module/{MODULE}/Awards directory
2018-03-17 12:59:53 +08:00
foreach (Module::all() as $module) {
$path = $module->getExtraPath('Awards');
$classes = ClassLoader::getClassesInPath($path);
$awards = array_merge($awards, $classes);
2018-03-17 12:59:53 +08:00
}
2018-03-18 01:17:38 +08:00
foreach ($awards as $award) {
$formatted_awards[\get_class($award)] = $award;
}
return $formatted_awards;
2018-03-17 12:59:53 +08:00
}
}