Skip to content

Commit

Permalink
[4.0] Change com_fields to services (#21420)
Browse files Browse the repository at this point in the history
* Change com_fields to services

* cs

* Fix conflicts

* Use the namespaced class
  • Loading branch information
laoneo authored and wilsonge committed Aug 22, 2018
1 parent aefb138 commit d6abb18
Show file tree
Hide file tree
Showing 27 changed files with 879 additions and 835 deletions.
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

0 comments on commit d6abb18

Please sign in to comment.