Comments

ankitjain28may created an issue. See original summary.

ankitjain28may’s picture

StatusFileSize
new9.46 KB
ankitjain28may’s picture

Status: Active » Needs review
dbjpanda’s picture

+++ b/affiliates_connect.info.yml
@@ -0,0 +1,7 @@
+package: Third-party Integration

package: Affiliates Connect

+++ b/affiliates_connect.info.yml
@@ -0,0 +1,7 @@
+version: 8.x-1.x

It will be added automatically by the packager on drupal.org. No need to add version.

+++ b/src/Controller/AffiliatesConnectController.php
@@ -0,0 +1,68 @@
diff --git a/src/Plugin/AffiliatesNetworkBase.php b/src/Plugin/AffiliatesNetworkBase.php

+++ b/src/Plugin/AffiliatesNetworkBase.php
@@ -0,0 +1,15 @@
diff --git a/src/Plugin/AffiliatesNetworkInterface.php b/src/Plugin/AffiliatesNetworkInterface.php

+++ b/src/Plugin/AffiliatesNetworkInterface.php
@@ -0,0 +1,15 @@
diff --git a/src/Plugin/AffiliatesNetworkManager.php b/src/Plugin/AffiliatesNetworkManager.php

Can you keep *Base, *Interface, *Manager outside of plugin like this https://cgit.drupalcode.org/search_api_location/tree/src or https://cgit.drupalcode.org/geocoder/tree/src

I hope it is best practice to define only plugins inside plugin folder. plugin type should be defined outside of plugin folder.

And provide a proper description inside *interface that what this AffilaiteNetwork plugin type is going to do ?

borisson_’s picture

All of the points in #4 are solid, but I have a couple more:

  1. +++ b/affiliates_connect.module
    @@ -0,0 +1,22 @@
    +        return '<p>' . t('This module provides an interface to easily integrate with various affiliate APIs or
    +        product advertising APIs provided by different ecommerce platforms like Flipkart, Amazon, Ebay etc to
    +        fetch data easily from their stores and display those to monetize your website by advertising their products.') . '</p>';
    

    Most hook help implementations start with an h3-level title before the actual content of the help.

    This shuold probably be split up into multiple smaller sentences as well.

  2. +++ b/affiliates_connect.routing.yml
    @@ -0,0 +1,17 @@
    +  requirements:
    +    _permission: 'access administration pages'
    ...
    +  requirements:
    +    _permission: 'access administration pages'
    

    We should introduce our own permission instead of reusing this one. That can be done in a new follow-up issue though.

  3. +++ b/src/Annotation/AffiliatesNetwork.php
    @@ -0,0 +1,43 @@
    +   * The module machine name.
    ...
    +   * The label of the module.
    ...
    +   * The description of the module.
    

    /s/module/affiliate plugin/ ?

  4. +++ b/src/Controller/AffiliatesConnectController.php
    @@ -0,0 +1,68 @@
    +  private $affiliatesNetworkManager;
    

    private properties / methods aren't used very often in core/contrib. This is so that we can more easily overwrite them from custom code.

  5. +++ b/src/Plugin/AffiliatesNetworkBase.php
    @@ -0,0 +1,15 @@
    +abstract class AffiliatesNetworkBase extends PluginBase implements AffiliatesNetworkInterface {
    +
    +
    +  // Add common methods and abstract methods for your plugin type here.
    +
    +}
    

    This baseclass is useless right now, we can remove it and add one when it's needed.

  6. +++ b/src/Plugin/AffiliatesNetworkManager.php
    @@ -0,0 +1,33 @@
    +  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    +    parent::__construct('Plugin/AffiliatesNetwork', $namespaces, $module_handler, 'Drupal\affiliates_connect\Plugin\AffiliatesNetworkInterface', 'Drupal\affiliates_connect\Annotation\AffiliatesNetwork');
    

    Useing the class::class notation is easier for refactoring later.

    So something like AffiliatesNetworkInterface::class

gvso’s picture

Status: Needs review » Needs work
ankitjain28may’s picture

Thanks for the review, i will make the changes :)

