<?php

error_reporting(E_ALL);

define(
    'BASE_PATH',
    dirname(__DIR__)
);

require_once
BASE_PATH .
'/app/core/Database.php';

require_once
BASE_PATH .
'/app/controllers/AdminConferenceHomeController.php';

echo
'[' .
date('Y-m-d H:i:s') .
"] Workflow automation started\n";

try {

    $controller =
        new \App\Controllers\AdminConferenceHomeController();

    $reflection =
        new ReflectionClass(
            $controller
        );

    $ownership =
        $reflection
        ->getMethod(
            'verifyWorkflowOwnership'
        );

    $ownership
    ->setAccessible(true);

    $ownership
    ->invoke(
        $controller
    );

    $escalation =
        $reflection
        ->getMethod(
            'runHomepageEscalationEngine'
        );

    $escalation
    ->setAccessible(true);

    $escalation
    ->invoke(
        $controller
    );

    echo
    '[' .
    date('Y-m-d H:i:s') .
    "] Workflow automation completed\n";

}
catch(Throwable $e)
{
    echo
    '[' .
    date('Y-m-d H:i:s') .
    "] ERROR: "
    .
    $e->getMessage()
    .
    "\n";
}
