33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-11-10 15:21:01 +00:00
patchtester/administrator/components/com_patchtester/PatchTester/Controller/ApplyController.php

60 lines
1.2 KiB
PHP
Raw Normal View History

<?php
/**
* Patch testing component for the Joomla! CMS
*
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later
*/
namespace PatchTester\Controller;
use Joomla\CMS\Factory;
2019-08-28 01:20:49 +00:00
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use PatchTester\Model\PullModel;
/**
* Controller class to apply patches
*
* @since 2.0
*/
class ApplyController extends AbstractController
{
/**
* Execute the controller.
*
* @return void Redirects the application
*
* @since 2.0
*/
public function execute()
{
try
{
$model = new PullModel(null, Factory::getDbo());
// Initialize the state for the model
$model->setState($this->initializeState($model));
if ($model->apply($this->getInput()->getUint('pull_id')))
{
2019-08-28 01:20:49 +00:00
$msg = Text::_('COM_PATCHTESTER_APPLY_OK');
}
else
{
2019-08-28 01:20:49 +00:00
$msg = Text::_('COM_PATCHTESTER_NO_FILES_TO_PATCH');
}
$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));
}
}