Skip to content

Commit

Permalink
Remove registering form paths for paths that no longer exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Jul 28, 2018
1 parent e1bcbad commit 27dfe78
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
6 changes: 0 additions & 6 deletions libraries/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@
// @deprecated 4.0
JLoader::registerAlias('JAdministrator', 'JApplicationAdministrator');
JLoader::registerAlias('JSite', 'JApplicationSite');

// Can be removed when the move of all core fields to namespace is finished
\Joomla\CMS\Form\FormHelper::addFieldPath(JPATH_LIBRARIES . '/joomla/form/fields');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/joomla/form/rule');
\Joomla\CMS\Form\FormHelper::addFieldPath(JPATH_LIBRARIES . '/cms/form/field');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/cms/form/rule');
8 changes: 0 additions & 8 deletions libraries/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,3 @@
JLoader::register('JExtension', JPATH_PLATFORM . '/cms/installer/extension.php');
JLoader::registerAlias('JAdministrator', 'JApplicationAdministrator');
JLoader::registerAlias('JSite', 'JApplicationSite');

// Can be removed when the move of all core fields to namespace is finished
\Joomla\CMS\Form\FormHelper::addFieldPath(JPATH_LIBRARIES . '/joomla/form/fields');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/joomla/form/rule');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/joomla/form/rules');
\Joomla\CMS\Form\FormHelper::addFormPath(JPATH_LIBRARIES . '/joomla/form/forms');
\Joomla\CMS\Form\FormHelper::addFieldPath(JPATH_LIBRARIES . '/cms/form/field');
\Joomla\CMS\Form\FormHelper::addRulePath(JPATH_LIBRARIES . '/cms/form/rule');
35 changes: 5 additions & 30 deletions libraries/src/Form/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Log\Log;
use Joomla\String\Inflector;
use Joomla\String\Normalise;
use Joomla\String\StringHelper;

Expand Down Expand Up @@ -316,37 +314,14 @@ public static function addRulePath($new = null)
*/
protected static function addPath($entity, $new = null)
{
// Reference to an array with paths for current entity
$paths = &self::$paths[$entity];

// Add the default entity's search path if not set.
if (empty($paths))
if (!isset(self::$paths[$entity]))
{
// While we support limited number of entities (form, field and rule) we can do simple pluralisation
$entityPlural = $entity . 's';

// Relying on "simple" plurals is deprecated, use the properly inflected plural form
$paths[] = __DIR__ . '/' . $entityPlural;

$inflectedPlural = Inflector::getInstance()->toPlural($entity);

if ($entityPlural !== $inflectedPlural)
{
Log::add(
sprintf(
'File paths for form entity type validations should be properly inflected as of 5.0.'
. ' The folder for entity type "%1$s" should be renamed from "%2$s" to "%3$s".',
$entity,
$entityPlural,
$inflectedPlural
),
Log::WARNING,
'deprecated'
);
$paths[] = __DIR__ . '/' . $inflectedPlural;
}
self::$paths[$entity] = [];
}

// Reference to an array with paths for current entity
$paths = &self::$paths[$entity];

// Force the new path(s) to an array.
settype($new, 'array');

Expand Down

0 comments on commit 27dfe78

Please sign in to comment.