40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
|
<?php
|
||
|
include_once dirname(dirname(__DIR__)) . '/bootstrap/autoload.php';
|
||
|
|
||
|
$controllers = glob(config('locations.controllers') . '/*.php');
|
||
|
$cnt = 0;
|
||
|
$errors = 0;
|
||
|
foreach ($controllers as $controller) {
|
||
|
$info = pathinfo($controller);
|
||
|
$name = $info['filename'];
|
||
|
$controller = '' . Stringy\Stringy::create($name)->underscored();
|
||
|
$class = '\\App\\Controller\\' . $name;
|
||
|
$ref = new ReflectionClass($class);
|
||
|
$methods = $ref->getMethods(ReflectionMethod::IS_STATIC);
|
||
|
|
||
|
try {
|
||
|
foreach ($methods as $method) {
|
||
|
$data = [
|
||
|
'controller' => $controller,
|
||
|
'action' => $method->name
|
||
|
];
|
||
|
$location = Model::factory(\Incoviba\common\Location::class)->where('controller', $controller)->where('action', $method->name)->findOne();
|
||
|
if ($location !== false) {
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
$location = Model::factory(\Incoviba\common\Location::class)->create($data);
|
||
|
$location->save();
|
||
|
$cnt ++;
|
||
|
}
|
||
|
} catch (Exception $e) {
|
||
|
d($e);
|
||
|
$errors ++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ($errors == 0) {
|
||
|
header('Location: next_step.php?step=log_locations');
|
||
|
}
|
||
|
?>
|