2016-02-20 16:34:23 +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.
|
2016-02-20 16:34:23 +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\Application\CMSApplication;
|
|
|
|
use Joomla\CMS\Component\ComponentHelper;
|
2019-08-28 00:50:21 +00:00
|
|
|
use Joomla\Input\Input;
|
2016-02-20 16:34:23 +00:00
|
|
|
use Joomla\Registry\Registry;
|
2019-08-28 01:07:28 +00:00
|
|
|
use PatchTester\Model\AbstractModel;
|
2016-02-20 16:34:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base controller for the patch testing component
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2019-08-28 00:50:21 +00:00
|
|
|
abstract class AbstractController
|
2016-02-20 16:34:23 +00:00
|
|
|
{
|
2019-08-28 00:50:21 +00:00
|
|
|
/**
|
|
|
|
* The active application
|
|
|
|
*
|
|
|
|
* @var CMSApplication
|
2020-04-03 20:19:05 +00:00
|
|
|
* @since 4.0.0
|
2019-08-28 00:50:21 +00:00
|
|
|
*/
|
|
|
|
protected $app;
|
|
|
|
|
2016-02-20 16:34:23 +00:00
|
|
|
/**
|
|
|
|
* The object context
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $context;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The default view to display
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
protected $defaultView = 'pulls';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiate the controller
|
|
|
|
*
|
2019-08-28 00:50:21 +00:00
|
|
|
* @param CMSApplication $app The application object.
|
2016-02-20 16:34:23 +00:00
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2019-08-28 00:50:21 +00:00
|
|
|
public function __construct(CMSApplication $app)
|
2016-02-20 16:34:23 +00:00
|
|
|
{
|
2019-08-28 00:50:21 +00:00
|
|
|
$this->app = $app;
|
2016-02-20 16:34:23 +00:00
|
|
|
|
|
|
|
// Set the context for the controller
|
|
|
|
$this->context = 'com_patchtester.' . $this->getInput()->getCmd('view', $this->defaultView);
|
|
|
|
}
|
|
|
|
|
2019-08-28 00:50:21 +00:00
|
|
|
/**
|
|
|
|
* Get the application object.
|
|
|
|
*
|
|
|
|
* @return CMSApplication
|
|
|
|
*
|
2020-04-03 20:19:05 +00:00
|
|
|
* @since 4.0.0
|
2019-08-28 00:50:21 +00:00
|
|
|
*/
|
|
|
|
public function getApplication()
|
|
|
|
{
|
|
|
|
return $this->app;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the input object.
|
|
|
|
*
|
|
|
|
* @return Input
|
|
|
|
*
|
2020-04-03 20:19:05 +00:00
|
|
|
* @since 4.0.0
|
2019-08-28 00:50:21 +00:00
|
|
|
*/
|
|
|
|
public function getInput()
|
|
|
|
{
|
|
|
|
return $this->app->input;
|
|
|
|
}
|
|
|
|
|
2016-02-20 16:34:23 +00:00
|
|
|
/**
|
|
|
|
* Sets the state for the model object
|
|
|
|
*
|
2019-08-28 01:07:28 +00:00
|
|
|
* @param AbstractModel $model Model object
|
2016-02-20 16:34:23 +00:00
|
|
|
*
|
|
|
|
* @return Registry
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
2019-08-28 01:07:28 +00:00
|
|
|
protected function initializeState(AbstractModel $model)
|
2016-02-20 16:34:23 +00:00
|
|
|
{
|
|
|
|
$state = new Registry;
|
|
|
|
|
|
|
|
// Load the parameters.
|
2017-08-17 23:22:01 +00:00
|
|
|
$params = ComponentHelper::getParams('com_patchtester');
|
2016-02-20 16:34:23 +00:00
|
|
|
|
|
|
|
$state->set('github_user', $params->get('org', 'joomla'));
|
|
|
|
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
|
|
|
|
|
|
|
|
return $state;
|
|
|
|
}
|
|
|
|
}
|