insperedia / yiidea-support

Other
2 stars 0 forks source link

Go to file `view` not work in ListView #17

Closed ahmadfadlydziljalal closed 1 month ago

ahmadfadlydziljalal commented 3 months ago

Consider this code:

 <?php
    echo ListView::widget([
        'dataProvider' => new ActiveDataProvider([
            'query' => $model->getCompanyServiceMasterTemplates(),
        ]),
        'itemView' => function ($model, $key, $index, $widget) {
            return $this->render('_view_item_master_template_invoice_import', [
                'model' => $model,
            ]);
        },
        'layout' => "{items}",
        'itemOptions' => [
            'tag' => false,
        ]
    ]);
    ?>

In normal condition, when we click _view_item_master_template_invoice_import, it will be automatically open those file. But in this case, it`s not work.

Please fixed it. I already subscribe this plugin in phpstorm

Thanks

insperedia commented 3 months ago

Can you please provide relative path of the view?

ahmadfadlydziljalal commented 3 months ago

This is works, Yii2 displayed it, but still no success in click >> goto file

return $this->render('/company-service/_view_item_master_template_invoice_import', [
    'model' => $model,
]);

We use standard basic template, no structure directory modification.

insperedia commented 3 months ago

Of course, it works in my test project. The first thing you need to try is to rebuild indexes. One option is to add a fake path in the plugin settings in the View section. It fires an index rebuild. Alternatively, you can probably use File > Invalidate caches > Mark downloaded shared indexes as broken.

If it does not help, you need to provide additional info. The code itself is not sufficient. Plugin search the view file in your directory structure. I need a path of the view and a path of the code calling render method.

insperedia commented 1 month ago

Please provide additional info:

  1. I need to know what path is shown in the error, displayed on hover on the marked missing view.
  2. And the actual location of the view.
ahmadfadlydziljalal commented 1 month ago
  1. I need to know what path is shown in the error, displayed on hover on the marked missing view.

No Error. Please just create a new Yii2 Application, and test of them.

  1. And the actual location of the view. Standard template

All tested in PhpStorm 2024.2.0.1

verifiera commented 1 month ago

Thank you. Will take a look.

insperedia commented 1 month ago

The reason why it is not working is that IDE does not know the type of $this. To make it work you need declare the type:

echo ListView::widget([

'itemView' => function ($model, $key, $index, $widget) {
    /**
     * @var \yii\web\View $this
     */
    return $this->render('test', [
        'model' => $model,
    ]);
},

]);