I agree that’s probably the logical next step.
Note that there are three parts to the “Assign log” action…
- The action plugin: https://github.com/farmOS/farmOS/blob/2.x/modules/core/owner/src/Plugin/Action/LogAssign.php
- The action form: https://github.com/farmOS/farmOS/blob/2.x/modules/core/owner/src/Form/LogAssignActionForm.php
- The routing configuration, which creates the
/log/assign
path and loads theLogAssignActionForm
: https://github.com/farmOS/farmOS/blob/2.x/modules/core/owner/farm_owner.routing.yml
It may be possible to generalize LogAssignActionForm.php
to AssignActionForm.php
, such that it can be used for both. This looks to be the most important line, where it specifically loads the log
entity type definition: https://github.com/farmOS/farmOS/blob/d2b512725ea2659bec10fbabf53fa60a9c3ddbe0/modules/core/owner/src/Form/LogAssignActionForm.php#L140
The routing config can be refactored to provide two paths: /log/assign
and /asset/assign
, and provide an additional argument to the LogAssignActionForm
to define the entity type (asset
or log
). That should take care of the form.
As for src/Plugin/Action/LogAssign.php
- I would probably create a new AssignBase.php
class, which that extends from. Then create another AssetAssign.php
action plugin class that also extends from it. The most important thing that needs to differ in each is this: https://github.com/farmOS/farmOS/blob/d2b512725ea2659bec10fbabf53fa60a9c3ddbe0/modules/core/owner/src/Plugin/Action/LogAssign.php#L17