This module extends the 'Rendered entity' views row plugin allowing developers to inject custom markup between results.

https://www.drupal.org/sandbox/extremal/2699035

git clone --branch 7.x-1.x https://git.drupal.org/sandbox/extremal/2699035.git views_results_inject
cd views_results_inject

Manual reviews of other projects:

https://www.drupal.org/node/2429983#comment-11063071
https://www.drupal.org/node/2699075#comment-11064537
https://www.drupal.org/node/2693535#comment-11064717

Comments

extremal created an issue. See original summary.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

madan879’s picture

Hi,

Please fix the some basic issues suggested by paraview (http://pareview.sh/pareview/httpsgitdrupalorgsandboxextremal2699035git) are below:

FILE: ...review/pareview_temp/plugins/views_results_rendered_entity_inject.inc
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
13 | WARNING | Class name must be prefixed with the project name
| | "ViewsResultsInject"
---------------------------------------------------------------------------

FILE: /var/www/drupal-7-pareview/pareview_temp/README.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
29 | WARNING | Line exceeds 80 characters; contains 91 characters
30 | WARNING | Line exceeds 80 characters; contains 111 characters
----------------------------------------------------------------------

FILE: ...review/pareview_temp/plugins/views_results_rendered_entity_inject.inc
---------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------
13 | ERROR | Class name must begin with a capital letter
13 | ERROR | Class name must use UpperCamel naming without underscores
36 | ERROR | Protected method name
| | "views_results_rendered_entity_inject::custom_callback_exists"
| | is not in lowerCamel format
43 | ERROR | Public method name
| | "views_results_rendered_entity_inject::get_value" is not in
| | lowerCamel format
---------------------------------------------------------------------------

extremal’s picture

Hi madan879,

Thanks for the review !
This module interacts with the functionality provided by 'Views' and 'Entity' modules (it overrides the 'Rendered Entity' row plugin).
Hence the errors.
I can change the class name, but won't be able to override existing methods which are not following the lowerCamel format without causing a coding standards error.
Probably this is one of the cases when we can't keep codesniffer happy (unless of course we put @codingStandardsIgnore annotations)
What do you think ?

madan879’s picture

Hi extremal,

Yes, we can use @codingStandardsIgnoreStart and @codingStandardsIgnoreEnd annotations for specific part of code need to omit for errors...

extremal’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
mmowers’s picture

Hi @extremal. Here's a manual code review, based on the Project Application Review Template.

Recommendations/Questions are in bold italics

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation. I could not find another module that performs the same function. Another way of injecting markup would be to add it directly in the views template, but this module is still useful.
Master Branch
[Yes: Follows] the guidelines for master branch, with 7.x-1.x as the branch name and the correct git clone command
Licensing
[Yes: Follows] the licensing requirements, as sandbox project uses GNU GPL v2, and there are no other licenses cited.
3rd party assets/code
[Yes: Follows] the guidelines for 3rd party assets/code, as none are included.
README.txt/README.md
[Yes: Follows] the guidelines for in-project documentation and/or the README Template, with all the required sections and information in README.txt.
Code long/complex enough for review
[No: Does not follow] the guidelines for project length and complexity. There are less than 120 lines of code (111 lines, including comments, if I counted correctly). There are 3 functions and 1 class (with 3 more functions), so I believe the function/class number requirement is met. Perhaps an exception can be made?
Secure code
[Yes: Meets] the security requirements There are no writes to the db and no handling of user input.
Coding style & Drupal API usage
[List of identified issues in no particular order]
  • No issues that I can find here.
klausi’s picture

@mmowers: I think you forgot the status. Since project length is not an application blocker is there anything else missing or is this now RTBC after your review?

mmowers’s picture

Status: Needs review » Needs work

After enabling and setting a views row plugin to "Rendered entity with injected custom markup", I get this warning:
Strict warning: Declaration of ViewsResultsInjectPlugin::get_value() should be compatible with entity_views_plugin_row_entity_view::get_value($values, $field = NULL) in require_once() (line 13 of /home/mow/websites/jonmed/sites/all/modules/views_results_inject/plugins/views_results_rendered_entity_inject.inc).

Also, when loading the view on a page, I get these warnings:
Strict warning: Declaration of ViewsResultsInjectPlugin::get_value() should be compatible with entity_views_plugin_row_entity_view::get_value($values, $field = NULL) in require_once() (line 13 of /home/mow/websites/jonmed/sites/all/modules/views_results_inject/plugins/views_results_rendered_entity_inject.inc).

Notice: Undefined property: stdClass::$entity in ViewsResultsInjectPlugin->get_value() (line 45 of /home/mow/websites/jonmed/sites/all/modules/views_results_inject/plugins/views_results_rendered_entity_inject.inc).

And the view itself does not seem to load.

Note that I haven't added any custom code to inject markup. I just enabled the module and set the views row plugin to "Rendered entity with injected custom markup".

It would be good for someone else to test as well to make sure it's not just me.

Changing status to "Needs Work".

extremal’s picture

Hi @mmowers,

Thanks a lot for your review. I missed that because I was testing it in conjunction with search_api_views module which was adding 'entity' field to the results array (http://cgit.drupalcode.org/search_api/tree/contrib/search_api_views/incl...).

In order to make this working with any type of entity (taxonomy term, node etc), I decided to keep the original get_value() method. But that means that the custom callback must be injected before the pre_render() happens (as we need to have the callback injected at this point: http://cgit.drupalcode.org/entity/tree/views/plugins/entity_views_plugin...).
And that means that we should do it straight after the views query runs but before pre_render() starts.
Luckily, there is a hook_views_post_execute() which happens exactly where we need it to happen!

To sum up:
- I've changed instructions of how to use this module (instead of injecting callback in hook_views_pre_render() it should be done in hook_views_post_execute())
- got rid of the get_value() method override

I am hoping that all is working fine now. Please let me know !

Thanks again for testing it ! Much appreciated.

extremal’s picture

Status: Needs work » Needs review
braindrift’s picture

Status: Needs review » Needs work

Hi extremal,

you should pass the plugin title in views_results_inject_views_plugins():16 through t().

Best regards

extremal’s picture

Status: Needs work » Needs review

Hi @braindrift,

Thanks, this is done now.

braindrift’s picture

Status: Needs review » Reviewed & tested by the community

Since I don't see any issues and the module is not complicated enough to have many issues I set it to RTBC.

braindrift’s picture

Hi @extremal,

you should add a hint to your project page that this module is for developers only since a non developer will not be able to use your module.

Best regards

extremal’s picture

Good idea. Thanks @braindrift.

th_tushar’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: single application approval

Hi @extremal,

Please update the example code on you module page, as it may cause security vulnerability in the user's site.

function yourmodule_custom_callback($name) {
  return 'Embed custom code into results of the view ' . $name;
}

User facing text should be passed through t() function and placeholders should be used instead of string concatenation.

Adding the single project promote tag as per the guidelines.

Thanks for your contribution!!

extremal’s picture

Status: Needs work » Needs review

Hi @th_tushar,

Thanks, corrected !

braindrift’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed and suggestions from #17 were implemented on module page and in README. So again to RTBC

klausi’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -PAreview: single application approval

Looks good to me! Since extremal has quite a few other contributions also I think we can fully approve him.

Thanks for your contribution, extremal!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

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.

Status: Fixed » Closed (fixed)

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