Closed (fixed)
Project:
Scheduler
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 May 2022 at 14:25 UTC
Updated:
25 Jun 2022 at 13:44 UTC
Jump to comment: Most recent
Multiple properties/methods in SchedulerPluginBase and the module provided Scheduler plugins could be automatically derived.
Let's simplify the base class and specific plugins.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dieterholvoet commentedI added an abstract implementation for the
typeFieldName/getTypes/entityFormIds/entityTypeFormIdsmethods toSchedulerPluginBase. Since the information those methods provide can be automatically derived, we could consider removing these methods from the plugin class.Merging this would simplify the implementation of scheduler_eck.
Comment #4
dieterholvoet commentedTODO: Filter out plugins with unmet dependencies in
SchedulerPluginManager::findDefinitionsComment #5
jonathan1055 commentedThanks. This looks very interesting.
Comment #6
jonathan1055 commentedCouple of quesions:
findDefinitions()used for? It is not called directly in any Scheduler code. I can see that it is useful to some 3rd-party modules, but we need to explain it. It has both @inheritdoc and a text description, so is not clear. Or maybe this is a standard function? Looks fairly generic. Is this the preferred way to get rid of the code such aswhich is in all of the existing
getTypes()functions, but now does not exist.$container->get('string_translation')has been removed from new static() in /src/SchedulerPluginBase.phpcreate(). Is this correct to remove? What are the implications?Thanks. Overall this is good improvement to the plugins and I'd like to get it committed and into the first full 2.0 release.
Comment #7
dieterholvoet commentedfindDefinitionsis an overridden method from the parent class. This version filters out plugins with missing module depencencies before they are initialized, removing the need for separate checks per plugin.PluginBaseconstructor doesn't have a fourth parameter.Comment #8
dieterholvoet commentedI'm waiting for this issue to be committed and included in a release, so I can commit #3283203: Simplify the scheduler plugin implementation and make a stable release for Scheduler for Entity Construction Kit (ECK).
Comment #9
jonathan1055 commentedOK, if I commit this and then release Scheduler 2.0.0-rc3 would that help? There are still a few things to get done before the full 2.0.0 release.
Comment #10
dieterholvoet commentedSure, it's just so I can add the right version dependency to the module.
Comment #11
jonathan1055 commentedIn the new typeFieldName() we have
But in the new entityFormIdsByType() we cater for no bundle key:
What happens in typeFieldName() if the entity does not have a bundle key? Do we need to cover this scenario and fail gracefully? The four existing plugins all have a bundle key, so I can't test this.
Comment #12
dieterholvoet commentedA good example entity type without bundles is
user. The question is: does scheduler support this? I don't think so, since the scheduler options are configured per bundle and since there is currently no way to configure it for a whole entity type.The simplest solution to me sounds like 'don't make scheduler plugins for entity types without bundles', but just to be safe we could filter out any plugins whose entity type doesn't support bundles in
SchedulerPluginManager::findDefinitionsand document that behaviour. Another option is to add support, but I don't think that would be super useful.Comment #13
dieterholvoet commentedHere's a plugin for the user entity type in case you want to try it out:
Comment #14
jonathan1055 commentedThanks, yes of course the User entity is a good one to test with. I think filtering out non-bundled entity types in
SchedulerPluginManager::findDefinitionsis a good idea.We did have a comment on #3225695-11: Support entity types whose entity bundle type does not end with `_type` and entities without created date about entities without a bundle, but as I said on that thread it would be a whole separate task and quite a major change (probably). There is also #3284451: Support for Block (display) entities which might benefit. But for now, lets just filter out the plugin.
Comment #15
dieterholvoet commentedI changed the implementation to filter out plugin definitions for entity types without bundles.
Comment #16
jonathan1055 commentedThanks for doing that. I have removed the bundle checks in the other places, as they should not be needed now.
Comment #17
dieterholvoet commentedIs there anything left to do here?
Comment #19
jonathan1055 commentedIf there is anything, it can be done in a follow up issue. Thank you for suggesting this improvement and for doing the bulk of the work. It is much better now, with nothing to do in the plugin definition except specify the arguments.
Comment #20
jonathan1055 commentedI have released Scheduler 2.0.0-rc3
Comment #21
jonathan1055 commentedI have just discovered an error, where I should not have removed the check on
$definition->hasKey('bundle')in the commit after #15 above. That is needed when generating the 'type' form ids, such as node_type_add_form, as it stands now we get node_type_page_add_form and the hook_form_alter does not get done.I will put this code back in to fix it. The RC3 release is broken, but I don't think I can delete a release, so I will make RC4.
Then I need to work out why the automated testing did not discover this error ... and then add more test coverage.
Comment #23
jonathan1055 commentedThere is also another problem (which was there before I made the change). When there are no entity types/bundles created yet, when creating the first one we do not get the form id returned, so the Scheduler options are not added. On subsequent adds, and when editting an entity type it works fine. This is because
getTypes()is empty on the first add, so nothing is processed in the foreach loop. It's only a problem for the entity type forms, so I have added a second parameter and then initialised $types according to that setting.Comment #25
dieterholvoet commentedThanks, I created a first release for scheduler_eck.
Comment #26
jonathan1055 commentedI need to add a test for the entity bundle form. I thought we had good test coverage so I was surprised when I found the two bugs after all the tests passed.
Added #3285242: Add test coverage for entity type form