Browse Source

Change module name to islandora, add default fedora_resource_type

pull/756/head
Jared Whiklo 9 years ago
parent
commit
8a0fb3c0f2
  1. 4
      config/install/islandora.fedora_resource_type.non_rdf_source.yml
  2. 4
      config/install/islandora.fedora_resource_type.rdf_source.yml
  3. 7
      config/schema/fedora_resource_type.schema.yml
  4. 0
      islandora.info.yml
  5. 1
      islandora.links.action.yml
  6. 2
      islandora.links.menu.yml
  7. 0
      islandora.links.task.yml
  8. 12
      islandora.module
  9. 7
      islandora.permissions.yml
  10. 19
      islandora.routing.yml
  11. 4
      src/Controller/FedoraResourceAddController.php
  12. 60
      src/Entity/FedoraResource.php
  13. 28
      src/Entity/FedoraResourceType.php
  14. 2
      src/Entity/FedoraResourceViewsData.php
  15. 22
      src/FedoraResource.php
  16. 6
      src/FedoraResourceAccessControlHandler.php
  17. 10
      src/FedoraResourceHtmlRouteProvider.php
  18. 45
      src/FedoraResourceInterface.php
  19. 29
      src/FedoraResourceListBuilder.php
  20. 2
      src/FedoraResourceTypeHtmlRouteProvider.php
  21. 7
      src/FedoraResourceTypeInterface.php
  22. 4
      src/FedoraResourceTypeListBuilder.php
  23. 4
      src/Form/FedoraResourceDeleteForm.php
  24. 6
      src/Form/FedoraResourceForm.php
  25. 6
      src/Form/FedoraResourceSettingsForm.php
  26. 2
      src/Form/FedoraResourceTypeDeleteForm.php
  27. 15
      src/Form/FedoraResourceTypeForm.php
  28. 12
      src/Plugin/Search/FedoraEntitySearch.php

4
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

4
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

7
config/schema/fedora_resource_type.schema.yml

@ -1,4 +1,4 @@
islandoraclaw.fedora_resource_type.*: islandora.fedora_resource_type.*:
type: config_entity type: config_entity
label: 'Fedora resource type config' label: 'Fedora resource type config'
mapping: mapping:
@ -10,8 +10,11 @@ islandoraclaw.fedora_resource_type.*:
label: 'Label' label: 'Label'
uuid: uuid:
type: string 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: search.plugin.node_search:
type: mapping type: mapping
label: 'Fedora Resource search' label: 'Fedora Resource search'

0
islandoraclaw.info.yml → islandora.info.yml

1
islandoraclaw.links.action.yml → islandora.links.action.yml

@ -3,6 +3,7 @@ entity.fedora_resource.add_form:
title: 'Add Fedora resource' title: 'Add Fedora resource'
appears_on: appears_on:
- entity.fedora_resource.collection - entity.fedora_resource.collection
entity.fedora_resource_type.add_form: entity.fedora_resource_type.add_form:
route_name: 'entity.fedora_resource_type.add_form' route_name: 'entity.fedora_resource_type.add_form'
title: 'Add Fedora resource type' title: 'Add Fedora resource type'

2
islandoraclaw.links.menu.yml → islandora.links.menu.yml

@ -8,7 +8,7 @@ entity.fedora_resource.collection:
# Fedora resource type menu items definition # Fedora resource type menu items definition
entity.fedora_resource_type.collection: entity.fedora_resource_type.collection:
title: 'Fedora resource type' title: 'Fedora resource type list'
route_name: entity.fedora_resource_type.collection route_name: entity.fedora_resource_type.collection
description: 'List Fedora resource type (bundles)' description: 'List Fedora resource type (bundles)'
parent: system.admin_structure parent: system.admin_structure

0
islandoraclaw.links.task.yml → islandora.links.task.yml

12
islandoraclaw.module → islandora.module

