33
0
mirror of https://github.com/joomla-extensions/patchtester.git synced 2024-12-24 20:00:26 +00:00
patchtester/administrator/components/com_patchtester/PatchTester/Controller/AbstractController.php

109 lines
2.0 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\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
2019-08-28 00:50:21 +00:00
use Joomla\Input\Input;
use Joomla\Registry\Registry;
2019-08-28 01:07:28 +00:00
use PatchTester\Model\AbstractModel;
/**
* Base controller for the patch testing component
*
* @since 2.0
*/
2019-08-28 00:50:21 +00:00
abstract class AbstractController
{
2019-08-28 00:50:21 +00:00
/**
* The active application
*
* @var CMSApplication
* @since __DEPLOY_VERSION__
*/
protected $app;
/**
* 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.
*
* @since 2.0
*/
2019-08-28 00:50:21 +00:00
public function __construct(CMSApplication $app)
{
2019-08-28 00:50:21 +00:00
$this->app = $app;
// 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
*
* @since __DEPLOY_VERSION__
*/
public function getApplication()
{
return $this->app;
}
/**
* Get the input object.
*
* @return Input
*
* @since __DEPLOY_VERSION__
*/
public function getInput()
{
return $this->app->input;
}
/**
* Sets the state for the model object
*
2019-08-28 01:07:28 +00:00
* @param AbstractModel $model Model object
*
* @return Registry
*
* @since 2.0
*/
2019-08-28 01:07:28 +00:00
protected function initializeState(AbstractModel $model)
{
$state = new Registry;
// Load the parameters.
$params = ComponentHelper::getParams('com_patchtester');
$state->set('github_user', $params->get('org', 'joomla'));
$state->set('github_repo', $params->get('repo', 'joomla-cms'));
return $state;
}
}