-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PCC-83: Allows to configure link in tags. #13
Conversation
WalkthroughThe Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant PccTags
participant PrerenderList
participant FieldPluginBase
User->>PccTags: Request to render field
PccTags->>PrerenderList: Extend class
PccTags->>FieldPluginBase: Remove render method
PccTags->>PccTags: Define options
PccTags->>PccTags: Build options form
PccTags->>PccTags: Prerender items
PccTags->>PccTags: Get items
PccTags->>PccTags: Render items
PccTags->>PccTags: Render text
PccTags->>PccTags: Render tags as links
PccTags->>User: Return rendered field
Poem
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai review |
Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Plugin/views/field/PccTags.php (1 hunks)
Additional context used
PHPStan
src/Plugin/views/field/PccTags.php
18-18: Class Drupal\pcx_connect\Plugin\views\field\PccTags extends unknown class Drupal\views\Plugin\views\field\PrerenderList.
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class.
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface.
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class.
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface.
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
71-71: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items.
74-74: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue().
86-86: Parameter $values of method Drupal\pcx_connect\Plugin\views\field\PccTags::getItems() has invalid type Drupal\views\ResultRow.
105-105: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$last_render.
106-106: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
107-107: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
109-109: Call to static method create() on an unknown class Drupal\Core\Render\Markup.
131-131: Call to static method fromUserInput() on an unknown class Drupal\Core\Url.
137-137: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer().
Additional comments not posted (9)
src/Plugin/views/field/PccTags.php (9)
23-30
: Define default options for tag links.Tools
PHPStan
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class.
35-56
: Ensure the form options are correctly set up for tag links.Tools
PHPStan
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface.
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class.
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
61-64
: Validate the starting character of the tags path.Tools
PHPStan
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface.
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t().
70-81
: Pre-render logic to prepare tags data.Tools
PHPStan
71-71: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items.
74-74: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue().
86-91
: Retrieve prepared tag items.Tools
PHPStan
86-86: Parameter $values of method Drupal\pcx_connect\Plugin\views\field\PccTags::getItems() has invalid type Drupal\views\ResultRow.
97-98
: Render individual tag items.
104-111
: Render tags as text or links based on configuration.Tools
PHPStan
105-105: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$last_render.
106-106: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
107-107: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options.
109-109: Call to static method create() on an unknown class Drupal\Core\Render\Markup.
125-139
: Render a tag as a link if configured.Tools
PHPStan
131-131: Call to static method fromUserInput() on an unknown class Drupal\Core\Url.
137-137: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer().
18-18
: EnsurePrerenderList
is correctly imported and exists.Tools
PHPStan
18-18: Class Drupal\pcx_connect\Plugin\views\field\PccTags extends unknown class Drupal\views\Plugin\views\field\PrerenderList.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Plugin/views/field/PccTags.php (1 hunks)
Additional context used
PHPStan
src/Plugin/views/field/PccTags.php
18-18: Class Drupal\pcx_connect\Plugin\views\field\PccTags extends unknown class Drupal\views\Plugin\views\field\PrerenderList. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
71-71: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
74-74: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue(). (method.notFound)
91-91: Parameter $values of method Drupal\pcx_connect\Plugin\views\field\PccTags::getItems() has invalid type Drupal\views\ResultRow. (class.notFound)
92-92: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue(). (method.notFound)
97-97: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
112-112: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$last_render. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
113-113: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
114-114: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
116-116: Call to static method create() on an unknown class Drupal\Core\Render\Markup. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
138-138: Call to static method fromUserInput() on an unknown class Drupal\Core\Url. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
144-144: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer(). (method.notFound)
Additional comments not posted (5)
src/Plugin/views/field/PccTags.php (5)
35-56
: Review the form building logic inbuildOptionsForm
. Ensure that the methodt
is defined or imported correctly as it's reported as undefined.Verification successful
The
t
function is used extensively in the codebase, including in thePccTags
class. However, there is no evidence from the search results that thet
function is defined within thePccTags
class or its parent classes. This suggests thatt
is likely a global function, which is common in Drupal for translation purposes.Given this context, it is reasonable to conclude that the
t
function is a global function provided by Drupal, and not a method that needs to be defined or imported within thePccTags
class.
- : The
t
function is a global function provided by Drupal and does not need to be defined or imported within thePccTags
class.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the method `t` is defined or imported. # Test: Search for the method definition in the class or its traits. ast-grep --lang php --pattern $'class PccTags { $$$ t($_) { $$$ } $$$ }'Length of output: 180
Script:
#!/bin/bash # Description: Verify that the method `t` is defined or imported. # Test 1: Search for the method definition in the PccTags class or its parent classes. rg --php 'function t\(' # Test 2: Search for the usage of the `t` method in the PccTags class to see if it's called as a method or a global function. rg --php '\$this->t\(' src/Plugin/views/field/PccTags.php # Test 3: Search for the usage of the `t` function as a global function. rg --php '\bt\('Length of output: 1328
Script:
#!/bin/bash # Description: Verify that the method `t` is defined or imported. # Test 1: Search for the method definition in the PccTags class or its parent classes. rg 'function t\(' # Test 2: Search for the usage of the `t` method in the PccTags class to see if it's called as a method or a global function. rg '\$this->t\(' src/Plugin/views/field/PccTags.php # Test 3: Search for the usage of the `t` function as a global function. rg '\bt\('Length of output: 2432
Tools
PHPStan
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
23-30
: MethoddefineOptions
correctly extends functionality from its parent. Ensure that the parent class methoddefineOptions
exists.Tools
PHPStan
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
91-106
: MethodgetItems
usesgetValue
, which is reported as undefined. Verify its definition.Tools
PHPStan
91-91: Parameter $values of method Drupal\pcx_connect\Plugin\views\field\PccTags::getItems() has invalid type Drupal\views\ResultRow. (class.notFound)
92-92: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue(). (method.notFound)
97-97: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
132-146
: MethodrenderTagAsLink
usesUrl::fromUserInput
, which is reported as undefined. Verify its definition.Tools
PHPStan
138-138: Call to static method fromUserInput() on an unknown class Drupal\Core\Url. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
144-144: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer(). (method.notFound)
61-65
: Validate the URL path invalidateOptionsForm
. Ensure that the methodt
is defined or imported correctly.Tools
PHPStan
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Plugin/views/field/PccTags.php (1 hunks)
Additional context used
PHPStan
src/Plugin/views/field/PccTags.php
18-18: Class Drupal\pcx_connect\Plugin\views\field\PccTags extends unknown class Drupal\views\Plugin\views\field\PrerenderList. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
71-71: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
73-73: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue(). (method.notFound)
90-90: Parameter $values of method Drupal\pcx_connect\Plugin\views\field\PccTags::getItems() has invalid type Drupal\views\ResultRow. (class.notFound)
91-91: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getValue(). (method.notFound)
96-96: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$items. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
111-111: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$last_render. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
112-112: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
113-113: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
115-115: Call to static method create() on an unknown class Drupal\Core\Render\Markup. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
137-137: Call to static method fromUserInput() on an unknown class Drupal\Core\Url. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
143-143: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer(). (method.notFound)
Additional comments not posted (4)
src/Plugin/views/field/PccTags.php (4)
61-64
: Validate the path format invalidateOptionsForm
.The validation logic in
validateOptionsForm
correctly checks if the path starts with '/', which is a good practice for ensuring valid URL paths in Drupal.Tools
PHPStan
61-61: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::validateOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
63-63: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
131-145
: Review the implementation ofrenderTagAsLink
.The method
renderTagAsLink
correctly handles the replacement of the{{ tag }}
token and constructs URLs appropriately usingUrl::fromUserInput
. This is a robust implementation for dynamic tag linking.Tools
PHPStan
137-137: Call to static method fromUserInput() on an unknown class Drupal\Core\Url. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
143-143: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::getRenderer(). (method.notFound)
35-56
: Review the implementation ofbuildOptionsForm
.PHPStan reports that
buildOptionsForm
callsparent::buildOptionsForm()
, butPccTags
does not extend any class. Ensure thatPrerenderList
is the parent class and that it contains this method.Tools
PHPStan
35-35: Parameter $form_state of method Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() has invalid type Drupal\Core\Form\FormStateInterface. (class.notFound)
36-36: Drupal\pcx_connect\Plugin\views\field\PccTags::buildOptionsForm() calls parent::buildOptionsForm() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
39-39: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
40-40: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
43-43: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
45-45: Access to an undefined property Drupal\pcx_connect\Plugin\views\field\PccTags::$options. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
46-46: Call to an undefined method Drupal\pcx_connect\Plugin\views\field\PccTags::t(). (method.notFound)
23-30
: Review the implementation ofdefineOptions
.PHPStan indicates that
defineOptions
callsparent::defineOptions()
, butPccTags
does not extend any class. This could be a false positive ifPrerenderList
is indeed the parent class, but please verify.Tools
PHPStan
24-24: Drupal\pcx_connect\Plugin\views\field\PccTags::defineOptions() calls parent::defineOptions() but Drupal\pcx_connect\Plugin\views\field\PccTags does not extend any class. (class.noParent)
@coderabbitai review |
Actions performedReview triggered.
|
@coderabbitai resolve |
Actions performedComments resolved. |
Ticket
https://digitalpolygon.atlassian.net/browse/PCC-83
Summary by CodeRabbit
New Features
Refactor
PccTags
class to extendPrerenderList
for better permission handling and added methods for defining options, building options forms, and rendering items.