Problem/Motivation
When I `grep -rl -- \\Drupal:: .` from the module root (and ignore tests and procedural code) I get:
./src/ParagraphAccessControlHandler.php
./src/Entity/ParagraphsType.php
./src/Entity/Paragraph.php
./src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
./src/Plugin/Field/FieldWidget/ParagraphsWidget.php
./src/Plugin/Field/FieldFormatter/ParagraphsSummaryFormatter.php
./modules/paragraphs_library/src/Controller/LibraryItemController.php
./modules/paragraphs_library/src/Entity/LibraryItem.php
As stated in https://www.drupal.org/docs/8/api/services-and-dependency-injection/serv... we really ought to use Dependency Injection.
Proposed resolution
Update the code to use Dependency Injection.
Remaining tasks
Do we want this to be a META issue and break the task into smaller pieces?
Will we want or need to create additional tests?
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 3091424_31.patch | 42.56 KB | julien_g |
| #30 | 3091424_30.patch | 42.57 KB | julien_g |
| #19 | 3091424_19.patch | 41.88 KB | julien_g |
| #14 | 3091424_4.patch | 41.84 KB | julien_g |
| #10 | dependency-injection-coding-standards-3091424-10.patch | 96.46 KB | chakkche |
Issue fork paragraphs-3091424
Show commands
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 #2
vegantriathleteCorrected typo in issue summary.
Comment #3
saphemmy commentedComment #4
ruturaj chaubeyAre you still working on this issue?
If not, I would like to take up this issue.
Comment #5
saphemmy commentedComment #6
ruturaj chaubeyComment #7
chakkche commentedComment #8
ruturaj chaubeyComment #9
chakkche commentedI will work on this.
Comment #10
chakkche commentedFixed all the drupal calls and coding standards in their respective files
Comment #11
ruturaj chaubeyWill review this.
Comment #12
ruturaj chaubeyWhile testing this patch, this following error occurred.
The create method of the
ParagraphsWidgetClass is not compatible with the core'sWidgetBaseClass.Steps to Reproduce
1. Create a paragraph type, by going to
admin/structure/paragraphs_type.2. Add a text or any field to the newly created paragraph type.
3. After the paragraph type is created, Add the paragraph field to a content type.
4. Then, while accessing the field widget of the paragraph type, a HTTP 500 response is displayed.
Also, I think the dependency injection in the
ParagraphsWidgetis not handled properly.Comment #13
julien_g commentedPatch is outdated.
I have run the grep command. Here are the new files with \\Drupal::
Patch in progress.
Comment #14
julien_g commentedHere is the patch.
Some files stil contains \Drupal:: calls :
Comment #15
tmaiochi commentedI'll review this!
Comment #16
tmaiochi commentedThe patch #14 I found a few standard coding problems in the added code and, when I ran the tests, I got a lot of errors that weren't there before the patch, so I'm moving to needs work
Comment #17
julien_g commentedHi @tmaiochi, can you give me more details .
When I run phpcs checks I have the following results :
for files that have issues on phpcs :
Before patch :
After patch :
Comment #18
tmaiochi commentedOf course @julien_g
In reality it's just a phpcs error that accuses the InlineParagraphsWidget.php file:
I ran
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,js src/Plugin/Field/FieldWidget/InlineParagraphsWidget.phpAnd the only line that there was a change and phpcs gives a message was this:
396 | ERROR | [x] Short array syntax must be used to define arraysComment #19
julien_g commentedThanks @tmaiochi,
here is the patch with phpcs error fixed
Comment #20
anabpvI will review this
Comment #22
anabpvSteps performed:
1 - downloaded the module and applied the patch from #19
2 - ran phpcs to properly review the dependency injections
3 - opened an MR and committed the changes from #19
Moving to RTBC.
Comment #26
saphemmy commentedI do suggest phpcs should be created on another issue if none exists.
My opinion: This issue should address the issue scope which is dependency injections as described by the title.
Comment #27
julien_g commentedHi,
New patch with failed test fixes.
Comment #28
julien_g commentedService not found exception on test fixes.
Comment #29
julien_g commentedComment #30
julien_g commentedComment #31
julien_g commentedHere is the patch that pass all tests
Comment #32
julien_g commentedComment #33
lucasbaralmI'm going to review this!
Comment #34
lucasbaralmSteps performed:
1 - downloaded the module and applied the patch from #31.
2 - ran phpcs to properly review the dependency injections.
Moving to RTBC.
Comment #35
berdirMust be a merge request now.
Comment #37
jatingupta40 commented#3091424: Created and rebase the MR with respect to 8.x-1.x.
Moving to Needs Review.
Comment #38
jatingupta40 commented