Back to WorkflowServiceTrait class

Method isFunctionalityUsed

public bool
isFunctionalityUsed
(mixed $functionality, mixed $extension)
Check if the functionality is used by a plugin
Parameters
  • string $functionality The functionality
  • string $extension The extension
Returns
  • bool
Since
  • 4.0.0
-
  • \Exception

Method isFunctionalityUsed - Source code

/**
 * Check if the functionality is used by a plugin
 *
 * @param   string  $functionality  The functionality
 * @param   string  $extension      The extension
 *
 * @return boolean
 * @throws \Exception
 *
 * @since   4.0.0
 */
public function isFunctionalityUsed($functionality, $extension) : bool
{
    static $used = [];
    $cacheKey = $extension . '.' . $functionality;
    if (isset($used[$cacheKey])) {
        return $used[$cacheKey];
    }
    // The container to get the services from
    $app = Factory::getApplication();
    if (!$app instanceof DispatcherAwareInterface) {
        return false;
    }
    $eventResult = $app->getDispatcher()->dispatch('onWorkflowFunctionalityUsed', AbstractEvent::create('onWorkflowFunctionalityUsed', ['eventClass' => 'Joomla\\CMS\\Event\\Workflow\\WorkflowFunctionalityUsedEvent', 'subject' => $this, 'extension' => $extension, 'functionality' => $functionality]));
    $used[$cacheKey] = $eventResult->getArgument('used', false);
    return $used[$cacheKey];
}