This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
espocrm-base/application/Espo/Controllers/Admin.php
T
2013-12-24 12:40:05 +02:00

38 lines
851 B
PHP

<?php
namespace Espo\Controllers;
use \Espo\Core\Exceptions\Error,
\Espo\Core\Exceptions\Forbidden;
class Admin extends \Espo\Core\Controllers\Base
{
public function __construct(\Espo\Core\Container $container, \Espo\Core\ServiceFactory $serviceFactory)
{
parent::__construct($container, $serviceFactory);
if (!$this->getUser()->isAdmin()) {
throw new Forbidden("You do not have access to this area");
}
}
public function actionRebuild($params, $data)
{
try{
$result = $this->getContainer()->get('schema')->rebuild();
} catch (\Exception $e) {
$result = false;
$GLOBALS['log']->add('EXCEPTION', 'Fault to rebuild database schema'.'. Details: '.$e->getMessage());
}
if ($result === false) {
throw new Error("Error while rebuilding database");
}
return json_encode($result);
}
}