Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Change com_fields to services #21420

Merged
merged 16 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\UCM\UCMType;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

/**
* Item Model for an Article.
Expand Down Expand Up @@ -88,9 +89,6 @@ protected function batchCopy($value, $pks, $contexts)

PluginHelper::importPlugin('system');

// Register FieldsHelper
\JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

// Parent exists so we let's proceed
while (!empty($pks))
{
Expand All @@ -117,7 +115,7 @@ protected function batchCopy($value, $pks, $contexts)
}
}

$fields = \FieldsHelper::getFields('com_content.article', $this->table, true);
$fields = FieldsHelper::getFields('com_content.article', $this->table, true);
$fieldsData = array();

if (!empty($fields))
Expand Down Expand Up @@ -272,9 +270,6 @@ protected function batchMove($value, $pks, $contexts)

PluginHelper::importPlugin('system');

// Register FieldsHelper
\JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

// Parent exists so we proceed
foreach ($pks as $pk)
{
Expand Down Expand Up @@ -303,7 +298,7 @@ protected function batchMove($value, $pks, $contexts)
}
}

$fields = \FieldsHelper::getFields('com_content.article', $this->table, true);
$fields = FieldsHelper::getFields('com_content.article', $this->table, true);

$fieldsData = array();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\Registry\Registry;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
Expand Down Expand Up @@ -57,7 +58,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
parent::__construct($config, $factory, $app, $input);

$this->internalContext = Factory::getApplication()->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD');
$parts = \FieldsHelper::extract($this->internalContext);
$parts = FieldsHelper::extract($this->internalContext);
$this->component = $parts ? $parts[0] : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\Registry\Registry;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
Expand Down Expand Up @@ -59,7 +60,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
{
parent::__construct($config, $factory, $app, $input);

$parts = \FieldsHelper::extract($this->input->getCmd('context'));
$parts = FieldsHelper::extract($this->input->getCmd('context'));

if ($parts)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,20 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Fields\Administrator\Dispatcher;

defined('_JEXEC') or die;

use Joomla\CMS\Dispatcher\Dispatcher;
use Joomla\CMS\Factory;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

/**
* Dispatcher class for com_content
*
* @since 4.0.0
*/
class FieldsDispatcher extends Dispatcher
class Dispatcher extends \Joomla\CMS\Dispatcher\Dispatcher
{
/**
* The extension namespace
*
* @var string
*
* @since 4.0.0
*/
protected $namespace = 'Joomla\\Component\\Fields';

/**
* Method to check component access permission
*
Expand All @@ -37,21 +30,18 @@ class FieldsDispatcher extends Dispatcher
*/
protected function checkAccess()
{
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

$app = Factory::getApplication();
$context = $app->getUserStateFromRequest(
$context = $this->app->getUserStateFromRequest(
'com_fields.groups.context',
'context',
$app->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD'),
$this->app->getUserStateFromRequest('com_fields.fields.context', 'context', 'com_content.article', 'CMD'),
'CMD'
);

$parts = FieldsHelper::extract($context);

if (!$parts || !$this->app->getIdentity()->authorise('core.manage', $parts[0]))
{
throw new \Joomla\CMS\Access\Exception\Notallowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
throw new Notallowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
}
}
}
3 changes: 2 additions & 1 deletion administrator/components/com_fields/Field/TypeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

FormHelper::loadFieldClass('list');

Expand Down Expand Up @@ -60,7 +61,7 @@ protected function getOptions()
{
$options = parent::getOptions();

$fieldTypes = \FieldsHelper::getFieldTypes();
$fieldTypes = FieldsHelper::getFieldTypes();

foreach ($fieldTypes as $fieldType)
{
Expand Down
Loading