Back to ModuleAdapter class

Method getElement

public string|null
getElement
(mixed $element = null)
Get the filtered extension element from the manifest
Parameters
  • string $element Optional element name to be converted
Returns
  • string|null The filtered element
Since
  • 3.4
Class: ModuleAdapter
Project: Joomla

Method getElement - Source code

/**
 * Get the filtered extension element from the manifest
 *
 * @param   string  $element  Optional element name to be converted
 *
 * @return  string|null  The filtered element
 *
 * @since   3.4
 */
public function getElement($element = null)
{
    if ($element) {
        return $element;
    }
    // Joomla 4 Module.
    if ((string) $this->getManifest()->element) {
        return (string) $this->getManifest()->element;
    }
    if (!\count($this->getManifest()->files->children())) {
        return $element;
    }
    foreach ($this->getManifest()->files->children() as $file) {
        if ((string) $file->attributes()->module) {
            // Joomla 3 (legacy) Module.
            return strtolower((string) $file->attributes()->module);
        }
    }
    return $element;
}