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] Remove registering form paths for paths that no longer exist #21279

Merged
merged 1 commit into from
Jul 31, 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
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