This is a basic module, not very deep, that uses Drupal 8 API hooks and Slack module's hooks to pass data to the Slack channel identified with the Slack app. The Admin settings for the app only include a on/off toggle and a text form field for defining the correct workflow state to use the message.

There are currently no modules on Drupal opensource that provide this simple functionality. After some thorough development, I was able to fulfill it, and now I want to make my solution available to the Drupal community.

Project link

https://www.drupal.org/project/workflow_slack_int

Git instructions

git clone --branch 8.x-1.x https://git.drupalcode.org/project/workflow_slack_int.git

Pareview checklist

https://pareview.sh/pareview/https-git.drupal.org-project-workflow_slack...

Comments

tony.sayge created an issue. See original summary.

rksyravi’s picture

Issue summary: View changes

Hi @ tony.sayge,

Thank you for contribution!!!
At first resolve, all the errors & warnings mentioned below. And also you can also check by yourself from Pareview checklist link added in the summary.

Your README.txt does not follow best practices (headings need to be uppercase). See https://www.drupal.org/node/2181737 .
The INTRODUCTION section is missing.
The REQUIREMENTS section is missing.
The INSTALLATION section is missing.
The CONFIGURATION section is missing.
Coder Sniffer has found some issues with your code (please check the Drupal coding standards). See attachment.
DrupalPractice has found some issues with your code, but could be false positives.

FILE: ...or/drupal/pareviewsh/pareview_temp/src/Form/WorkflowSlackIntForm.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------
 61 | WARNING | Unused variable $values.
 72 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
--------------------------------------------------------------------------

Time: 212ms; Memory: 4Mb
No automated test cases were found, did you consider writing PHPUnit tests? This is not a requirement but encouraged for professional software development.
This automated report was generated with PAReview.sh, your friendly project application review script.

FILE: ...web/vendor/drupal/pareviewsh/pareview_temp/workflow_slack_int.module
--------------------------------------------------------------------------
FOUND 13 ERRORS AND 4 WARNINGS AFFECTING 13 LINES
--------------------------------------------------------------------------
  6 | ERROR   | [x] There must be exactly one blank line after the file
    |         |     comment
 24 | WARNING | [x] Unused use statement
 26 | WARNING | [x] Unused use statement
 27 | WARNING | [x] Unused use statement
 28 | WARNING | [x] Unused use statement
 32 | ERROR   | [x] Expected 1 space(s) before asterisk; 0 found
 32 | ERROR   | [x] There must be no blank lines after the function
    |         |     comment
 34 | ERROR   | [x] Namespaced classes/interfaces/traits should be
    |         |     referenced with use statements
 44 | ERROR   | [x] There should be no white space before a closing ")"
 56 | ERROR   | [x] Namespaced classes/interfaces/traits should be
    |         |     referenced with use statements
 69 | ERROR   | [x] Case breaking statements must be followed by a single
    |         |     blank line
 69 | ERROR   | [x] Case breaking statement indented incorrectly;
    |         |     expected 6 spaces, found 4
 71 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 71 | ERROR   | [x] No space found before comment text; expected "// Do
    |         |     something else;" but found "//Do something else;"
 71 | ERROR   | [x] Inline comments must end in full-stops, exclamation
    |         |     marks, colons, question marks, or closing parentheses
 72 | ERROR   | [x] Case breaking statement indented incorrectly;
    |         |     expected 6 spaces, found 4
 74 | ERROR   | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 17 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------


FILE: ...00000/site1101/web/vendor/drupal/pareviewsh/pareview_temp/README.txt
--------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------
 3 | WARNING | [ ] Line exceeds 80 characters; contains 149 characters
 5 | ERROR   | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------


FILE: ...or/drupal/pareviewsh/pareview_temp/src/Form/WorkflowSlackIntForm.php
--------------------------------------------------------------------------
FOUND 14 ERRORS AND 1 WARNING AFFECTING 15 LINES
--------------------------------------------------------------------------
 18 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 3
 19 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 20 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 21 | ERROR   | [x] Expected 1 blank line before function; 0 found
 27 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 3
 28 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 29 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 34 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 3
 35 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 36 | ERROR   | [x] Expected 4 space(s) before asterisk; 3 found
 40 | ERROR   | [x] Short array syntax must be used to define arrays
 47 | ERROR   | [x] Short array syntax must be used to define arrays
 51 | WARNING | [x] A comma should follow the last multiline array item.
    |         |     Found: 'draft'
 76 | ERROR   | [x] Expected 1 blank line after function; 0 found
 77 | ERROR   | [x] The closing brace for the class must have an empty
    |         |     line before it
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

Time: 553ms; Memory: 4Mb
rksyravi’s picture

Status: Needs review » Needs work

Hi,
For now, I am changing the status to 'Needs work', after you resolve the issues change to 'Needs review'

avpaderno’s picture

avpaderno’s picture

Issue summary: View changes
tony.sayge’s picture

Thank you for the comments. I've gone through the code and have corrected the errors from PAReview.

tony.sayge’s picture

Status: Needs work » Needs review
rksyravi’s picture

Hi @tony.sayge,
You're almost done with all the errors & warnings. This is the last one, on which you'll need to work.

FILE: ...or/drupal/pareviewsh/pareview_temp/src/Form/WorkflowSlackIntForm.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
 73 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
--------------------------------------------------------------------------

Time: 441ms; Memory: 4Mb
rksyravi’s picture

Status: Needs review » Needs work
tony.sayge’s picture

Thanks @rksyravi. I guess I just glossed over that one.

I appreciate the assist.

tony.sayge’s picture

Status: Needs work » Needs review
ankush_03’s picture

Status: Needs review » Needs work

2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------
Line src/Form/WorkflowSlackIntForm.php
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------
Class Drupal\workflow_slack_integration\Form\WorkflowSlackIntForm was not found while trying to analyse it - autoloading is probably not configured properly.
------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------

------ --------------------------------------------------------------------------------------
Line workflow_slack_int.module
------ --------------------------------------------------------------------------------------
33 Call to an undefined method Drupal\Core\Entity\EntityInterface::get().
47 Call to an undefined method Drupal\Core\Entity\EntityInterface::getRevisionId().
50 Call to an undefined method Drupal\Core\Entity\EntityInterface::getRevisionUserId().
50 Call to static method load() on an unknown class User.
53 Access to an undefined property Drupal\Core\Entity\EntityInterface::$title.
------ --------------------------------------------------------------------------------------

[ERROR] Found 6 errors

avpaderno’s picture

avpaderno’s picture

get() is the FieldableEntityInterface::get() method, while getRevisionId() is RevisionableInterface::getRevisionId(). ContentEntityBase implements both the interfaces.

The code should check which interfaces are used from the object passed as parameter, before calling any method.

avpaderno’s picture

tony.sayge’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Fixed
  1. config schema is missing, see https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...
  2. module file: all use statements should be at the top of the file together.
  3. workflow_slack_int_node_update(): Not all nodes will have a moderation_state field, so this will throw exceptions or PHP fatal errors on all other node types.

Otherwise looks good to me.

Thanks for your contribution, Tony!

I updated your account so you can opt into security advisory coverage now.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

klausi’s picture

Also assigning credits to myself.

avpaderno’s picture

tony.sayge’s picture

Thanks everyone for the help.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.