Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space TDDM and version 1

...

If you want to limit access to the workflow to certain users, you can implement the can_access() method.

New workflows are not automatically enabled. To enable a workflow, you need to trigger it in install.php or upgrade.php:

Code Block
languagephp
// Example of enabling a workflow programmatically:
$workflow = contentmarketplace_goone\workflow\core_course\coursecreate\contentmarketplace::instance();
$workflow->enable();

Implementing a workflow manager

...

You can also choose to implement can_access() if you want to require per-user control over the type of workflow.

Info

Note that both workflow managers and workflows support the can_access() method, but they serve different purposes.

The workflow manager can_access() method should be used to restrict access to the entire workflow, i.e. prevent the user from taking the action that the workflow is designed to perform. For example, if a user is not allowed to create courses, the coursecreate workflow manager should prevent it.

The workflow can_access() method should be used to restrict access to a single workflow of that manager. For example, if there is a workflow that supports course creation via a plugin that has been disabled, the overall workflow manager may allow access but the specific workflow might not.

Workflow parameters

In some cases there will be state-specific data that you want to pass through from where the workflow is triggered into the workflow or beyond. For example courses can be created in the context of a specific category, so it's reasonable to pass the category to the workflow, which can then decide whether to make use of that information (by for example, creating the course in that category). Data can be passed and used via the set_params() and get_params() methods. Params are set against the workflow manager but available in both the manager and the workflow itself.

...