@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains islandoraclaw.module.. * Contains islandora.module..
*/ */
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
@ -10,10 +10,10 @@ use Drupal\Core\Routing\RouteMatchInterface;
/** /**
* Implements hook_help(). * Implements hook_help().
*/ */
function islandoraclaw_help($route_name, RouteMatchInterface $route_match) { function islandora_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) { switch ($route_name) {
// Main module help for the islandoraclaw module. // Main module help for the islandora module.
case 'help.page.islandoraclaw': case 'help.page.islandora':
$output = ''; $output = '';
$output .= '<h3>' . t('About') . '</h3>'; $output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('') . '</p>'; $output .= '<p>' . t('') . '</p>';
@ -26,7 +26,7 @@ function islandoraclaw_help($route_name, RouteMatchInterface $route_match) {
/** /**
* Implements hook_theme(). * Implements hook_theme().
*/ */
function islandoraclaw_theme() { function islandora_theme() {
$theme = []; $theme = [];
$theme['fedora_resource'] = [ $theme['fedora_resource'] = [
'render element' => 'elements', 'render element' => 'elements',
@ -44,7 +44,7 @@ function islandoraclaw_theme() {
/** /**
* Implements hook_theme_suggestions_HOOK(). * Implements hook_theme_suggestions_HOOK().
*/ */
function islandoraclaw_theme_suggestions_fedora_resource(array $variables) { function islandora_theme_suggestions_fedora_resource(array $variables) {
$suggestions = array(); $suggestions = array();
$entity = $variables['elements']['#fedora_resource']; $entity = $variables['elements']['#fedora_resource'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_'); $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');

7
islandoraclaw.permissions.yml → islandora.permissions.yml

@ -1,3 +1,4 @@
# Fedora Resource permissions
add fedora resource entities: add fedora resource entities:
title: 'Create new Fedora resource entities' title: 'Create new Fedora resource entities'
@ -17,3 +18,9 @@ view published fedora resource entities:
view unpublished fedora resource entities: view unpublished fedora resource entities:
title: '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

19
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

4
src/Controller/FedoraResourceAddController.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Controller; namespace Drupal\islandora\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Request;
/** /**
* Class FedoraResourceAddController. * Class FedoraResourceAddController.
* *
* @package Drupal\islandoraclaw\Controller * @package Drupal\islandora\Controller
*/ */
class FedoraResourceAddController extends ControllerBase { class FedoraResourceAddController extends ControllerBase {

60
src/Entity/FedoraResource.php

@ -1,19 +1,19 @@
<?php <?php
namespace Drupal\islandoraclaw\Entity; namespace Drupal\islandora\Entity;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait; use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\islandoraclaw\FedoraResourceInterface; use Drupal\islandora\FedoraResourceInterface;
use Drupal\user\UserInterface; use Drupal\user\UserInterface;
/** /**
* Defines the Fedora resource entity. * Defines the Fedora resource entity.
* *
* @ingroup islandoraclaw * @ingroup islandora
* *
* @ContentEntityType( * @ContentEntityType(
* id = "fedora_resource", * id = "fedora_resource",
@ -21,18 +21,18 @@ use Drupal\user\UserInterface;
* bundle_label = @Translation("Fedora resource type"), * bundle_label = @Translation("Fedora resource type"),
* handlers = { * handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\islandoraclaw\FedoraResourceListBuilder", * "list_builder" = "Drupal\islandora\FedoraResourceListBuilder",
* "views_data" = "Drupal\islandoraclaw\Entity\FedoraResourceViewsData", * "views_data" = "Drupal\islandora\Entity\FedoraResourceViewsData",
* *
* "form" = { * "form" = {
* "default" = "Drupal\islandoraclaw\Form\FedoraResourceForm", * "default" = "Drupal\islandora\Form\FedoraResourceForm",
* "add" = "Drupal\islandoraclaw\Form\FedoraResourceForm", * "add" = "Drupal\islandora\Form\FedoraResourceForm",
* "edit" = "Drupal\islandoraclaw\Form\FedoraResourceForm", * "edit" = "Drupal\islandora\Form\FedoraResourceForm",
* "delete" = "Drupal\islandoraclaw\Form\FedoraResourceDeleteForm", * "delete" = "Drupal\islandora\Form\FedoraResourceDeleteForm",
* }, * },
* "access" = "Drupal\islandoraclaw\FedoraResourceAccessControlHandler", * "access" = "Drupal\islandora\FedoraResourceAccessControlHandler",
* "route_provider" = { * "route_provider" = {
* "html" = "Drupal\islandoraclaw\FedoraResourceHtmlRouteProvider", * "html" = "Drupal\islandora\FedoraResourceHtmlRouteProvider",
* }, * },
* }, * },
* base_table = "fedora_resource", * base_table = "fedora_resource",
@ -176,6 +176,40 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
return $this; return $this;
} }
/**
* {@inheritdoc}
*/
public function hasParent()
{
return ($this->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. * Default value callback for 'fedora_has_parent' base field definition.
* *
@ -238,7 +272,7 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSetting('target_type', 'fedora_resource') ->setSetting('target_type', 'fedora_resource')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\islandoraClaw\Entity\FedoraResource::getFedoraRoot') ->setDefaultValueCallback('Drupal\islandora\Entity\FedoraResource::getFedoraRoot')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', array( ->setDisplayOptions('view', array(
'label' => 'hidden', 'label' => 'hidden',
@ -258,7 +292,7 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE); ->setDisplayConfigurable('view', TRUE);
$fields['ldp_containes'] = BaseFieldDefinition::create('entity_reference') $fields['ldp_contains'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('LDP Contains')) ->setLabel(t('LDP Contains'))
->setDescription(t('Contains Fedora Resource.')) ->setDescription(t('Contains Fedora Resource.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)

28
src/Entity/FedoraResourceType.php

@ -1,9 +1,9 @@
<?php <?php
namespace Drupal\islandoraclaw\Entity; namespace Drupal\islandora\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\islandoraclaw\FedoraResourceTypeInterface; use Drupal\islandora\FedoraResourceTypeInterface;
/** /**
* Defines the Fedora resource type entity. * Defines the Fedora resource type entity.
@ -12,14 +12,14 @@ use Drupal\islandoraclaw\FedoraResourceTypeInterface;
* id = "fedora_resource_type", * id = "fedora_resource_type",
* label = @Translation("Fedora resource type"), * label = @Translation("Fedora resource type"),
* handlers = { * handlers = {
* "list_builder" = "Drupal\islandoraclaw\FedoraResourceTypeListBuilder", * "list_builder" = "Drupal\islandora\FedoraResourceTypeListBuilder",
* "form" = { * "form" = {
* "add" = "Drupal\islandoraclaw\Form\FedoraResourceTypeForm", * "add" = "Drupal\islandora\Form\FedoraResourceTypeForm",
* "edit" = "Drupal\islandoraclaw\Form\FedoraResourceTypeForm", * "edit" = "Drupal\islandora\Form\FedoraResourceTypeForm",
* "delete" = "Drupal\islandoraclaw\Form\FedoraResourceTypeDeleteForm" * "delete" = "Drupal\islandora\Form\FedoraResourceTypeDeleteForm"
* }, * },
* "route_provider" = { * "route_provider" = {
* "html" = "Drupal\islandoraclaw\FedoraResourceTypeHtmlRouteProvider", * "html" = "Drupal\islandora\FedoraResourceTypeHtmlRouteProvider",
* }, * },
* }, * },
* config_prefix = "fedora_resource_type", * config_prefix = "fedora_resource_type",
@ -55,4 +55,18 @@ class FedoraResourceType extends ConfigEntityBundleBase implements FedoraResourc
*/ */
protected $label; protected $label;
/**
* The RDF type
*
* @var string
*/
protected $rdf_type;
/**
* {@inheritdoc}
*/
public function getRdfType()
{
return $this->rdf_type;
}
} }

2
src/Entity/FedoraResourceViewsData.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Entity; namespace Drupal\islandora\Entity;
use Drupal\views\EntityViewsData; use Drupal\views\EntityViewsData;
use Drupal\views\EntityViewsDataInterface; use Drupal\views\EntityViewsDataInterface;

22
src/FedoraResource.php

@ -1,22 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\islandoraclaw\FedoraResourceInterface.
*/
namespace Drupal\islandoraclaw;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\user\EntityOwnerInterface;
use Drupal\Core\Entity\EntityChangedInterface;
/**
* Provides an interface for defining a Fedora 4 Resource entity.
*
* This interface extends multiple ones so we can use all the extended ones at once.
*
* @ingroup islandoraclaw
*/
interface FedoraResourceInterface extends ContentEntityInterface, EntityOwnerInterface, EntityChangedInterface {
}

6
src/FedoraResourceAccessControlHandler.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
@ -10,7 +10,7 @@ use Drupal\Core\Access\AccessResult;
/** /**
* Access controller for the Fedora resource entity. * Access controller for the Fedora resource entity.
* *
* @see \Drupal\islandoraclaw\Entity\FedoraResource. * @see \Drupal\islandora\Entity\FedoraResource.
*/ */
class FedoraResourceAccessControlHandler extends EntityAccessControlHandler { class FedoraResourceAccessControlHandler extends EntityAccessControlHandler {
@ -18,7 +18,7 @@ class FedoraResourceAccessControlHandler extends EntityAccessControlHandler {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\islandoraclaw\FedoraResourceInterface $entity */ /** @var \Drupal\islandora\FedoraResourceInterface $entity */
switch ($operation) { switch ($operation) {
case 'view': case 'view':
if (!$entity->isPublished()) { if (!$entity->isPublished()) {

10
src/FedoraResourceHtmlRouteProvider.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
@ -86,8 +86,8 @@ class FedoraResourceHtmlRouteProvider extends AdminHtmlRouteProvider {
// Content entities with bundles are added via a dedicated controller. // Content entities with bundles are added via a dedicated controller.
$route $route
->setDefaults([ ->setDefaults([
'_controller' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::addForm', '_controller' => 'Drupal\islandora\Controller\FedoraResourceAddController::addForm',
'_title_callback' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::getAddFormTitle', '_title_callback' => 'Drupal\islandora\Controller\FedoraResourceAddController::getAddFormTitle',
]) ])
->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}'); ->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
$parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $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 = new Route("/admin/structure/{$entity_type->id()}/add");
$route $route
->setDefaults([ ->setDefaults([
'_controller' => 'Drupal\islandoraclaw\Controller\FedoraResourceAddController::add', '_controller' => 'Drupal\islandora\Controller\FedoraResourceAddController::add',
'_title' => "Add {$entity_type->getLabel()}", '_title' => "Add {$entity_type->getLabel()}",
]) ])
->setRequirement('_entity_create_access', $entity_type->id()) ->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 = new Route("/admin/structure/{$entity_type->id()}/settings");
$route $route
->setDefaults([ ->setDefaults([
'_form' => 'Drupal\islandoraclaw\Form\FedoraResourceSettingsForm', '_form' => 'Drupal\islandora\Form\FedoraResourceSettingsForm',
'_title' => "{$entity_type->getLabel()} settings", '_title' => "{$entity_type->getLabel()} settings",
]) ])
->setRequirement('_permission', $entity_type->getAdminPermission()) ->setRequirement('_permission', $entity_type->getAdminPermission())

45
src/FedoraResourceInterface.php

@ -1,15 +1,16 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\EntityOwnerInterface; use Drupal\user\EntityOwnerInterface;
/** /**
* Provides an interface for defining Fedora resource entities. * Provides an interface for defining Fedora resource entities.
* *
* @ingroup islandoraclaw * @ingroup islandora
*/ */
interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface { interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
@ -37,7 +38,7 @@ interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedI
* @param string $name * @param string $name
* The Fedora resource name. * The Fedora resource name.
* *
* @return \Drupal\islandoraclaw\FedoraResourceInterface * @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity. * The called Fedora resource entity.
*/ */
public function setName($name); public function setName($name);
@ -56,7 +57,7 @@ interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedI
* @param int $timestamp * @param int $timestamp
* The Fedora resource creation timestamp. * The Fedora resource creation timestamp.
* *
* @return \Drupal\islandoraclaw\FedoraResourceInterface * @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity. * The called Fedora resource entity.
*/ */
public function setCreatedTime($timestamp); public function setCreatedTime($timestamp);
@ -77,9 +78,43 @@ interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedI
* @param bool $published * @param bool $published
* TRUE to set this Fedora resource to published, FALSE to set it to unpublished. * TRUE to set this Fedora resource to published, FALSE to set it to unpublished.
* *
* @return \Drupal\islandoraclaw\FedoraResourceInterface * @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity. * The called Fedora resource entity.
*/ */
public function setPublished($published); public function setPublished($published);
/**
* Does the entity have a parent entity?
*
* @return bool
* Whether a parent entity was set.
*/
public function hasParent();
/**
* Gets the id of the parent entity.
*
* @return int
* The id of the parent Fedora resource entity.
*/
public function getParentId();
/**
* Get the parent entity.
*
* @return \Drupal\islandora\FedoraResourceInterface
* The actual entity of the parent Fedora resource.
*/
public function getParent();
/**
* Get the parent entity.
*
* @param \Drupal\islandora\FedoraResourceInterface $parent
* The parent entity
*
* @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity.
*/
public function setParent(EntityTypeInterface $entity);
} }

29
src/FedoraResourceListBuilder.php

@ -1,27 +1,25 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder; use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Routing\LinkGeneratorTrait; use Drupal\Core\Link;
use Drupal\Core\Url;
/** /**
* Defines a class to build a listing of Fedora resource entities. * Defines a class to build a listing of Fedora resource entities.
* *
* @ingroup islandoraclaw * @ingroup islandora
*/ */
class FedoraResourceListBuilder extends EntityListBuilder { class FedoraResourceListBuilder extends EntityListBuilder {
use LinkGeneratorTrait;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildHeader() { public function buildHeader() {
$header['id'] = $this->t('Fedora resource ID'); $header['id'] = $this->t('Fedora resource ID');
$header['name'] = $this->t('Name'); $header['name'] = $this->t('Name');
$header['parent'] = $this->t('Parent');
return $header + parent::buildHeader(); return $header + parent::buildHeader();
} }
@ -29,16 +27,21 @@ class FedoraResourceListBuilder extends EntityListBuilder {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildRow(EntityInterface $entity) { public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\islandoraclaw\Entity\FedoraResource */ /* @var $entity \Drupal\islandora\Entity\FedoraResource */
$row['id'] = $entity->id(); $row['id'] = $entity->id();
$row['name'] = $this->l( $row['name'] = Link::fromTextAndUrl(
$entity->label(), $entity->label(),
new Url( $entity->toUrl()
'entity.fedora_resource.edit_form', array(
'fedora_resource' => $entity->id(),
)
)
); );
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); return $row + parent::buildRow($entity);
} }

2
src/FedoraResourceTypeHtmlRouteProvider.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;

7
src/FedoraResourceTypeInterface.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Config\Entity\ConfigEntityInterface;
@ -10,4 +10,9 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
interface FedoraResourceTypeInterface extends ConfigEntityInterface { interface FedoraResourceTypeInterface extends ConfigEntityInterface {
// Add get/set methods for your configuration properties here. // Add get/set methods for your configuration properties here.
/**
* Return the entities rdf_type
*/
public function getRdfType();
} }

4
src/FedoraResourceTypeListBuilder.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw; namespace Drupal\islandora;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
@ -16,6 +16,7 @@ class FedoraResourceTypeListBuilder extends ConfigEntityListBuilder {
public function buildHeader() { public function buildHeader() {
$header['label'] = $this->t('Fedora resource type'); $header['label'] = $this->t('Fedora resource type');
$header['id'] = $this->t('Machine name'); $header['id'] = $this->t('Machine name');
$header['rdf_type'] = $this->t('RDF Type');
return $header + parent::buildHeader(); return $header + parent::buildHeader();
} }
@ -25,6 +26,7 @@ class FedoraResourceTypeListBuilder extends ConfigEntityListBuilder {
public function buildRow(EntityInterface $entity) { public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label(); $row['label'] = $entity->label();
$row['id'] = $entity->id(); $row['id'] = $entity->id();
$row['rdf_type'] = $entity->getRdfType();
// You probably want a few more properties here... // You probably want a few more properties here...
return $row + parent::buildRow($entity); return $row + parent::buildRow($entity);
} }

4
src/Form/FedoraResourceDeleteForm.php

@ -1,13 +1,13 @@
<?php <?php
namespace Drupal\islandoraclaw\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm; use Drupal\Core\Entity\ContentEntityDeleteForm;
/** /**
* Provides a form for deleting Fedora resource entities. * Provides a form for deleting Fedora resource entities.
* *
* @ingroup islandoraclaw * @ingroup islandora
*/ */
class FedoraResourceDeleteForm extends ContentEntityDeleteForm { class FedoraResourceDeleteForm extends ContentEntityDeleteForm {

6
src/Form/FedoraResourceForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
@ -8,7 +8,7 @@ use Drupal\Core\Form\FormStateInterface;
/** /**
* Form controller for Fedora resource edit forms. * Form controller for Fedora resource edit forms.
* *
* @ingroup islandoraclaw * @ingroup islandora
*/ */
class FedoraResourceForm extends ContentEntityForm { class FedoraResourceForm extends ContentEntityForm {
@ -16,7 +16,7 @@ class FedoraResourceForm extends ContentEntityForm {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\islandoraclaw\Entity\FedoraResource */ /* @var $entity \Drupal\islandora\Entity\FedoraResource */
$form = parent::buildForm($form, $form_state); $form = parent::buildForm($form, $form_state);
$entity = $this->entity; $entity = $this->entity;

6
src/Form/FedoraResourceSettingsForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
@ -8,9 +8,9 @@ use Drupal\Core\Form\FormStateInterface;
/** /**
* Class FedoraResourceSettingsForm. * Class FedoraResourceSettingsForm.
* *
* @package Drupal\islandoraclaw\Form * @package Drupal\islandora\Form
* *
* @ingroup islandoraclaw * @ingroup islandora
*/ */
class FedoraResourceSettingsForm extends FormBase { class FedoraResourceSettingsForm extends FormBase {

2
src/Form/FedoraResourceTypeDeleteForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;

15
src/Form/FedoraResourceTypeForm.php

@ -1,6 +1,6 @@
<?php <?php
namespace Drupal\islandoraclaw\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
@ -8,7 +8,7 @@ use Drupal\Core\Form\FormStateInterface;
/** /**
* Class FedoraResourceTypeForm. * Class FedoraResourceTypeForm.
* *
* @package Drupal\islandoraclaw\Form * @package Drupal\islandora\Form
*/ */
class FedoraResourceTypeForm extends EntityForm { class FedoraResourceTypeForm extends EntityForm {
@ -32,11 +32,20 @@ class FedoraResourceTypeForm extends EntityForm {
'#type' => 'machine_name', '#type' => 'machine_name',
'#default_value' => $fedora_resource_type->id(), '#default_value' => $fedora_resource_type->id(),
'#machine_name' => array( '#machine_name' => array(
'exists' => '\Drupal\islandoraclaw\Entity\FedoraResourceType::load', 'exists' => '\Drupal\islandora\Entity\FedoraResourceType::load',
), ),
'#disabled' => !$fedora_resource_type->isNew(), '#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. */ /* You will need additional form elements for your custom properties. */
return $form; return $form;

12
src/Plugin/Search/FedoraEntitySearch.php

@ -1,10 +1,10 @@
<? <?
/** /**
* @file * @file
* Contains \Drupal\islandoraclaw\Plugin\Search\FedoraEntitySearch. * Contains \Drupal\islandora\Plugin\Search\FedoraEntitySearch.
*/ */
namespace Drupal\islandoraclaw\Plugin\Search; namespace Drupal\islandora\Plugin\Search;
use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Cache\CacheableMetadata;
@ -20,7 +20,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\Access\AccessibleInterface;
use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\islandoraclaw\FedoraResourceInterface; use Drupal\islandora\FedoraResourceInterface;
use Drupal\search\Plugin\ConfigurableSearchPluginBase; use Drupal\search\Plugin\ConfigurableSearchPluginBase;
use Drupal\search\Plugin\SearchIndexingInterface; use Drupal\search\Plugin\SearchIndexingInterface;
use Drupal\search\SearchQuery; use Drupal\search\SearchQuery;
@ -175,7 +175,7 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces
} }
/** /**
* Constructs \Drupal\islandoraclaw\Plugin\Search\FedoraResourceSearch. * Constructs \Drupal\islandora\Plugin\Search\FedoraResourceSearch.
* *
* @param array $configuration * @param array $configuration
* A configuration array containing information about the plugin instance. * A configuration array containing information about the plugin instance.
@ -371,7 +371,7 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces
$results = array(); $results = array();
// 'fedora_resource' comes from the entity type id declared // '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. // Replace this with your entity's type id.
$entity_storage = $this->entityManager->getStorage('fedora_resource'); $entity_storage = $this->entityManager->getStorage('fedora_resource');
$entity_render = $this->entityManager->getViewBuilder('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 // '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. // Replace this with your entity's type id.
$entity_storage = $this->entityManager->getStorage('fedora_resource'); $entity_storage = $this->entityManager->getStorage('fedora_resource');

Loading…
Cancel
Save