From 8a0fb3c0f2477f32e41b7dc5295b33e9634e2c6e Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Mon, 18 Jul 2016 10:22:56 -0500 Subject: [PATCH] Change module name to islandora, add default fedora_resource_type --- ...ra.fedora_resource_type.non_rdf_source.yml | 4 ++ ...andora.fedora_resource_type.rdf_source.yml | 4 ++ config/schema/fedora_resource_type.schema.yml | 7 ++- islandoraclaw.info.yml => islandora.info.yml | 0 ...s.action.yml => islandora.links.action.yml | 1 + ...links.menu.yml => islandora.links.menu.yml | 2 +- ...links.task.yml => islandora.links.task.yml | 0 islandoraclaw.module => islandora.module | 12 ++-- ...rmissions.yml => islandora.permissions.yml | 7 +++ islandora.routing.yml | 19 ++++++ .../FedoraResourceAddController.php | 4 +- src/Entity/FedoraResource.php | 60 +++++++++++++++---- src/Entity/FedoraResourceType.php | 28 ++++++--- src/Entity/FedoraResourceViewsData.php | 2 +- src/FedoraResource.php | 22 ------- src/FedoraResourceAccessControlHandler.php | 6 +- src/FedoraResourceHtmlRouteProvider.php | 10 ++-- src/FedoraResourceInterface.php | 45 ++++++++++++-- src/FedoraResourceListBuilder.php | 29 +++++---- src/FedoraResourceTypeHtmlRouteProvider.php | 2 +- src/FedoraResourceTypeInterface.php | 7 ++- src/FedoraResourceTypeListBuilder.php | 4 +- src/Form/FedoraResourceDeleteForm.php | 4 +- src/Form/FedoraResourceForm.php | 6 +- src/Form/FedoraResourceSettingsForm.php | 6 +- src/Form/FedoraResourceTypeDeleteForm.php | 2 +- src/Form/FedoraResourceTypeForm.php | 15 ++++- src/Plugin/Search/FedoraEntitySearch.php | 12 ++-- 28 files changed, 219 insertions(+), 101 deletions(-) create mode 100644 config/install/islandora.fedora_resource_type.non_rdf_source.yml create mode 100644 config/install/islandora.fedora_resource_type.rdf_source.yml rename islandoraclaw.info.yml => islandora.info.yml (100%) rename islandoraclaw.links.action.yml => islandora.links.action.yml (99%) rename islandoraclaw.links.menu.yml => islandora.links.menu.yml (92%) rename islandoraclaw.links.task.yml => islandora.links.task.yml (100%) rename islandoraclaw.module => islandora.module (80%) rename islandoraclaw.permissions.yml => islandora.permissions.yml (69%) create mode 100644 islandora.routing.yml delete mode 100644 src/FedoraResource.php diff --git a/config/install/islandora.fedora_resource_type.non_rdf_source.yml b/config/install/islandora.fedora_resource_type.non_rdf_source.yml new file mode 100644 index 00000000..245224d3 --- /dev/null +++ b/config/install/islandora.fedora_resource_type.non_rdf_source.yml @@ -0,0 +1,4 @@ +langcode: en +id: non_rdf_source +label: 'Non RDF Source' +rdf_type: fedora:Binary \ No newline at end of file diff --git a/config/install/islandora.fedora_resource_type.rdf_source.yml b/config/install/islandora.fedora_resource_type.rdf_source.yml new file mode 100644 index 00000000..e6421392 --- /dev/null +++ b/config/install/islandora.fedora_resource_type.rdf_source.yml @@ -0,0 +1,4 @@ +langcode: en +id: rdf_source +label: 'RDF Source' +rdf_type: fedora:Resource \ No newline at end of file diff --git a/config/schema/fedora_resource_type.schema.yml b/config/schema/fedora_resource_type.schema.yml index ec754ca3..e07cefa3 100644 --- a/config/schema/fedora_resource_type.schema.yml +++ b/config/schema/fedora_resource_type.schema.yml @@ -1,4 +1,4 @@ -islandoraclaw.fedora_resource_type.*: +islandora.fedora_resource_type.*: type: config_entity label: 'Fedora resource type config' mapping: @@ -10,8 +10,11 @@ islandoraclaw.fedora_resource_type.*: label: 'Label' uuid: type: string + rdf_type: + type: label + label: 'RDF type' -# Plugin \Drupal\islandoraclaw\Plugin\Search\FedoraResourceSearch +# Plugin \Drupal\islandora\Plugin\Search\FedoraResourceSearch search.plugin.node_search: type: mapping label: 'Fedora Resource search' diff --git a/islandoraclaw.info.yml b/islandora.info.yml similarity index 100% rename from islandoraclaw.info.yml rename to islandora.info.yml diff --git a/islandoraclaw.links.action.yml b/islandora.links.action.yml similarity index 99% rename from islandoraclaw.links.action.yml rename to islandora.links.action.yml index 2666c978..38d9833a 100644 --- a/islandoraclaw.links.action.yml +++ b/islandora.links.action.yml @@ -3,6 +3,7 @@ entity.fedora_resource.add_form: title: 'Add Fedora resource' appears_on: - entity.fedora_resource.collection + entity.fedora_resource_type.add_form: route_name: 'entity.fedora_resource_type.add_form' title: 'Add Fedora resource type' diff --git a/islandoraclaw.links.menu.yml b/islandora.links.menu.yml similarity index 92% rename from islandoraclaw.links.menu.yml rename to islandora.links.menu.yml index dbd6cdad..4c4ed548 100644 --- a/islandoraclaw.links.menu.yml +++ b/islandora.links.menu.yml @@ -8,7 +8,7 @@ entity.fedora_resource.collection: # Fedora resource type menu items definition entity.fedora_resource_type.collection: - title: 'Fedora resource type' + title: 'Fedora resource type list' route_name: entity.fedora_resource_type.collection description: 'List Fedora resource type (bundles)' parent: system.admin_structure diff --git a/islandoraclaw.links.task.yml b/islandora.links.task.yml similarity index 100% rename from islandoraclaw.links.task.yml rename to islandora.links.task.yml diff --git a/islandoraclaw.module b/islandora.module similarity index 80% rename from islandoraclaw.module rename to islandora.module index dc8c0b58..d858608d 100644 --- a/islandoraclaw.module +++ b/islandora.module @@ -2,7 +2,7 @@ /** * @file - * Contains islandoraclaw.module.. + * Contains islandora.module.. */ use Drupal\Core\Routing\RouteMatchInterface; @@ -10,10 +10,10 @@ use Drupal\Core\Routing\RouteMatchInterface; /** * Implements hook_help(). */ -function islandoraclaw_help($route_name, RouteMatchInterface $route_match) { +function islandora_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { - // Main module help for the islandoraclaw module. - case 'help.page.islandoraclaw': + // Main module help for the islandora module. + case 'help.page.islandora': $output = ''; $output .= '

