-
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-59: Views integration with pcc site entity. #4
Conversation
WalkthroughThe recent changes bring significant enhancements to the PCX Connect module in Drupal. These updates refine Views hook implementations, improve the Changes
Warning Review ran into problemsProblems (1)
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 (
|
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: 9
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- pcx_connect.views.inc (1 hunks)
- src/Controller/ApiStatusController.php (1 hunks)
- src/Entity/PccSite.php (2 hunks)
- src/PccSiteViewHelper.php (1 hunks)
- src/Plugin/views/query/PccSiteViewQuery.php (1 hunks)
Files skipped from review due to trivial changes (1)
- src/Controller/ApiStatusController.php
Additional comments not posted (7)
src/PccSiteViewHelper.php (2)
60-61
: LGTM!
75-79
: LGTM!src/Plugin/views/query/PccSiteViewQuery.php (5)
34-36
: LGTM!
41-47
: LGTM!
56-57
: LGTM!
77-78
: LGTM!
84-91
: Verify the necessity of the TODO comment.Please confirm if the TODO comment is still relevant or if it can be removed.
src/Entity/PccSite.php
Outdated
public function postSave(EntityStorageInterface $storage, $update = TRUE) { | ||
parent::postSave($storage, $update); | ||
|
||
// Clear cache to populate the PCC site in views. | ||
if (\Drupal::moduleHandler()->moduleExists('views')) { | ||
Views::viewsData()->clear(); | ||
\Drupal::cache('discovery')->delete('views:wizard'); | ||
} |
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.
Use dependency injection for better testability and adherence to Drupal best practices.
- if (\Drupal::moduleHandler()->moduleExists('views')) {
- Views::viewsData()->clear();
- \Drupal::cache('discovery')->delete('views:wizard');
- }
+ $module_handler = \Drupal::service('module_handler');
+ $views_data = \Drupal::service('views.views_data');
+ $cache_discovery = \Drupal::service('cache.discovery');
+ if ($module_handler->moduleExists('views')) {
+ $views_data->clear();
+ $cache_discovery->delete('views:wizard');
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public function postSave(EntityStorageInterface $storage, $update = TRUE) { | |
parent::postSave($storage, $update); | |
// Clear cache to populate the PCC site in views. | |
if (\Drupal::moduleHandler()->moduleExists('views')) { | |
Views::viewsData()->clear(); | |
\Drupal::cache('discovery')->delete('views:wizard'); | |
} | |
public function postSave(EntityStorageInterface $storage, $update = TRUE) { | |
parent::postSave($storage, $update); | |
// Clear cache to populate the PCC site in views. | |
$module_handler = \Drupal::service('module_handler'); | |
$views_data = \Drupal::service('views.views_data'); | |
$cache_discovery = \Drupal::service('cache.discovery'); | |
if ($module_handler->moduleExists('views')) { | |
$views_data->clear(); | |
$cache_discovery->delete('views:wizard'); | |
} |
src/PccSiteViewHelper.php
Outdated
* @return array|null | ||
* Returns array of Entity attributes. |
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.
Update the return type in the docblock to reflect the actual return type.
- * @return array|null
+ * @return array
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
* @return array|null | |
* Returns array of Entity attributes. | |
* @return array | |
* Returns array of Entity attributes. |
pcx_connect.views.inc
Outdated
'title' => t('Content'), | ||
'help' => t('Article Content'), |
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.
Replace the t()
function with \Drupal::translation()->translate()
for better performance.
- $table['content'] = [
- 'title' => t('Content'),
- 'help' => t('Article Content'),
- 'field' => [
- 'id' => 'standard',
- 'click sortable' => FALSE,
- ],
- 'filter' => [
- 'id' => 'string',
- ],
- ];
+ $table['content'] = [
+ 'title' => \Drupal::translation()->translate('Content'),
+ 'help' => \Drupal::translation()->translate('Article Content'),
+ 'field' => [
+ 'id' => 'standard',
+ 'click sortable' => FALSE,
+ ],
+ 'filter' => [
+ 'id' => 'string',
+ ],
+ ];
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
'title' => t('Content'), | |
'help' => t('Article Content'), | |
'title' => \Drupal::translation()->translate('Content'), | |
'help' => \Drupal::translation()->translate('Article Content'), |
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 (3)
- pcx_connect.views.inc (1 hunks)
- src/Entity/PccSite.php (3 hunks)
- src/PccSiteViewHelper.php (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- pcx_connect.views.inc
- src/Entity/PccSite.php
- src/PccSiteViewHelper.php
Fixes - https://digitalpolygon.atlassian.net/browse/PCC-59
Things covered:
PccSiteViewHelper.php
helper class to get pcc entity related data.Summary by CodeRabbit
New Features
Improvements
ApiStatusController
class.PccSite
entity to ensure up-to-date views.Bug Fixes
ApiStatusController
class documentation.These updates aim to improve the functionality and maintainability of PCC site views and API status handling.