skala
parent
9875562ffa
commit
8be4e3e169
@ -0,0 +1,9 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
|
||||
{% block content %} |
||||
<h2>{{ 'Upgrade' }}</h2> |
||||
<h3>{{ 'ClickToUpgradeToVersion' }} {{ version }}</h3> |
||||
<form action="{{ url('upgrade.controller:upgradeAction', { 'version': version }) }}" method="post" {{ form_enctype(form) }}> |
||||
{{ form_widget(form) }} |
||||
</form> |
||||
{% endblock %} |
@ -0,0 +1,6 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
|
||||
{% block content %} |
||||
|
||||
{{ output }} |
||||
{% endblock %} |
@ -0,0 +1,36 @@ |
||||
<?php |
||||
|
||||
namespace ChamiloLMS\Component\Console\Output; |
||||
|
||||
use Symfony\Component\Console\Output\Output; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
|
||||
/** |
||||
* Class BufferedOutput |
||||
* @package ChamiloLMS\Component\Console\Output |
||||
*/ |
||||
class BufferedOutput extends Output |
||||
{ |
||||
public $messages = array(); |
||||
public $lastMessage = null; |
||||
public $buffer = null; |
||||
|
||||
/** |
||||
* @param string $message |
||||
* @param bool $newline |
||||
*/ |
||||
public function doWrite($message, $newline) |
||||
{ |
||||
$this->buffer .= $message. '<br />'; |
||||
$this->messages[] = $message; |
||||
$this->lastMessage = $message; |
||||
} |
||||
|
||||
/** |
||||
* @return null |
||||
*/ |
||||
public function getBuffer() |
||||
{ |
||||
return $this->buffer; |
||||
} |
||||
} |
@ -0,0 +1,167 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace ChamiloLMS\Controller\Admin\Administrator; |
||||
|
||||
use ChamiloLMS\Controller\CommonController; |
||||
use Silex\Application; |
||||
use Symfony\Component\Form\Extension\Core\Type\FormType; |
||||
use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; |
||||
use ChamiloLMS\Component\Console\Output\BufferedOutput; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Entity; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
||||
//use Guzzle\Http\Client; |
||||
|
||||
/** |
||||
* Class RoleController |
||||
* @todo @route and @method function don't work yet |
||||
* @package ChamiloLMS\Controller |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
class UpgradeController extends CommonController |
||||
{ |
||||
/** |
||||
* @Route("/") |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function indexAction() |
||||
{ |
||||
//$version = api_http_request('version.chamilo.org', 80, '/version.php'); |
||||
$version = '1.11.0'; |
||||
|
||||
$request = $this->getRequest(); |
||||
$builder = $this->createFormBuilder(); |
||||
$builder |
||||
->add('submit', 'submit'); |
||||
$form = $builder->getForm(); |
||||
|
||||
if ($request->getMethod() == 'POST') { |
||||
if ($form->isValid()) { |
||||
|
||||
$this->get('session')->getFlashBag()->add('success', "Added"); |
||||
$url = $this->generateUrl('upgrade.controller:upgradeAction'); |
||||
return $this->redirect($url); |
||||
} |
||||
} |
||||
|
||||
$template = $this->get('template'); |
||||
$template->assign('form', $form->createView()); |
||||
$template->assign('version', $version); |
||||
$response = $template->render_template($this->getTemplatePath().'index.tpl'); |
||||
|
||||
return new Response($response, 200, array()); |
||||
} |
||||
|
||||
/** |
||||
* @Route("{version}/update") |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function upgradeAction($version) |
||||
{ |
||||
/** @var \Knp\Console\Application $console */ |
||||
$console = $this->get('console'); |
||||
|
||||
$console->addCommands( |
||||
array( |
||||
// DBAL Commands. |
||||
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), |
||||
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), |
||||
|
||||
// Migrations Commands. |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), |
||||
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(), |
||||
|
||||
new \Chash\Command\Chash\SetupCommand(), |
||||
|
||||
new \Chash\Command\Database\RunSQLCommand(), |
||||
new \Chash\Command\Database\DumpCommand(), |
||||
new \Chash\Command\Database\RestoreCommand(), |
||||
new \Chash\Command\Database\SQLCountCommand(), |
||||
new \Chash\Command\Database\FullBackupCommand(), |
||||
new \Chash\Command\Database\DropDatabaseCommand(), |
||||
new \Chash\Command\Database\ShowConnInfoCommand(), |
||||
|
||||
new \Chash\Command\Files\CleanDataFilesCommand(), |
||||
new \Chash\Command\Files\CleanTempFolderCommand(), |
||||
new \Chash\Command\Files\CleanConfigFilesCommand(), |
||||
new \Chash\Command\Files\MailConfCommand(), |
||||
new \Chash\Command\Files\SetPermissionsAfterInstallCommand(), |
||||
new \Chash\Command\Files\GenerateTempFileStructureCommand(), |
||||
|
||||
new \Chash\Command\Installation\InstallCommand(), |
||||
new \Chash\Command\Installation\WipeCommand(), |
||||
new \Chash\Command\Installation\StatusCommand(), |
||||
new \Chash\Command\Installation\UpgradeCommand() |
||||
|
||||
) |
||||
); |
||||
|
||||
$helpers = array( |
||||
'configuration' => new \Chash\Helpers\ConfigurationHelper() |
||||
); |
||||
|
||||
$helperSet = $console->getHelperSet(); |
||||
foreach ($helpers as $name => $helper) { |
||||
$helperSet->set($helper, $name); |
||||
} |
||||
|
||||
$command = $console->get('chamilo:upgrade'); |
||||
|
||||
$version = '1.11.0'; |
||||
|
||||
$def = $command->getDefinition(); |
||||
|
||||
$input = new \Symfony\Component\Console\Input\ArrayInput( |
||||
array( |
||||
'name', |
||||
'--path' => $this->get('sys_root'), |
||||
'version' => $version, |
||||
'--migration-yml-path' => api_remove_trailing_slash($this->get('sys_temp_path')), |
||||
'--migration-class-path' => $this->get('sys_root').'vendor/chamilo/chash/src/Chash/Migrations', |
||||
'--download-package' => 'false', |
||||
'--silent' => 'true' |
||||
), |
||||
$def |
||||
); |
||||
|
||||
$output = new BufferedOutput(); |
||||
$result = $command->run($input, $output); |
||||
if ($result) { |
||||
|
||||
} |
||||
$output = $output->getBuffer(); |
||||
|
||||
$template = $this->get('template'); |
||||
$template->assign('output', $output); |
||||
$response = $template->render_template($this->getTemplatePath().'upgrade.tpl'); |
||||
|
||||
return new Response($response, 200, array()); |
||||
} |
||||
|
||||
protected function getControllerAlias() |
||||
{ |
||||
return 'upgrade.controller'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getTemplatePath() |
||||
{ |
||||
return 'admin/administrator/upgrade/'; |
||||
} |
||||
|
||||
/** |
||||
* @return \Entity\Repository\BranchSyncRepository |
||||
*/ |
||||
protected function getRepository() |
||||
{ |
||||
|
||||
} |
||||
} |
@ -1,4 +0,0 @@ |
||||
name: 'Chamilo Migrations' |
||||
migrations_namespace: Chash\Migrations |
||||
table_name: chamilo_migration_versions |
||||
migrations_directory: /var/www/chash/src/Chash/Migrations/ |
@ -0,0 +1 @@ |
||||
UPDATE settings_current SET selected_value = '1.11.post' WHERE variable = 'chamilo_database_version'; |
@ -0,0 +1 @@ |
||||
UPDATE settings_current SET selected_value = '1.11.pre' WHERE variable = 'chamilo_database_version'; |
@ -0,0 +1 @@ |
||||
<?php |
Loading…
Reference in new issue