' . t('About') . '

'; $output .= '

' . t('') . '

'; @@ -26,7 +26,7 @@ function islandoraclaw_help($route_name, RouteMatchInterface $route_match) { /** * Implements hook_theme(). */ -function islandoraclaw_theme() { +function islandora_theme() { $theme = []; $theme['fedora_resource'] = [ 'render element' => 'elements', @@ -44,7 +44,7 @@ function islandoraclaw_theme() { /** * Implements hook_theme_suggestions_HOOK(). */ -function islandoraclaw_theme_suggestions_fedora_resource(array $variables) { +function islandora_theme_suggestions_fedora_resource(array $variables) { $suggestions = array(); $entity = $variables['elements']['#fedora_resource']; $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_'); diff --git a/islandoraclaw.permissions.yml b/islandora.permissions.yml similarity index 69% rename from islandoraclaw.permissions.yml rename to islandora.permissions.yml index 607d85c0..d5b5fb4e 100644 --- a/islandoraclaw.permissions.yml +++ b/islandora.permissions.yml @@ -1,3 +1,4 @@ +# Fedora Resource permissions add fedora resource entities: title: 'Create new Fedora resource entities' @@ -17,3 +18,9 @@ view published fedora resource entities: view unpublished fedora resource entities: title: 'View unpublished Fedora resource entities' + +# Fedora Resource Type permissions +administer fedora resource type entities: + title: 'Administer Fedora Resource Type entities' + description: 'Allow to access administration of Fedora Resource Type entities (bundles).' + restrict access: true \ No newline at end of file diff --git a/islandora.routing.yml b/islandora.routing.yml new file mode 100644 index 00000000..ef85e8a3 --- /dev/null +++ b/islandora.routing.yml @@ -0,0 +1,19 @@ +entity.fedora_resource.collection: + path: '/admin/structure/fedora_resource' + defaults: + _entity_list: 'fedora_resource' + _title: 'Fedora Resource' + requirements: + _permission: 'administer fedora resource entities' + options: + _admin_route: true + +entity.fedora_resource_type.collection: + path: '/admin/structure/fedora_resource_type' + defaults: + _entity_list: 'fedora_resource_type' + _title: 'Fedora Resource Type' + requirements: + _permission: 'administer fedora resource type entities' + options: + _admin_route: true diff --git a/src/Controller/FedoraResourceAddController.php b/src/Controller/FedoraResourceAddController.php index 5314661d..700f3aba 100644 --- a/src/Controller/FedoraResourceAddController.php +++ b/src/Controller/FedoraResourceAddController.php @@ -1,6 +1,6 @@ get('fedora_has_parent') !== null); + } + + /** + * {@inheritdoc} + */ + public function getParent() + { + return $this->get('fedora_has_parent')->getEntity(); + } + + /** + * {@inheritdoc} + */ + public function getParentId() + { + return $this->get('fedora_has_parent')->getEntity()->id(); + } + + /** + * {@inheritdoc} + */ + public function setParent(EntityTypeInterface $entity) + { + $this->set('fedora_has_parent', $entity); + return $this; + } + /** * Default value callback for 'fedora_has_parent' base field definition. * @@ -238,7 +272,7 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac ->setRevisionable(TRUE) ->setSetting('target_type', 'fedora_resource') ->setSetting('handler', 'default') - ->setDefaultValueCallback('Drupal\islandoraClaw\Entity\FedoraResource::getFedoraRoot') + ->setDefaultValueCallback('Drupal\islandora\Entity\FedoraResource::getFedoraRoot') ->setTranslatable(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', @@ -258,7 +292,7 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); - $fields['ldp_containes'] = BaseFieldDefinition::create('entity_reference') + $fields['ldp_contains'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('LDP Contains')) ->setDescription(t('Contains Fedora Resource.')) ->setRevisionable(TRUE) diff --git a/src/Entity/FedoraResourceType.php b/src/Entity/FedoraResourceType.php index fc81fc36..4303f59c 100644 --- a/src/Entity/FedoraResourceType.php +++ b/src/Entity/FedoraResourceType.php @@ -1,9 +1,9 @@ rdf_type; + } } diff --git a/src/Entity/FedoraResourceViewsData.php b/src/Entity/FedoraResourceViewsData.php index 3601ac66..eb0209a2 100644 --- a/src/Entity/FedoraResourceViewsData.php +++ b/src/Entity/FedoraResourceViewsData.php @@ -1,6 +1,6 @@ isPublished()) { diff --git a/src/FedoraResourceHtmlRouteProvider.php b/src/FedoraResourceHtmlRouteProvider.php index 865312a4..958958fe 100644 --- a/src/FedoraResourceHtmlRouteProvider.php +++ b/src/FedoraResourceHtmlRouteProvider.php @@ -1,6 +1,6 @@ setDefaults([ - '_controller' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::addForm', - '_title_callback' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::getAddFormTitle', + '_controller' => 'Drupal\islandora\Controller\FedoraResourceAddController::addForm', + '_title_callback' => 'Drupal\islandora\Controller\FedoraResourceAddController::getAddFormTitle', ]) ->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}'); $parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id]; @@ -113,7 +113,7 @@ class FedoraResourceHtmlRouteProvider extends AdminHtmlRouteProvider { $route = new Route("/admin/structure/{$entity_type->id()}/add"); $route ->setDefaults([ - '_controller' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::add', + '_controller' => 'Drupal\islandora\Controller\FedoraResourceAddController::add', '_title' => "Add {$entity_type->getLabel()}", ]) ->setRequirement('_entity_create_access', $entity_type->id()) @@ -136,7 +136,7 @@ class FedoraResourceHtmlRouteProvider extends AdminHtmlRouteProvider { $route = new Route("/admin/structure/{$entity_type->id()}/settings"); $route ->setDefaults([ - '_form' => 'Drupal\islandoraclaw\Form\FedoraResourceSettingsForm', + '_form' => 'Drupal\islandora\Form\FedoraResourceSettingsForm', '_title' => "{$entity_type->getLabel()} settings", ]) ->setRequirement('_permission', $entity_type->getAdminPermission()) diff --git a/src/FedoraResourceInterface.php b/src/FedoraResourceInterface.php index 7a6ff42f..0270d825 100644 --- a/src/FedoraResourceInterface.php +++ b/src/FedoraResourceInterface.php @@ -1,15 +1,16 @@ t('Fedora resource ID'); $header['name'] = $this->t('Name'); + $header['parent'] = $this->t('Parent'); return $header + parent::buildHeader(); } @@ -29,16 +27,21 @@ class FedoraResourceListBuilder extends EntityListBuilder { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - /* @var $entity \Drupal\islandoraclaw\Entity\FedoraResource */ + /* @var $entity \Drupal\islandora\Entity\FedoraResource */ $row['id'] = $entity->id(); - $row['name'] = $this->l( + $row['name'] = Link::fromTextAndUrl( $entity->label(), - new Url( - 'entity.fedora_resource.edit_form', array( - 'fedora_resource' => $entity->id(), - ) - ) + $entity->toUrl() ); + if ($entity->hasParent()) { + $row['parent'] = Link::fromTextAndUrl( + $entity->getParent()->label(), + $entity->getParent()->toUrl() + ); + } + else { + $row['parent'] = $this->t("n/a"); + } return $row + parent::buildRow($entity); } diff --git a/src/FedoraResourceTypeHtmlRouteProvider.php b/src/FedoraResourceTypeHtmlRouteProvider.php index ec66688a..cee288c9 100644 --- a/src/FedoraResourceTypeHtmlRouteProvider.php +++ b/src/FedoraResourceTypeHtmlRouteProvider.php @@ -1,6 +1,6 @@ t('Fedora resource type'); $header['id'] = $this->t('Machine name'); + $header['rdf_type'] = $this->t('RDF Type'); return $header + parent::buildHeader(); } @@ -25,6 +26,7 @@ class FedoraResourceTypeListBuilder extends ConfigEntityListBuilder { public function buildRow(EntityInterface $entity) { $row['label'] = $entity->label(); $row['id'] = $entity->id(); + $row['rdf_type'] = $entity->getRdfType(); // You probably want a few more properties here... return $row + parent::buildRow($entity); } diff --git a/src/Form/FedoraResourceDeleteForm.php b/src/Form/FedoraResourceDeleteForm.php index 5092667e..4573827b 100644 --- a/src/Form/FedoraResourceDeleteForm.php +++ b/src/Form/FedoraResourceDeleteForm.php @@ -1,13 +1,13 @@ entity; diff --git a/src/Form/FedoraResourceSettingsForm.php b/src/Form/FedoraResourceSettingsForm.php index ccc324a8..70b075cc 100644 --- a/src/Form/FedoraResourceSettingsForm.php +++ b/src/Form/FedoraResourceSettingsForm.php @@ -1,6 +1,6 @@ 'machine_name', '#default_value' => $fedora_resource_type->id(), '#machine_name' => array( - 'exists' => '\Drupal\islandoraclaw\Entity\FedoraResourceType::load', + 'exists' => '\Drupal\islandora\Entity\FedoraResourceType::load', ), '#disabled' => !$fedora_resource_type->isNew(), ); + $form['rdf_type'] = array( + '#type' => 'textfield', + '#title' => $this->t('RDF Type'), + '#maxlength' => 255, + '#default_value' => $fedora_resource_type->getRdfType(), + '#description' => $this->t('Base RDF type for this entity'), + '#required' => TRUE, + ); + /* You will need additional form elements for your custom properties. */ return $form; diff --git a/src/Plugin/Search/FedoraEntitySearch.php b/src/Plugin/Search/FedoraEntitySearch.php index 2b3c56a7..42084256 100644 --- a/src/Plugin/Search/FedoraEntitySearch.php +++ b/src/Plugin/Search/FedoraEntitySearch.php @@ -1,10 +1,10 @@ entityManager->getStorage('fedora_resource'); $entity_render = $this->entityManager->getViewBuilder('fedora_resource'); @@ -498,7 +498,7 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces } // 'fedora_resource' comes from the entity type id declared - // in the annotation for \Drupal\islandoraclaw\Entity\FedoraResource. + // in the annotation for \Drupal\islandora\Entity\FedoraResource. // Replace this with your entity's type id. $entity_storage = $this->entityManager->getStorage('fedora_resource');