2014-05-03 23:48:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
2018-09-01 14:32:23 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 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;
|
|
|
|
|
2017-08-17 23:22:01 +00:00
|
|
|
use Joomla\CMS\Factory;
|
2019-08-28 01:20:49 +00:00
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\Router\Route;
|
2014-05-03 23:48:08 +00:00
|
|
|
use PatchTester\Model\PullModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller class to apply patches
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2016-02-20 16:34:23 +00:00
|
|
|
class ApplyController 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
|
|
|
|
{
|
2017-08-17 23:22:01 +00:00
|
|
|
$model = new PullModel(null, Factory::getDbo());
|
2014-10-17 16:47:00 +00:00
|
|
|
|
|
|
|
// Initialize the state for the model
|
|
|
|
$model->setState($this->initializeState($model));
|
|
|
|
|
2015-02-23 13:50:13 +00:00
|
|
|
if ($model->apply($this->getInput()->getUint('pull_id')))
|
|
|
|
{
|
2019-08-28 01:20:49 +00:00
|
|
|
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
|
2015-02-23 13:50:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-28 01:20:49 +00:00
|
|
|
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
|
2015-02-23 13:50:13 +00:00
|
|
|
}
|
2014-05-03 23:48:08 +00:00
|
|
|
|
|
|
|
$type = 'message';
|
|
|
|
}
|
|
|
|
catch (\Exception $e)
|
|
|
|
{
|
|
|
|
$msg = $e->getMessage();
|
|
|
|
$type = 'error';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->getApplication()->enqueueMessage($msg, $type);
|
2019-08-28 01:20:49 +00:00
|
|
|
$this->getApplication()->redirect(Route::_('index.php?option=com_patchtester', false));
|
2014-05-03 23:48:08 +00:00
|
|
|
}
|
|
|
|
}
|