The module adds Open Search Description to your site. This enables the visitors to search your website directly from the Google Chrome address bar. (See README for more information.)

Automated testing

https://www.drupal.org/node/2847577/qa

Project link

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

Git instructions

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

PAReview checklist

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

CommentFileSizeAuthor
#4 opensearch.png20.98 KBankush_03

Comments

Antonín Slejška created an issue. See original summary.

antonín slejška’s picture

Status: Active » Needs review
ankush_03’s picture

@Antonin,

If there is any dependency of any core/contrib module, Please specify in your info.yml file.

currently dependencies: (there is a blank value for dependency).

ankush_03’s picture

StatusFileSize
new20.98 KB

Attached Screenshot.

avpaderno’s picture

avpaderno’s picture

Thank you for applying!
Check the Git settings you are using; in particular, verify the email Git is using is an email Drupal.org knows. Your commits aren't associated to your account, and that is because Git is not using an email registered within your Drupal.org account.

antonín slejška’s picture

Hi Ankush,

there are no dependencies to other modules. See the tests, which work, when only opensearchtab module is installed:

public static $modules = ['opensearchtab'];

The tests:

ankush_03’s picture

@Antonin

So remove blank dependencies: key from info file.

antonín slejška’s picture

Hi Kiam,

thanks for the remark. I have changed the git config for the project and the last commit is connected with my Drupal account.

https://git.drupalcode.org/project/opensearchtab/commits/8.x-1.x

antonín slejška’s picture

vernit’s picture

I have reviewed manually and found below concerns :

1. src/Controller/OpenSearchDescriptionController.php - Code extended more then 80 column. Recommended to break smaller chunks to more readable.
2. Use dependency injection

Example of using:

$messenger= \Drupal::messenger();
$messenger->addMessage($message, 'statut');

First, use the namespace:

use Drupal\Core\Messenger\MessengerInterface;

Than add protected variable to your class:

protected $messenger;

In your constructor:

 public function __construct(MessengerInterface $messenger) {
    $this->messenger = $messenger;
  }

and then:

public static function create(ContainerInterface $container) {
    return new static(
      $container->get('messenger')
    );
  }

Then you can use

$this->messenger->addMessage($message, $message_status);

in your code.

Thank you for your contribution.

ankush_03’s picture

@vernit,

For point 2 You're talking about the same controller file? Becoz I didn't find anything related to drupal messages.

vernit’s picture

Message is for example point of view.
In file Drupal request is used.,

vernit’s picture

Status: Needs review » Needs work
ankush_03’s picture

ok @vernit

@Antonín Slejška is there any case for not extending controller base class in OpenSearchDescriptionController.php file.

$config = \Drupal::config('system.site');

you can also do it by extending controller base class :

Eg: $config = $this->config('system.site'); (This should avoid direct drupal calls)

antonín slejška’s picture

Hi Vernit,

thanks for your suggestions:

Ad 1: I have implemented it with the help of PhpStorm Reformat File Dialog.

Ad 2: I have implemented the dependency injection for configs.

antonín slejška’s picture

Status: Needs work » Needs review

I have implemented the dependency injection also for request and responce:
https://git.drupalcode.org/project/opensearchtab/blob/8.x-1.x/src/Contro...

crafter’s picture

Hi, I have one issue. Maybe better idea would be put part of code from controller to any service beacuse this controller is too big, method content should be share.
I don't think so that contoller's role is creating xml. In my opinion you should put all creating xml functionality to another service. In controller you should only call:

$this->response->setContent($this->myOpenTagService->getXml());
avpaderno’s picture

Issue summary: View changes

Putting the part for generating the XML content into a service would make the code more modular, and allow a third-party module to alter the XML content, but since the task of controllers is generating content, this is not something we can judge on these applications.
It's a great suggestion, though.

antonín slejška’s picture

Hi Adam and Kiam,

I have implemented the service.

Thanks for the suggestion!

crafter’s picture

In my opinion everything is good here. Maybe one thing yet but it's only suggestion. if I were you I would move raw numeric values to const in validateForm in your config form here but like I told before it is only suggestion.

antonín slejška’s picture

Hi Adam,

I made an experiment with the constant. The problem is, that the constant can not be used in the translation method t(). See PAReview.

There are some possible solutions of this problem, but for me it seems too sophisticated.

Generally I have found the suggestion interesting. But I would like to make it more general. Any idea, how to solve the issue?

ankush_03’s picture

@Antonín Slejška

You can try use Drupal\Component\Render\FormattableMarkup

Refer https://drupal.stackexchange.com/questions/220874/passing-variables-that...

antonín slejška’s picture

Thank you Ankush,

the code looks cleaner and the PAReview displays no warnings now.

klausi’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for you contribution!

  1. OpenSearchSettingsForm::buildForm(): $this->t('@title') is not useful for translation. You should send the string literals through t() for translation. So const FIELDS should be a private or protected method that translates the user facing string literals instead.
  2. OpenSearchSettingsForm::buildForm(): "this->t('See the XML of the open search tab:') . ' ' . $opensearchdescription_link;": do not concatenate variables to translatable strings, use placeholders with t() instead.
  3. OpenSearchDescriptionController: class comment only repeats the class name. Please describe what the class is used for and what it does instead. Please check all your class comments.

Otherwise looks good to me, did not see any security issues.

antonín slejška’s picture

Hi Klausi,

thanks for your suggestions. I have implemented them:

  1. commit
  2. commit
  3. commit
avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, 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.

I thank all the dedicated reviewers as well.

antonín slejška’s picture

Thank You Kiam and all other reviewers for all your comments and suggestions. I found it really helpful!

Status: Fixed » Closed (fixed)

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