Back to RulesRule class

Method getFieldActions

protected array
getFieldActions
(\SimpleXMLElement $element)
Method to get the list of possible permission action names for the form field.
Parameters
  • \SimpleXMLElement $element The \SimpleXMLElement object representing the `<field>` tag for the form field object.
Returns
  • array A list of permission action names from the form field element definition.
Since
  • 1.7.0
Class: RulesRule
Project: Joomla

Method getFieldActions - Source code

/**
 * Method to get the list of possible permission action names for the form field.
 *
 * @param   \SimpleXMLElement  $element  The \SimpleXMLElement object representing the `<field>` tag for the form field object.
 *
 * @return  array  A list of permission action names from the form field element definition.
 *
 * @since   1.7.0
 */
protected function getFieldActions(\SimpleXMLElement $element)
{
    $actions = array();
    // Initialise some field attributes.
    $section = $element['section'] ? (string) $element['section'] : '';
    $component = $element['component'] ? (string) $element['component'] : '';
    // Get the asset actions for the element.
    $elActions = Access::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml', "/access/section[@name='" . $section . "']/");
    if ($elActions) {
        // Iterate over the asset actions and add to the actions.
        foreach ($elActions as $item) {
            $actions[] = $item->name;
        }
    }
    // Iterate over the children and add to the actions.
    foreach ($element->children() as $el) {
        if ($el->getName() === 'action') {
            $actions[] = (string) $el['name'];
        }
    }
    return $actions;
}