Create a service which would help get the information from the user and save it in cache. The same service (or another one) should be responsible for reading the cached data and returning User objects (https://github.com/hussainweb/drupal-api-client/blob/master/src/Entity/U...).

Comments

hussainweb created an issue. See original summary.

yonas.legesse’s picture

Assigned: Unassigned » yonas.legesse
Status: Active » Needs review
StatusFileSize
new2.74 KB

I have created a service to be used to get data from Drupal.org, store in cache and read from cache.

yonas.legesse’s picture

Corrected return statement in previous patch.

yonas.legesse’s picture

Upon review, it's better to use a single function to save and get the information. This comes in very handy when using it for computed fields.

hussainweb’s picture

Status: Needs review » Needs work

@yonas.legesse, thanks for your work on the patch. I have a few comments and most of them should be a quick-fix.

  1. +++ b/do_username.services.yml
    @@ -0,0 +1,11 @@
    +        arguments: ['@do_username.do_client','@cache.data']
    

    Nit: Space after comma

  2. +++ b/do_username.services.yml
    @@ -0,0 +1,11 @@
    +        ¶
    \ No newline at end of file
    

    There is extra whitespace here and no newline

  3. +++ b/src/DrupalOrgUserInformationService.php
    @@ -0,0 +1,64 @@
    +class DrupalOrgUserInformationService {
    

    Can we call this class something else? This is rather too long. I am thinking of something like `DOUserInfoRetriever`.

  4. +++ b/src/DrupalOrgUserInformationService.php
    @@ -0,0 +1,64 @@
    +   * Function to store user information.
    

    The comment is not accurate.

yonas.legesse’s picture

Assigned: yonas.legesse » Unassigned
StatusFileSize
new2.31 KB

@hussainweb, i've incorporated the comments. Kindly review.

hussainweb’s picture

Some more comments

  1. +++ b/src/DOUserInfoRetriever.php
    @@ -0,0 +1,63 @@
    +   * Function to store user information.
    

    This comment still needs to be updated.

  2. +++ b/src/DOUserInfoRetriever.php
    @@ -0,0 +1,63 @@
    +      return $cachedData->data->current();
    

    If we're only going to use `current()`, we should just cache that only.

hussainweb’s picture

Status: Needs work » Fixed

I made some improvements apart from other comments above and committed. Thanks for your work here!

Status: Fixed » Closed (fixed)

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