2018-03-17 12:59:53 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Service;
|
2018-03-17 13:55:39 +08:00
|
|
|
use App\Support\ClassLoader;
|
2018-03-17 12:59:53 +08:00
|
|
|
use Module;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class AwardService
|
|
|
|
* @package App\Services
|
|
|
|
*/
|
|
|
|
class AwardService extends Service
|
2018-03-17 12:59:53 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Find any of the award classes
|
2018-03-20 09:50:40 +08:00
|
|
|
* @return \App\Interfaces\Award[]
|
2018-03-17 12:59:53 +08:00
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function findAllAwardClasses(): array
|
2018-03-17 12:59:53 +08:00
|
|
|
{
|
|
|
|
$awards = [];
|
2018-03-18 01:17:38 +08:00
|
|
|
$formatted_awards = [];
|
2018-03-17 13:55:39 +08:00
|
|
|
|
|
|
|
# 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');
|
2018-03-17 13:55:39 +08:00
|
|
|
$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
|
|
|
}
|
|
|
|
}
|