diff --git a/lib/Drupal/profile2/ProfileTypeListController.php b/lib/Drupal/profile2/ProfileTypeListController.php
new file mode 100644
index 0000000..879b81c
--- /dev/null
+++ b/lib/Drupal/profile2/ProfileTypeListController.php
@@ -0,0 +1,42 @@
+uri();
+ $operations['manage-fields'] = array(
+ 'title' => t('manage fields'),
+ 'href' => $uri['path'] . '/fields',
+ 'options' => $uri['options'],
+ 'weight' => 11,
+ );
+ $operations['manage-display'] = array(
+ 'title' => t('manage display'),
+ 'href' => $uri['path'] . '/display',
+ 'options' => $uri['options'],
+ 'weight' => 12,
+ );
+ }
+
+ return $operations;
+ }
+}
diff --git a/profile2.module b/profile2.module
index 90132bf..aedd35f 100644
--- a/profile2.module
+++ b/profile2.module
@@ -68,7 +68,9 @@ function profile2_entity_info() {
$return['profile2_type'] = array(
'label' => t('Profile type'),
'entity class' => 'Drupal\profile2\ProfileType',
+ 'uri callback' => 'profile2_profile_type_uri',
'controller class' => 'Drupal\Core\Config\Entity\ConfigStorageController',
+ 'list controller class' => 'Drupal\profile2\ProfileTypeListController',
'form controller class' => array(
'default' => 'Drupal\profile2\ProfileTypeFormController',
),
@@ -96,6 +98,18 @@ function profile2_profile_uri(Profile $profile) {
}
/**
+ * Entity uri callback.
+ *
+ * @param Drupal\profile2\ProfileType $profile_type
+ * A profile type entity.
+ */
+function profile2_profile_type_uri(ProfileType $profile_type) {
+ return array(
+ 'path' => 'admin/structure/profiles/manage/' . $profile_type->id(),
+ );
+}
+
+/**
* Implements hook_menu().
*/
function profile2_menu() {
@@ -238,47 +252,8 @@ function profile2_menu_local_tasks_alter(&$data, $router_item, $root_path) {
* Page callback; Lists available ProfileType objects.
*/
function profile2_type_list_page() {
- $field_ui = module_exists('field_ui');
- $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => $field_ui ? 4 : 2));
- $rows = array();
- foreach (entity_load_multiple('profile2_type') as $type) {
- $row = array();
- $row['label'] = t('@label (Machine name: @type)', array(
- '@label' => $type->label(),
- '@type' => $type->id(),
- ));
- $row['edit']['data'] = array(
- '#type' => 'link',
- '#title' => t('edit'),
- '#href' => 'admin/structure/profiles/manage/' . $type->id(),
- );
- if ($field_ui) {
- $row['field-manage']['data'] = array(
- '#type' => 'link',
- '#title' => t('manage fields'),
- '#href' => 'admin/structure/profiles/manage/' . $type->id() . '/fields',
- );
- $row['field-display']['data'] = array(
- '#type' => 'link',
- '#title' => t('manage display'),
- '#href' => 'admin/structure/profiles/manage/' . $type->id() . '/display',
- );
- }
- $row['delete']['data'] = array(
- '#type' => 'link',
- '#title' => t('delete'),
- '#href' => 'admin/structure/profiles/manage/' . $type->id() . '/delete',
- );
- $rows[] = $row;
- }
-
- $build = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#empty' => t('No profile types available. Add profile type.', array('@link' => url('admin/structure/profiles/add'))),
- );
- return $build;
+ $controller = entity_list_controller('profile2_type');
+ return $controller->render();
}
/**