2014-05-03 23:48:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2014 Open Source Matters, Inc. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PatchTester\Controller;
|
|
|
|
|
|
|
|
use PatchTester\Model\PullsModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller class to fetch remote data
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2014-10-17 11:32:48 +00:00
|
|
|
class FetchController extends DisplayController
|
2014-05-03 23:48:08 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Execute the controller.
|
|
|
|
*
|
|
|
|
* @return void Redirects the application
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// TODO - Decouple the model and context?
|
2015-02-16 21:35:49 +00:00
|
|
|
$model = new PullsModel('com_patchtester.fetch', null, \JFactory::getDbo());
|
2014-10-17 11:32:48 +00:00
|
|
|
|
|
|
|
// Initialize the state for the model
|
|
|
|
$model->setState($this->initializeState($model));
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
$model->requestFromGithub();
|
|
|
|
|
|
|
|
$msg = \JText::_('COM_PATCHTESTER_FETCH_SUCCESSFUL');
|
|
|
|
$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));
|
|
|
|
}
|
|
|
|
}
|