Commit 2fadd3c6 authored by Joshua Sedler's avatar Joshua Sedler 🤸🏼
Browse files

Issue #3247102 by apaderno: Implement dashboards page routing logic

parent 3f4f4685
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -19,12 +19,12 @@ homebox.homebox.*:
      sequence:
        type: string
        label: 'Role'
    options:
      type: sequence
      label: 'Visibility'
      sequence:
        type: string
        label: 'Option'
    dashboardPageEnabled:
      type: int:tiny
      label: 'Dashboard Page Enabled'
    dashboardUserTabEnabled:
      type: int:tiny
      label: 'Dashboard User Tab Enabled'
    blocks:
      type: sequence
      label: 'Blocks'
@@ -41,9 +41,6 @@ homebox.homebox.*:
            type: string
          status:
            type: boolean
    columns:
      type: sequence
      label: 'Columns'
      sequence:
    layoutId:
      type: string
        label: 'Columns'
 No newline at end of file
      label: 'Layout Id'
+26 −0
Original line number Diff line number Diff line
@@ -16,3 +16,29 @@ function homebox_update_8100() {
  \Drupal::service('module_installer')
    ->install(['jquery_ui', 'jquery_ui_draggable', 'jquery_ui_droppable']);
}

function homebox_update_8101() {
  // @todo Homebox.php
  // Renamed "$columns" to "$layoutId"
  // Removed "$options"
  // Remove "$path"
  // @todo routing.yml
  // Removed homebox.page
  // @todo schema.yml
  // Delete "options"
  //
  // Change:
  // columns:
  //  type: sequence
  //  label: 'Columns'
  //  sequence:
  //    type: string
  //    label: 'Columns'
  //
  // To:
  // layoutId:
  //   type: string
  //   label: 'Layout Id'


}
+2 −20
Original line number Diff line number Diff line
@@ -5,8 +5,6 @@
 * Homebox module hooks.
 */

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Routing\RouteMatchInterface;

/**
@@ -46,22 +44,6 @@ function homebox_theme() {
  ];
}

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function homebox_homebox_insert(EntityInterface $entity) {
  // @todo Check for existing aliases with the same alias name.
  /** @var \Drupal\homebox\Entity\Homebox $path_entity */
  $path_entity = $entity;
  $path_alias = \Drupal::entityTypeManager()->getStorage('path_alias')->create([
    'path' => '/homebox-page/' . $entity->id() . '/' . \Drupal::currentUser()->id(),
    'alias' => '/' . $path_entity->getPath(),
    'langcode' => Language::LANGCODE_SITE_DEFAULT,
  ]);

  $path_alias->save();
}

/**
 * Implements hook_local_tasks_alter().
 *
@@ -74,11 +56,11 @@ function homebox_local_tasks_alter(&$local_tasks) {
  $homeboxes = $homebox_storage->loadMultiple();
  /** @var \Drupal\homebox\Entity\HomeboxInterface $homebox */
  foreach ($homeboxes as $homebox) {
    if ($homebox->getOptions()['menu']) {
    if ($homebox->getDashboardUserTabEnabled()) {
      $local_tasks['homebox.user_profile.layout.' . $homebox->id()] = [
        'id' => 'homebox.user_profile.layout.' . $homebox->id(),
        'title' => $homebox->label(),
        'route_name' => 'homebox.page',
        'route_name' => 'homebox.dashboard_user_tab',
        'base_route' => 'entity.user.canonical',
        'weight' => -100,
        'route_parameters' => ['homebox' => $homebox->id()],
+13 −2
Original line number Diff line number Diff line
use homebox:
  title: 'Use Homebox'
  description: 'Allows to restrict Homebox access in general. If enabled, individual homebox roles can be set in each Homebox.'
# TODO: Introduce in 2.0.0-alpha1: [#3264925]
#edit own homebox:
#  title: 'Edit own homeboxes'
#  description: 'Allows to configure own Homeboxes. If disabled, the Homebox default can not be changed by the user.'
bypass homeboxes access:
  title: 'Bypass Homebox access control'
  description: 'View and configure all Homeboxes regardless of permission restrictions. Also allows to access other users Homeboxes.'
  restrict access: TRUE
administer homebox:
  title: 'Administer Homebox'
  description: 'Allows access to configure Homebox.'
  restrict access: true
  description: 'Allows access to configure Homebox settings via settings page.'
  restrict access: TRUE
+34 −4
Original line number Diff line number Diff line
homebox.page:
  path: '/homebox-page/{homebox}/{user}'
homebox.dashboard_page.default:
  path: '/homebox/{homebox}'
  defaults:
    _form: '\Drupal\homebox\Form\HomeboxPageForm'
    _form: '\Drupal\homebox\Form\HomeboxDashboardPageForm'
  requirements:
    _custom_access: '\Drupal\homebox\Controller\HomeboxController::access'
    _custom_access: '\Drupal\homebox\Controller\HomeboxController::accessDashboardPage'
  options:
    parameters:
      homebox:
        type: entity:homebox

homebox.dashboard_page:
  path: '/homebox/{homebox}/{user}'
  defaults:
    _form: '\Drupal\homebox\Form\HomeboxDashboardPageForm'
  requirements:
    _custom_access: '\Drupal\homebox\Controller\HomeboxController::accessDashboardPage'
  options:
    parameters:
      homebox:
        type: entity:homebox
      user:
        type: entity:user

homebox.dashboard_user_tab:
  path: '/user/{user}/homebox/{homebox}'
  defaults:
    _form: '\Drupal\homebox\Form\HomeboxDashboardUserTabForm'
  requirements:
    _custom_access: '\Drupal\homebox\Controller\HomeboxController::accessDashboardUserTab'
  options:
    parameters:
      homebox:
        type: entity:homebox
      user:
        type: entity:user

homebox.settings_form:
  path: '/admin/structure/homebox/{homebox}/settings'
Loading