ankitjain28may’s picture

Status: Needs work » Needs review
StatusFileSize
new7.28 KB

I have made the changes as stated in the above comments, please review.

ankitjain28may’s picture

StatusFileSize
new7.26 KB

Sorry, Added the wrong patch, please ignore the above one, Review this.

dbjpanda’s picture

@ankitjain28may You have only uploaded the interdiff, Have you forgotten to upload the patch ?

ankitjain28may’s picture

Status: Needs review » Needs work
StatusFileSize
new9.32 KB
new7.26 KB

@dbjpanda sorry, I added the patch and the interdiff.

chiranjeeb2410’s picture

Status: Needs work » Needs review
Lal_’s picture

+++ b/affiliates_connect.module
@@ -0,0 +1,31 @@
+    // Main module help for the affiliates_connect module.
...
+      $output .= '<h3>' . t('About Affiliates Connect') . '</h3>';
+      $output .= '<p>' . t('This module provides an interface to ') . '</p>';
+      $output .= '<p>' . t('easily integrate with various affiliate ') . '</p>';
+      $output .= '<p>' . t('APIs or product advertising APIs provided') . '</p>';
+      $output .= '<p>' . t(' by different ecommerce platforms like ') . '</p>';
+      $output .= '<p>' . t('Flipkart, Amazon, Ebay etc to fetch data ') . '</p>';
+      $output .= '<p>' . t('easily from their stores and display ') . '</p>';
+      $output .= '<p>' . t('those to monetize your website by ') . '</p>';
+      $output .= '<p>' . t('advertising their products.') . '</p>';

you can use description.html.twig I think it would make it much simpler just check...

https://cgit.drupalcode.org/examples/tree/menu_example/templates/descrip...

https://cgit.drupalcode.org/examples/tree/menu_example/src/Controller/Me...

ankitjain28may’s picture

@Lal_Thanks, This looks great, I will make the changes.

gvso’s picture

Status: Needs review » Needs work
+++ b/config/install/affiliates_connect.settings.yml
@@ -0,0 +1,5 @@
+fallback_scraper: True
+save_searched_products: False
+cloaking: True
+enable_hits_analysis: True
+append_affiliate_id: True

I'm not sure if there is a coding standard for boolean in .settings.yml file, but I have never seen this convention in any modules (looks like python to me). I have seen either all with uppercase letters or all with lowercase letters. It seems like core is using lowercase

ankitjain28may’s picture

Assigned: Unassigned » ankitjain28may
Status: Needs work » Needs review
StatusFileSize
new11.71 KB
new12.5 KB

I made the changes, Please review.

borisson_’s picture

I think this is a great first start. We should probably add tests as well. Maybe that can be a followup though.

A test that checks that the created routes exist and return a 200-OK should be suffient for now.

I have some code style problems with this as well, but I'd suggest that we can fix those after we commit this, so we can have automated tests enabled, making fixing those easier.

ankitjain28may’s picture

@borisson_ Thanks for the review, I will write tests in the follow-up and fix code style problems too.

borisson_’s picture

Awesome, in that case this seems like a solid base to start from. Leaving to @dbjpanda to RTBC and/or commit but +1 from me.

thedrupalkid’s picture

Status: Needs review » Reviewed & tested by the community

For any improvisations we can always create a different issue. Hence, As per the Issue Summary moving it to RTBC.

chiranjeeb2410’s picture

StatusFileSize
new13.55 KB
new148.7 KB
new143.73 KB

@borrison_, @dbjpanda, @ankitjain28may

The module skeleton seems to be working fine as of now along with the Config Settings page. Ran and tested the
code for the same and seems RTBC to me.

Seems good to commit this. Attaching screenshots below.

dbjpanda’s picture

Status: Reviewed & tested by the community » Fixed

Thanks to all of you. Committed. Great job @ankitjain28may

Status: Fixed » Closed (fixed)

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