Example #1
0
 /**
  * {@inheritdoc}
  */
 public function routes()
 {
     $route_collection = new RouteCollection();
     // Get all entity types.
     $eck_types = EckEntityType::loadMultiple();
     foreach ($eck_types as $eck_type) {
         // Route for list.
         $route_list = new Route('admin/structure/eck/entity/' . $eck_type->id, array('_entity_list' => $eck_type->id, '_title' => $eck_type->label . 'list'), array('_permission' => 'view eck entity'));
         // Add the route.
         $route_collection->add('eck.entity.' . $eck_type->id . '.list', $route_list);
         // Route for type list.
         $route_type_list = new Route('admin/structure/eck/entity/' . $eck_type->id . '/types', array('_controller' => '\\Drupal\\Core\\Entity\\Controller\\EntityListController::listing', 'entity_type' => $eck_type->id . '_type', '_title' => $eck_type->label . 'types'), array('_permission' => 'administer eck entity bundles'));
         // Add the route.
         $route_collection->add('eck.entity.' . $eck_type->id . '_type.list', $route_type_list);
         // Route for type add.
         $route_type_add = new Route('admin/structure/eck/entity/' . $eck_type->id . '/types/add', array('_entity_form' => $eck_type->id . '_type.add', '_title' => $eck_type->label . 'type'), array('_permission' => 'administer eck entity bundles'));
         // Add the route.
         $route_collection->add('eck.entity.' . $eck_type->id . '_type.add', $route_type_add);
         // Route for type edit.
         $route_type_edit = new Route('admin/structure/eck/entity/' . $eck_type->id . '/types/manage/{' . $eck_type->id . '_type}', array('_entity_form' => $eck_type->id . '_type.edit', '_title' => 'Edit' . $eck_type->label . 'type'), array('_permission' => 'administer eck entity bundles'));
         // Add the route.
         $route_collection->add('entity.' . $eck_type->id . '_type.edit_form', $route_type_edit);
         // Route for type delete.
         $route_type_delete = new Route('admin/structure/eck/entity/' . $eck_type->id . '/types/manage/{' . $eck_type->id . '_type}/delete', array('_entity_form' => $eck_type->id . '_type.delete', '_title' => 'Delete' . $eck_type->label . 'type'), array('_permission' => 'administer eck entity bundles'));
         // Add the route.
         $route_collection->add('entity.' . $eck_type->id . '_type.delete_form', $route_type_delete);
     }
     return $route_collection;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getRoutes(EntityTypeInterface $entity_type)
 {
     $route_collection = new RouteCollection();
     // Get all entity types.
     $eck_types = EckEntityType::loadMultiple();
     foreach ($eck_types as $eck_type) {
         $t_args = array('@entity' => $eck_type->label);
         // Route for view.
         $route_view = (new Route('admin/structure/eck/entity/' . $eck_type->id . '/{' . $eck_type->id . '}'))->addDefaults(array('_entity_view' => $eck_type->id, '_title' => $eck_type->label))->setRequirement('_entity_access', $eck_type->id . '.view');
         // Add the route.
         $route_collection->add('entity.' . $eck_type->id . '.canonical', $route_view);
         // Route for edit.
         $route_edit = new Route('admin/structure/eck/entity/' . $eck_type->id . '/{' . $eck_type->id . '}/edit', array('_entity_form' => $eck_type->id . '.edit', '_title' => 'Edit' . $eck_type->label), array('_entity_access' => $eck_type->id . '.edit'));
         // Add the route.
         $route_collection->add('entity.' . $eck_type->id . '.edit_form', $route_edit);
         // Route for delete.
         $route_delete = new Route('admin/structure/eck/entity/' . $eck_type->id . '/{' . $eck_type->id . '}/delete', array('_entity_form' => $eck_type->id . '.delete', '_title' => 'Delete' . $eck_type->label), array('_entity_access' => $eck_type->id . '.delete'));
         // Add the route.
         $route_collection->add('entity.' . $eck_type->id . '.delete_form', $route_delete);
         return $route_collection;
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public static function load($id)
 {
     // Because we use a single class for multiple entity bundles we need to
     // parse all entity types and find the id.
     $entity_manager = \Drupal::entityManager();
     $loaded_entity = NULL;
     foreach (EckEntityType::loadMultiple() as $entity) {
         $load = $entity_manager->getStorage($entity->id() . '_type')->load($id);
         $loaded_entity = empty($load) ? $loaded_entity : $load;
     }
     return $loaded_entity;
 }