diff -u b/last_visited_pages.install b/last_visited_pages.install --- b/last_visited_pages.install +++ b/last_visited_pages.install @@ -46,7 +46,7 @@ ], 'primary key' => ['id'], 'indexes' => [ - 'id' => ['id'] + 'id' => ['id'], ], ]; @@ -54,7 +54,7 @@ } /** - * Implements hook_uninstall() + * Implements hook_uninstall(). */ function last_visited_pages_uninstall() { \Drupal::database()->schema()->dropTable('last_visited_pages'); diff -u b/src/Form/LastVisitedPagesSettingsForm.php b/src/Form/LastVisitedPagesSettingsForm.php --- b/src/Form/LastVisitedPagesSettingsForm.php +++ b/src/Form/LastVisitedPagesSettingsForm.php @@ -7,7 +7,9 @@ use Drupal\Core\Form\FormStateInterface; /** - * Configures the Quantity of Last Visited Pages displayed for Last Visited Pages Block. + * Config the Quantity of Last Visited Pages displayed. + * + * For last Visited Pages Block. */ class LastVisitedPagesSettingsForm extends ConfigFormBase { diff -u b/src/LastVisitedPagesSubscriber.php b/src/LastVisitedPagesSubscriber.php --- b/src/LastVisitedPagesSubscriber.php +++ b/src/LastVisitedPagesSubscriber.php @@ -2,13 +2,12 @@ namespace Drupal\last_visited_pages; -use Drupal\Console\Bootstrap\Drupal; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; /** - * Subscribes to the kernel request event to completely obliterate the default content. + * Subscribes to the kernel request event to completely obliterate the content. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The event to process. @@ -23,7 +22,7 @@ */ public function checkForPlaces(GetResponseEvent $event) { // Grab the saved Last Visited Pages. - $places = \Drupal::state()->get('recent.places') ?: []; + \Drupal::state()->get('recent.places') ?: []; $request = \Drupal::request(); $route_match = \Drupal::routeMatch(); $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject()); @@ -41,19 +40,19 @@ $path = \Drupal::service('path.current')->getPath(); $uid = \Drupal::currentUser()->id(); - $file_insert_id = \Drupal::database()->insert('last_visited_pages') + \Drupal::database()->insert('last_visited_pages') ->fields([ - 'title', - 'path', - 'timestamp', - 'uid' - ]) + 'title', + 'path', + 'timestamp', + 'uid', + ]) ->values([ - $title, - $path, - REQUEST_TIME, - $uid - ]) + $title, + $path, + REQUEST_TIME, + $uid, + ]) ->execute(); $result_query_count = \Drupal::database()->select('last_visited_pages', 'n') diff -u b/src/Plugin/Block/LastVisitedPagesBlock.php b/src/Plugin/Block/LastVisitedPagesBlock.php --- b/src/Plugin/Block/LastVisitedPagesBlock.php +++ b/src/Plugin/Block/LastVisitedPagesBlock.php @@ -57,7 +57,7 @@ $last_visited_pages = ''; if (!empty($all_result)) { - foreach ($all_result as $key => $item) { + foreach ($all_result as $item) { $url = Url::fromUri('base:' . $item->path, ['absolute' => TRUE])->toString(); if ($item->title == '') { @@ -103,7 +103,7 @@ // Add a select box of numbers form 1 to $max_to_display. $form['block_num_places_form'] = [ '#type' => 'select', - '#title' => t('Number of items to show'), + '#title' => $this->t('Number of items to show'), '#default_value' => $default_places, '#options' => array_combine(range(1, $max_places), range(1, $max_places)), ]; @@ -128,14 +128,14 @@ '#type' => 'select', '#title' => $this->t('Date format'), '#options' => $date_formats, - '#default_value' => $this->configuration['date_format'] ?? 'medium' + '#default_value' => $this->configuration['date_format'] ?? 'medium', ]; $form['custom_date_format'] = [ '#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('See the documentation for PHP date formats.'), - '#default_value' => $this->configuration['custom_date_format'] ?? '' + '#default_value' => $this->configuration['custom_date_format'] ?? '', ]; $form['custom_date_format']['#states']['visible'][] = [ only in patch2: unchanged: --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Last Visited Pages ### Objective: -Last Visited Pages is a Module that Keep tracks of all the routes visited by a User, and provides Block Plugin to display Title, URL and Time each route was visited. +Last Visited Pages is a Module that Keep tracks of all the routes visited by a +User, and provides Block Plugin to display Title, URL and Time each route was +visited. ### Features: This Module will show Proficiency is following areas of Module Development. @@ -15,11 +17,13 @@ This Module will show Proficiency is following areas of Module Development. * Cache Invalidation ### Set Up: -1. To Setup, Like any Drupal 9 module Just Place the Module Files in Module Directory +1. To Setup, Like any Drupal 9 module Just Place the Module Files in Module + Directory 2. Enable the module "Last Visited Pages" through Extends Admin Tab -3. Once Enabled a block **Last Visited Pages** would be Available in the Block Layout. -4. Place the Block on the areas you wish you display recently visited places (ex: sidebar, footer) +3. Once Enabled a block **Last Visited Pages** would be Available in the Block + Layout. +4. Place the Block on the areas you wish you display recently visited places + (ex: sidebar, footer) 5. You can configure the blocks to show the number of results you wish to see. -6. Additionally the blocks could be configured from Drupal Configuration Page under the User Interface Header. - - +6. Additionally the blocks could be configured from Drupal Configuration Page + under the User Interface Header. only in patch2: unchanged: --- a/config/install/last_visited_pages.settings.yml +++ b/config/install/last_visited_pages.settings.yml @@ -1 +1 @@ -max_places: 10 \ No newline at end of file +max_places: 10 only in patch2: unchanged: --- a/last_visited_pages.info.yml +++ b/last_visited_pages.info.yml @@ -7,5 +7,3 @@ core_version_requirement: ^8 || ^9 configure : last_visited_pages.settings dependencies: - drupal:block - - only in patch2: unchanged: --- a/last_visited_pages.routing.yml +++ b/last_visited_pages.routing.yml @@ -4,4 +4,4 @@ last_visited_pages.settings: _form: '\Drupal\last_visited_pages\Form\LastVisitedPagesSettingsForm' _title: 'Last Visited Pages Settings' requirements: - _permission: 'administer site configuration' \ No newline at end of file + _permission: 'administer site configuration' only in patch2: unchanged: --- a/last_visited_pages.services.yml +++ b/last_visited_pages.services.yml @@ -2,4 +2,4 @@ services: last_visited_pages.recentplacessubscriber: class: Drupal\last_visited_pages\LastVisitedPagesSubscriber tags: - - { name: event_subscriber } \ No newline at end of file + - { name: event_subscriber }