2014-05-03 23:48:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
2015-02-22 21:29:43 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2015 Open Source Matters, Inc. All rights reserved.
|
2014-05-03 23:48:08 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PatchTester\Controller;
|
|
|
|
|
|
|
|
use PatchTester\Model\PullModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller class to revert patches
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2016-02-20 16:34:23 +00:00
|
|
|
class RevertController extends AbstractController
|
2014-05-03 23:48:08 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Execute the controller.
|
|
|
|
*
|
|
|
|
* @return void Redirects the application
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$model = new PullModel;
|
2014-10-17 16:47:00 +00:00
|
|
|
|
|
|
|
// Initialize the state for the model
|
|
|
|
$model->setState($this->initializeState($model));
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
$model->revert($this->getInput()->getUint('pull_id'));
|
|
|
|
|
2015-05-09 15:57:06 +00:00
|
|
|
$msg = \JText::_('COM_PATCHTESTER_REVERT_OK');
|
2014-05-03 23:48:08 +00:00
|
|
|
$type = 'message';
|
|
|
|
}
|
|
|
|
catch (\Exception $e)
|
|
|
|
{
|
|
|
|
$msg = $e->getMessage();
|
|
|
|
$type = 'error';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->getApplication()->enqueueMessage($msg, $type);
|
|
|
|
$this->getApplication()->redirect(\JRoute::_('index.php?option=com_patchtester', false));
|
|
|
|
}
|
|
|
|
}
|