diff --git a/core/modules/grid/grid.admin.inc b/core/modules/grid/grid.admin.inc index 22d87d8..b71c511 100644 --- a/core/modules/grid/grid.admin.inc +++ b/core/modules/grid/grid.admin.inc @@ -5,7 +5,7 @@ * Administration functions to maintain a common set of grids. */ -use Drupal\grid\Grid; +use Drupal\grid\Plugin\Core\Entity\Grid; /** * Page callback: Presents list of grids. @@ -42,7 +42,7 @@ function grid_page_add() { * * @see grid_menu() */ -function grid_delete_confirm($form, &$form_state, Grid $grid) { +function grid_confirm_delete($form, &$form_state, Grid $grid) { // Always provide entity id in the same form key as in the entity edit form. $form['id'] = array('#type' => 'value', '#value' => $grid->id()); $form_state['grid'] = $grid; @@ -56,9 +56,9 @@ function grid_delete_confirm($form, &$form_state, Grid $grid) { } /** - * Form submission handler for grid_delete_confirm(). + * Form submission handler for grid_confirm_delete(). */ -function grid_delete_confirm_submit($form, &$form_state) { +function grid_confirm_delete_submit($form, &$form_state) { $grid = $form_state['grid']; $grid->delete(); drupal_set_message(t('Grid %label has been deleted.', array('%label' => $grid->label()))); diff --git a/core/modules/grid/grid.module b/core/modules/grid/grid.module index 6063c7f..c8f7aa7 100644 --- a/core/modules/grid/grid.module +++ b/core/modules/grid/grid.module @@ -5,13 +5,22 @@ * Pluggable grid system manager module. */ -use Drupal\grid\Grid; +use Drupal\grid\Plugin\Core\Entity\Grid; + +/** + * Implements hook_help(). + */ +function grid_help($path, $arg) { + switch($path) { + case 'admin/help#grid': + return '

' . t('Grids provide useful guides to place content on your pages. The grid module provides the ability to edit any type of grid and supports fluid and fixed equal column grids by itself. Extend with contributed modules for more grid types.') . '

'; + } +} /** * Implements hook_menu(). */ function grid_menu() { - $items = array(); $items['admin/structure/grids'] = array( 'title' => 'Grids', 'description' => 'Manage list of grids which can be used with layouts.', @@ -45,7 +54,7 @@ function grid_menu() { $items['admin/structure/grids/grid/%grid/delete'] = array( 'title' => 'Delete', 'page callback' => 'drupal_get_form', - 'page arguments' => array('grid_delete_confirm', 4), + 'page arguments' => array('grid_confirm_delete', 4), 'access callback' => 'user_access', 'access arguments' => array('administer grids'), 'type' => MENU_LOCAL_TASK, @@ -67,30 +76,6 @@ function grid_permission() { } /** - * Implements hook_entity_info(). - */ -function grid_entity_info() { - $types['grid'] = array( - 'label' => t('Grid'), - 'entity class' => 'Drupal\grid\Grid', - 'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController', - 'form controller class' => array( - 'default' => 'Drupal\grid\GridFormController', - ), - 'list controller class' => 'Drupal\Core\Config\Entity\ConfigEntityListController', - 'list path' => 'admin/structure/grids', - 'uri callback' => 'grid_uri', - 'config prefix' => 'grid', - 'entity keys' => array( - 'id' => 'id', - 'label' => 'label', - 'uuid' => 'uuid', - ), - ); - return $types; -} - -/** * Entity URI callback. * * @param Drupal\grid\Grid $grid diff --git a/core/modules/grid/lib/Drupal/grid/GridFormController.php b/core/modules/grid/lib/Drupal/grid/GridFormController.php index 96763d7..4aec9c5 100644 --- a/core/modules/grid/lib/Drupal/grid/GridFormController.php +++ b/core/modules/grid/lib/Drupal/grid/GridFormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\grid\Plugin\Core\Entity\Grid; /** * Form controller for the grid edit/add forms. @@ -51,9 +52,9 @@ public function form(array $form, array &$form_state, EntityInterface $grid) { ); $form['type'] = array( '#type' => 'value', - '#value' => $grid->type, + '#value' => $grid->type, ); - $form['options'] = $this->getPlugin()->form($form, $form_state, $grid->options); + $form['options'] = $this->getPlugin()->form($form, $form_state, $grid->options); return parent::form($form, $form_state, $grid); } @@ -62,7 +63,7 @@ public function form(array $form, array &$form_state, EntityInterface $grid) { * Overrides Drupal\Core\Entity\EntityFormController::validate(). */ public function validate(array $form, array &$form_state) { - $this->getPlugin()->validate($form, $form_state['values']['options']); + $this->getPlugin()->validate($form, $form_state['values']['options']); } /** diff --git a/core/modules/grid/lib/Drupal/grid/Plugin/Core/Entity/Grid.php b/core/modules/grid/lib/Drupal/grid/Plugin/Core/Entity/Grid.php index af122e5..355bda5 100644 --- a/core/modules/grid/lib/Drupal/grid/Plugin/Core/Entity/Grid.php +++ b/core/modules/grid/lib/Drupal/grid/Plugin/Core/Entity/Grid.php @@ -2,17 +2,35 @@ /** * @file - * Definition of Drupal\grid\Grid. + * Definition of Drupal\grid\Plugin\Core\Entity\Grid. */ -namespace Drupal\grid; +namespace Drupal\grid\Plugin\Core\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\grid\Plugin\GridInterface; /** - * Defines the grid entity. - */ + * Defines the grid entity class. + * + * @Plugin( + * id = "grid", + * label = @Translation("Grid"), + * module = "grid", + * controller_class = "Drupal\Core\Config\Entity\ConfigStorageController", + * form_controller_class = { + * "default" = "Drupal\grid\GridFormController", + * }, + * list_controller_class = "Drupal\Core\Config\Entity\ConfigEntityListController", + * list_path = "admin/structure/grids", + * uri_callback = "grid_uri", + * config_prefix = "grid", + * entity_keys = { + * "id" = "id", + * "label" = "label", + * "uuid" = "uuid", + * } + * ) */ class Grid extends ConfigEntityBase implements GridInterface { /**