Problem/Motivation
Follow-up from #2492585-24: Deprecate comment_view() & comment_view_multiple()
Action \Drupal\comment\Plugin\Action\UnpublishByKeywordComment does not implement ContainerFactoryPluginInterface so no way to inject services that used inside.
Proposed resolution
Make the action class implement ContainerFactoryPluginInterface
Add __construct() method with all required services
Use injected services
Remaining tasks
patch, commit
User interface changes
no
API changes
\Drupal\comment\Plugin\Action\UnpublishByKeywordComment implements ContainerFactoryPluginInterface
Data model changes
no
Beta phase evaluation
| Issue category | Task because clean-up of code introduced in 8.x |
|---|---|
| Issue priority | Normal because reduces fragility |
| Disruption | no |
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 2526004-6.patch | 3.71 KB | andypost |
| #6 | interdiff.txt | 3.63 KB | andypost |
| #4 | 2526004-4.patch | 2.81 KB | andypost |
Comments
Comment #1
andypostnext step to convert
\Drupal\comment\Tests\CommentActionsTest::testCommentUnpublishByKeywordto unittestComment #2
andypostrelated needs the same sort of test
Comment #4
andypostAdded missed interface, fixed IS
Looks we need to inject string translation and convert
t()to$this->t()as wellProbably absence of interface on action could change category to bug.
Comment #5
jibranI think it's RTBC just minor points.
Can we inject CommentViewBuilder instead of entity manager?
Please make this multi line.
Comment #6
andypostNow it's ready for unittesting, working on it
Comment #7
andypostThe test was filed in #2526060-4: Add tests for action plugins let's get agreement on approach, looks we can convert existing tests to kernel test to make it faster 5x.
Also testing of subject does not needed, action uses rendered comment (full) to check for keywords, so if no subject rendered no reason to check keywords in
Updated IS (removed mentions about unit tests)
Comment #8
jibranLooks good to me.
Comment #10
jibranseems unrelated so re-testing.
Comment #12
andypostyep, bot flux
Comment #13
alexpottCommitted 268ffb4 and pushed to 8.0.x. Thanks!
I think this is permissible in beta because the disruption is minimal and using the container to inject dependencies is the correct pattern.
Comment #15
andypostThanx!