Пример #1
0
 public function test()
 {
     $pathToMe = '/leroy' . LeEnvironment::PATH_TO_LECORE_DEV_MODE;
     $pathToDevelopmentRoot = '/leroy';
     $leEnv = new LeEnvironment();
     $this->assertTrue(is_string($leEnv->getProjectRoot()));
     $this->assertEquals(LeEnvironment::MODE_DEV, $leEnv->getMode());
     $this->assertFalse($leEnv->isVendorMode());
     $this->assertTrue($leEnv->isDevMode());
     $this->assertEquals($pathToMe, substr($leEnv->getMe(), strlen($pathToMe) * -1));
     $this->assertTrue(file_exists($leEnv->getMe()));
     $this->assertEquals($pathToDevelopmentRoot, substr($leEnv->getProjectRootDevelopmentMode(), strlen($pathToDevelopmentRoot) * -1));
     $this->assertTrue(file_exists($leEnv->getProjectRootDevelopmentMode()));
     $projectRoot = '/a/b/c/d/e/f/g';
     $pathToVendorRoot = $projectRoot . LeEnvironment::PATH_TO_LECORE_VENDOR_MODE;
     $this->assertEquals($projectRoot, $leEnv->getProjectRootVendorMode($pathToVendorRoot));
 }
Пример #2
0
 *
 * @todo the name of the log should be grab from config
 */
try {
    $request = new LeQuest(new LeServerModel(new LeValidator()));
    $request->initialize($_POST, $_GET, $_SERVER);
    unset($_REQUEST);
    unset($_GET);
    unset($_POST);
    $controller = $request->get('c');
    $method = $request->get('m');
    $request->remove('c');
    $request->remove('m');
    $execute = new LeExecuteController($request);
    echo $execute->execute($controller, $method);
} catch (Exception $e) {
    $env = new LeEnvironment();
    if ($env->isDevMode()) {
        print_r($e);
    } else {
        $log = new LeLog(__FILE__);
        $context = [];
        if (!is_null($request) && $request instanceof LeQuestInterface) {
            $context = $request->get();
            if (!is_array($context)) {
                $context = [$context];
            }
        }
        $log->critical($e->getMessage(), $context);
    }
}