Back to ContentHelper class

Method getActions

public static \Joomla\CMS\Object\CMSObject
getActions
(mixed $component = '', mixed $section = '', mixed $id = 0)
Gets a list of the actions that can be performed.
Parameters
  • string $component The component name.
  • string $section The access section name.
  • int $id The item ID.
Returns
  • \Joomla\CMS\Object\CMSObject
Since
  • 3.2
Class: ContentHelper
Project: Joomla

Method getActions - Source code

/**
 * Gets a list of the actions that can be performed.
 *
 * @param   string   $component  The component name.
 * @param   string   $section    The access section name.
 * @param   integer  $id         The item ID.
 *
 * @return  CMSObject
 *
 * @since   3.2
 */
public static function getActions($component = '', $section = '', $id = 0)
{
    $assetName = $component;
    if ($section && $id) {
        $assetName .= '.' . $section . '.' . (int) $id;
    }
    $result = new CMSObject();
    $user = Factory::getUser();
    $actions = Access::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml', '/access/section[@name="component"]/');
    if ($actions === false) {
        Log::add(Text::sprintf('JLIB_ERROR_COMPONENTS_ACL_CONFIGURATION_FILE_MISSING_OR_IMPROPERLY_STRUCTURED', $component), Log::ERROR, 'jerror');
        return $result;
    }
    foreach ($actions as $action) {
        $result->set($action->name, $user->authorise($action->name, $assetName));
    }
    return $result;
}