Skip to content

Commit

Permalink
Call namespace helper class in Categories model
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation committed Jun 7, 2017
1 parent f4083bc commit a6890cc
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions administrator/components/com_categories/Model/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Mvc\Factory\MvcFactoryInterface;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Model\ListModel;
Expand Down Expand Up @@ -380,19 +381,27 @@ public function countItems(&$items, $extension)

// Try to find the component helper.
$eName = str_replace('com_', '', $component);
$file = \JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (file_exists($file))
{
$prefix = ucfirst($eName);
$cName = $prefix . 'Helper';
$namespace = ComponentHelper::getComponent($component)->namespace;

\JLoader::register($cName, $file);
if ($namespace)
{
$cName = $namespace.'\\Administrator\\Helper\\'.ucfirst($eName.'Helper');
}
else
{
$file = \JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (class_exists($cName) && is_callable(array($cName, 'countItems')))
if (file_exists($file))
{
$cName::countItems($items, $section);
$cName = ucfirst($eName) . 'Helper';
\JLoader::register($cName, $file);
}
}

if (!empty($cName) && class_exists($cName) && is_callable(array($cName, 'countItems')))
{
$cName::countItems($items, $section);
}
}
}

0 comments on commit a6890cc

Please sign in to comment.