Back to CategoryFactory class

Method createCategory

public \Joomla\CMS\Categories\CategoryInterface
createCategory
(array $options = [], string $section = '')
Creates a category.
Parameters
  • array $options The options
  • string $section The section
Returns
  • \Joomla\CMS\Categories\CategoryInterface
Since
  • 3.10.0
-
  • \Joomla\CMS\Categories\SectionNotFoundException

Method createCategory - Source code

/**
 * Creates a category.
 *
 * @param   array   $options  The options
 * @param   string  $section  The section
 *
 * @return  CategoryInterface
 *
 * @since   3.10.0
 *
 * @throws  SectionNotFoundException
 */
public function createCategory(array $options = [], string $section = '') : CategoryInterface
{
    $className = trim($this->namespace, '\\') . '\\Site\\Service\\' . ucfirst($section) . 'Category';
    if (!class_exists($className)) {
        throw new SectionNotFoundException();
    }
    return new $className($options);
}