diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 4d39d05..293e560 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -8,24 +8,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse; /** - * Menu callback; Listing of all current image styles. - */ -function image_style_list() { - $page = array(); - - $styles = entity_load_multiple('image_style'); - $page['image_style_list'] = array( - '#markup' => theme('image_style_list', array('styles' => $styles)), - '#attached' => array( - 'css' => array(drupal_get_path('module', 'image') . '/css/image.admin.css' => array()), - ), - ); - - return $page; - -} - -/** * Form builder; Edit an image style name and effects order. * * @param $form_state @@ -502,55 +484,6 @@ function image_rotate_form($data) { } /** - * Returns HTML for the page containing the list of image styles. - * - * @param $variables - * An associative array containing: - * - styles: An array of all the image styles returned by image_get_styles(). - * - * @see image_get_styles() - * @ingroup themeable - */ -function theme_image_style_list($variables) { - $styles = $variables['styles']; - - $header = array(t('Style name'), t('Operations')); - $rows = array(); - - foreach ($styles as $style) { - $row = array(); - $row[] = l($style->label(), 'admin/config/media/image-styles/manage/' . $style->id()); - $links = array(); - $links['edit'] = array( - 'title' => t('edit'), - 'href' => 'admin/config/media/image-styles/manage/' . $style->id(), - 'class' => array('image-style-link'), - ); - $links['delete'] = array( - 'title' => t('delete'), - 'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/delete', - 'class' => array('image-style-link'), - ); - $row[] = array( - 'data' => array( - '#type' => 'operations', - '#links' => $links, - ), - ); - $rows[] = $row; - } - - if (empty($rows)) { - $rows[] = array(array( - 'colspan' => 4, - 'data' => t('There are currently no styles. Add a new one.', array('!url' => url('admin/config/media/image-styles/add'))), - )); - } - - return theme('table', array('header' => $header, 'rows' => $rows)); -} - -/** * Returns HTML for a listing of the effects within a specific image style. * * @param $variables diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 53cb813..6ab3d12 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -122,17 +122,12 @@ function image_menu() { $items['admin/config/media/image-styles'] = array( 'title' => 'Image styles', 'description' => 'Configure styles that can be used for resizing or adjusting images on display.', - 'page callback' => 'image_style_list', - 'access arguments' => array('administer image styles'), - 'file' => 'image.admin.inc', + 'route_name' => 'image_style_list', ); $items['admin/config/media/image-styles/list'] = array( 'title' => 'List', 'description' => 'List the current image styles on the site.', - 'page callback' => 'image_style_list', - 'access arguments' => array('administer image styles'), 'type' => MENU_DEFAULT_LOCAL_TASK, - 'file' => 'image.admin.inc', ); $items['admin/config/media/image-styles/add'] = array( 'title' => 'Add style', @@ -212,9 +207,6 @@ function image_theme() { ), // Theme functions in image.admin.inc. - 'image_style_list' => array( - 'variables' => array('styles' => NULL), - ), 'image_style_effects' => array( 'render element' => 'form', ), diff --git a/core/modules/image/image.routing.yml b/core/modules/image/image.routing.yml index b178d33..917c33b 100644 --- a/core/modules/image/image.routing.yml +++ b/core/modules/image/image.routing.yml @@ -11,3 +11,10 @@ image_effect_delete: _form: '\Drupal\image\Form\ImageEffectDeleteForm' requirements: _permission: 'administer image styles' + +image_style_list: + pattern: '/admin/config/media/image-styles' + defaults: + _entity_list: 'image_style' + requirements: + _permission: 'administer image styles' diff --git a/core/modules/image/lib/Drupal/image/ImageStyleListController.php b/core/modules/image/lib/Drupal/image/ImageStyleListController.php new file mode 100644 index 0000000..61ff6e4 --- /dev/null +++ b/core/modules/image/lib/Drupal/image/ImageStyleListController.php @@ -0,0 +1,94 @@ +urlGenerator = $url_generator; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { + return new static( + $entity_type, + $entity_info, + $container->get('plugin.manager.entity')->getStorageController($entity_type), + $container->get('module_handler'), + $container->get('url_generator') + ); + } + + /** + * {@inheritdoc} + */ + public function buildHeader() { + $row = parent::buildHeader(); + unset($row['id']); + $row['label'] = t('Style name'); + return $row; + } + + /** + * {@inheritdoc} + */ + public function buildRow(EntityInterface $entity) { + $row = parent::buildRow($entity); + unset($row['id']); + $row['label'] = String::checkPlain($entity->label()); + return $row; + } + + /** + * {@inheritdoc} + */ + public function render() { + $build = parent::render(); + $build['#empty'] = t('There are currently no styles. Add a new one.', array( + '!url' => $this->urlGenerator->generateFromPath('admin/config/media/image-styles/add'), + )); + return $build; + } + +} diff --git a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php index c377781..5ba4fe0 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php @@ -24,7 +24,8 @@ * "form" = { * "delete" = "Drupal\image\Form\ImageStyleDeleteForm" * }, - * "storage" = "Drupal\image\ImageStyleStorageController" + * "storage" = "Drupal\image\ImageStyleStorageController", + * "list" = "Drupal\image\ImageStyleListController" * }, * uri_callback = "image_style_entity_uri", * config_prefix = "image.style",