Browse Source

Merge branch '8.x-1.x' of https://github.com/Islandora-CLAW/islandora into issue-430

pull/756/head
Natkeeran 8 years ago
parent
commit
d94da28411
  1. 14
      .scripts/line_endings.sh
  2. 81
      .scripts/travis_setup.sh
  3. 39
      .travis.yml
  4. 2
      README.md
  5. 34
      composer.json
  6. 0
      islandora/config/install/islandora.fedora_resource_type.non_rdf_source.yml
  7. 0
      islandora/config/install/islandora.fedora_resource_type.rdf_source.yml
  8. 0
      islandora/config/install/islandora.settings.yml
  9. 0
      islandora/config/install/rdf.mapping.fedora_resource_type.rdf_source.yml
  10. 0
      islandora/config/schema/fedora_resource_type.schema.yml
  11. 2
      islandora/fedora_resource.page.inc
  12. 0
      islandora/islandora.info.yml
  13. 0
      islandora/islandora.links.action.yml
  14. 0
      islandora/islandora.links.menu.yml
  15. 0
      islandora/islandora.links.task.yml
  16. 2
      islandora/islandora.module
  17. 0
      islandora/islandora.permissions.yml
  18. 0
      islandora/islandora.routing.yml
  19. 0
      islandora/islandora.services.yml
  20. 119
      islandora/src/Controller/FedoraResourceAddController.php
  21. 43
      islandora/src/Entity/FedoraResource.php
  22. 0
      islandora/src/Entity/FedoraResourceType.php
  23. 0
      islandora/src/Entity/FedoraResourceViewsData.php
  24. 0
      islandora/src/FedoraResourceAccessControlHandler.php
  25. 4
      islandora/src/FedoraResourceHtmlRouteProvider.php
  26. 10
      islandora/src/FedoraResourceInterface.php
  27. 0
      islandora/src/FedoraResourceListBuilder.php
  28. 0
      islandora/src/FedoraResourceTypeHtmlRouteProvider.php
  29. 0
      islandora/src/FedoraResourceTypeInterface.php
  30. 0
      islandora/src/FedoraResourceTypeListBuilder.php
  31. 10
      islandora/src/FedoraResourceViewBuilder.php
  32. 0
      islandora/src/Form/FedoraResourceDeleteForm.php
  33. 17
      islandora/src/Form/FedoraResourceEntityInlineForm.php
  34. 0
      islandora/src/Form/FedoraResourceForm.php
  35. 0
      islandora/src/Form/FedoraResourceSettingsForm.php
  36. 0
      islandora/src/Form/FedoraResourceTypeDeleteForm.php
  37. 0
      islandora/src/Form/FedoraResourceTypeForm.php
  38. 6
      islandora/src/Form/IslandoraSettingsForm.php
  39. 22
      islandora/src/ParamConverter/UuidEntityConverter.php
  40. 9
      islandora/src/Plugin/Search/FedoraEntitySearch.php
  41. 0
      islandora/templates/fedora-resource-content-add-list.html.twig
  42. 0
      islandora/templates/fedora_resource.html.twig
  43. 97
      src/Controller/FedoraResourceAddController.php

14
.scripts/line_endings.sh

@ -0,0 +1,14 @@
#!/bin/bash
RETURN=0
FILES=`find -L $1 -name "*.info" -o -name "*.txt" -o -name "*.md"`
echo "Testing for files with DOS line endings..."
for FILE in $FILES
do
file $FILE | grep CRLF
if [ $? == 0 ]
then
RETURN=1
fi
done
exit $RETURN

81
.scripts/travis_setup.sh

@ -0,0 +1,81 @@
#!/bin/bash
mysql -u root -e 'create database drupal;'
mysql -u root -e "GRANT ALL PRIVILEGES ON drupal.* To 'drupal'@'localhost' IDENTIFIED BY 'drupal';"
# Java (Oracle)
sudo apt-get install -y software-properties-common
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer
sudo update-java-alternatives -s java-8-oracle
sudo apt-get install -y oracle-java8-set-default
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
# phpcpd
#sudo apt-get install -y phpcpd
cd $HOME
pear channel-discover pear.drush.org
pear upgrade --force Console_GetoptPlus
pear upgrade --force pear
pear channel-discover pear.drush.org
# Drush
cd /tmp
php -r "readfile('https://s3.amazonaws.com/files.drush.org/drush.phar');" > drush
php drush core-status
chmod +x drush
sudo mv drush /opt
sudo ln -s /opt/drush /usr/bin/drush
phpenv rehash
cd $HOME
drush dl drupal-8.2.2 --drupal-project-rename=drupal
cd $HOME/drupal
drush si minimal --db-url=mysql://drupal:drupal@localhost/drupal --yes
drush runserver --php-cgi=$HOME/.phpenv/shims/php-cgi localhost:8081 &>/tmp/drush_webserver.log &
ln -s $ISLANDORA_DIR modules/islandora
drush en -y rdf
drush en -y responsive_image
drush en -y syslog
drush en -y serialization
drush en -y basic_auth
drush en -y rest
drush dl rdfui --dev
drush en -y rdfui
drush en -y rdf_builder
drush dl restui
drush en -y restui
drush dl inline_entity_form
drush en -y inline_entity_form
drush dl media_entity
drush en -y media_entity
drush dl media_entity_image
drush en -y media_entity_image
drush dl search_api
drush -y pm-uninstall search
drush en -y search_api
cd $HOME/drupal/modules
git clone https://github.com/DiegoPino/claw-jsonld.git
drush en -y jsonld
drush -y dl bootstrap
drush -y en bootstrap
drush -y config-set system.theme default bootstrap
drush cr
# The shebang in this file is a bogeyman that is haunting the web test cases.
rm /home/travis/.phpenv/rbenv.d/exec/hhvm-switcher.bash
sleep 20

39
.travis.yml

@ -0,0 +1,39 @@
sudo: true
language: php
php:
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: hhvm
fast_finish: true
branches:
only:
- /^8.x/
before_install:
- export ISLANDORA_DIR=$TRAVIS_BUILD_DIR
install:
# - $TRAVIS_BUILD_DIR/tests/scripts/travis_setup.sh
- composer install
- php vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer
script:
- $ISLANDORA_DIR/.scripts/line_endings.sh .
- php vendor/bin/phpcs --standard=Drupal **/*.module **/*.php --ignore=tests,vendor .
- php vendor/bin/phpcpd --names *.module,*.inc,*.test,*.php --exclude=vendor .
notifications:
irc:
channels:
- "irc.freenode.org#islandora"
on_success: change
on_failure: always
skip_join: true

2
README.md

@ -5,7 +5,7 @@
## Introduction ## Introduction
Islandora Fedora 4 Repository Module for Drupal 8.1.x Islandora modules for Drupal 8.2.x
## Maintainers ## Maintainers

34
composer.json

@ -0,0 +1,34 @@
{
"name": "drupal/islandora",
"description": "A client for interacting with a Fedora 4 server using CLAW microservices.",
"type": "drupal-module",
"homepage": "https://github.com/islandora-claw/islandora",
"support": {
"issues": "https://github.com/islandora-claw/CLAW/issues",
"irc": "irc://irc.freenode.net/islandora"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"drupal/coder": "*",
"sebastian/phpcpd": "*"
},
"license": "GPL-2.0+",
"authors": [
{
"name": "Islandora Foundation",
"email": "community@islandora.ca",
"role": "Owner"
},
{
"name": "Daniel Lamb",
"email": "dlamb@islandora.ca",
"role": "Maintainer"
},
{
"name": "Diego Pino",
"email": "dpino@krayon.cl",
"role": "Maintainer"
}
]
}

0
config/install/islandora.fedora_resource_type.non_rdf_source.yml → islandora/config/install/islandora.fedora_resource_type.non_rdf_source.yml

0
config/install/islandora.fedora_resource_type.rdf_source.yml → islandora/config/install/islandora.fedora_resource_type.rdf_source.yml

0
config/install/islandora.settings.yml → islandora/config/install/islandora.settings.yml

0
config/install/rdf.mapping.fedora_resource_type.rdf_source.yml → islandora/config/install/rdf.mapping.fedora_resource_type.rdf_source.yml

0
config/schema/fedora_resource_type.schema.yml → islandora/config/schema/fedora_resource_type.schema.yml

2
fedora_resource.page.inc → islandora/fedora_resource.page.inc

@ -14,8 +14,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
* *
* @author Diego Pino Navarro <dpino@metro.org> https://github.com/diegopino * @author Diego Pino Navarro <dpino@metro.org> https://github.com/diegopino
*
*/ */
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\Core\Link; use Drupal\Core\Link;
use Drupal\Core\Url; use Drupal\Core\Url;

0
islandora.info.yml → islandora/islandora.info.yml

0
islandora.links.action.yml → islandora/islandora.links.action.yml

0
islandora.links.menu.yml → islandora/islandora.links.menu.yml

0
islandora.links.task.yml → islandora/islandora.links.task.yml

2
islandora.module → islandora/islandora.module

@ -25,7 +25,7 @@ function islandora_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.islandora': case 'help.page.islandora':
$output = ''; $output = '';
$output .= '<h3>' . t('About') . '</h3>'; $output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('') . '</p>'; $output .= '<p>' . t('This is a placeholder for future help text about Islandora.') . '</p>';
return $output; return $output;
default: default:

0
islandora.permissions.yml → islandora/islandora.permissions.yml

0
islandora.routing.yml → islandora/islandora.routing.yml

0
islandora.services.yml → islandora/islandora.services.yml

119
islandora/src/Controller/FedoraResourceAddController.php

@ -0,0 +1,119 @@
<?php
namespace Drupal\islandora\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Class FedoraResourceAddController.
*
* @package Drupal\islandora\Controller
*/
class FedoraResourceAddController extends ControllerBase {
/**
* The Entity storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* The Entity storage type.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $typeStorage;
/**
* FedoraResourceAddController constructor.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The Entity storage.
* @param \Drupal\Core\Entity\EntityStorageInterface $type_storage
* The Entity storage type.
*/
public function __construct(EntityStorageInterface $storage, EntityStorageInterface $type_storage) {
$this->storage = $storage;
$this->typeStorage = $type_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $container->get('entity_type.manager');
return new static(
$entity_type_manager->getStorage('fedora_resource'),
$entity_type_manager->getStorage('fedora_resource_type')
);
}
/**
* Displays add links for available bundles/types for entity fedora_resource.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* A render array for a list of the fedora_resource bundles/types that can
* be added or if there is only one type/bunlde defined for the site, the
* function returns the add page for that bundle/type.
*/
public function add(Request $request) {
$types = $this->typeStorage->loadMultiple();
if ($types && count($types) == 1) {
$type = reset($types);
return $this->addForm($type, $request);
}
if (count($types) === 0) {
return array(
'#markup' => $this->t('You have not created any %bundle types yet. @link to add a new type.', [
'%bundle' => 'Fedora resource',
'@link' => $this->l($this->t('Go to the type creation page'), Url::fromRoute('entity.fedora_resource_type.add_form')),
]),
);
}
return array('#theme' => 'fedora_resource_content_add_list', '#content' => $types);
}
/**
* Presents the creation form for fedora_resource entities of given type.
*
* @param EntityInterface $fedora_resource_type
* The custom bundle to add.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* A form array as expected by drupal_render().
*/
public function addForm(EntityInterface $fedora_resource_type, Request $request) {
$entity = $this->storage->create(array(
'type' => $fedora_resource_type->id(),
));
return $this->entityFormBuilder()->getForm($entity);
}
/**
* Provides the page title for this controller.
*
* @param EntityInterface $fedora_resource_type
* The custom bundle/type being added.
*
* @return string
* The page title.
*/
public function getAddFormTitle(EntityInterface $fedora_resource_type) {
return t('Create of bundle @label',
array('@label' => $fedora_resource_type->label())
);
}
}

43
src/Entity/FedoraResource.php → islandora/src/Entity/FedoraResource.php

@ -70,13 +70,23 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
use EntityChangedTrait; use EntityChangedTrait;
/** /**
* Override this to have a rel ='uuid' for islandora entities.
*
* Stolen (but not inherited from EntityInterface)
*
* @param string $rel * @param string $rel
* The link relationship type, for example: canonical or edit-form.
* @param array $options * @param array $options
* @return $this|\Drupal\Core\Url * See \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() for
* the available options.
*
* @return \Drupal\Core\Url
* The URL object.
*/ */
public function toUrl($rel = 'canonical', array $options = []) { public function toUrl($rel = 'canonical', array $options = []) {
// TODO: I Will override this to have a rel ='uuid' for islandora entities // TODO: I Will override this to have a rel ='uuid' for islandora entities
return parent::toUrl($rel, $options); // TODO: Change the autogenerated stub // TODO: Change the autogenerated stub.
return parent::toUrl($rel, $options);
} }
/** /**
@ -92,7 +102,8 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
* An array of URI placeholders. * An array of URI placeholders.
*/ */
protected function urlRouteParameters($rel) { protected function urlRouteParameters($rel) {
$uri_route_parameters = parent::urlRouteParameters($rel); // TODO: Change the autogenerated stub // TODO: Change the autogenerated stub.
$uri_route_parameters = parent::urlRouteParameters($rel);
if ($rel === 'uuid') { if ($rel === 'uuid') {
$uri_route_parameters[$this->getEntityTypeId()] = $this->uuid(); $uri_route_parameters[$this->getEntityTypeId()] = $this->uuid();
} }
@ -100,7 +111,6 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -118,8 +128,8 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
parent::postSave($storage, $update); parent::postSave($storage, $update);
// Reindex the entity when it is updated. The entity is automatically // Reindex the entity when it is updated. The entity is automatically
// indexed when it is added, simply by being added to the {fedora_resource} table. // indexed when it is added, simply by being added to the {fedora_resource}
// Only required if using the core search index. // table. Only required if using the core search index.
if ($update) { if ($update) {
if (\Drupal::moduleHandler()->moduleExists('search')) { if (\Drupal::moduleHandler()->moduleExists('search')) {
search_mark_for_reindex('fedora_resource_search', $this->id()); search_mark_for_reindex('fedora_resource_search', $this->id());
@ -208,32 +218,32 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
$this->set('status', $published ? NODE_PUBLISHED : NODE_NOT_PUBLISHED); $this->set('status', $published ? NODE_PUBLISHED : NODE_NOT_PUBLISHED);
return $this; return $this;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function hasParent() public function hasParent() {
{ return ($this->get('fedora_has_parent') !== NULL);
return ($this->get('fedora_has_parent') !== null);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getParent() public function getParent() {
{
return $this->get('fedora_has_parent')->getEntity(); return $this->get('fedora_has_parent')->getEntity();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getParentId() public function getParentId() {
{
return $this->get('fedora_has_parent')->getEntity()->id(); return $this->get('fedora_has_parent')->getEntity()->id();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function setParent(EntityTypeInterface $entity) public function setParent(EntityTypeInterface $entity) {
{
$this->set('fedora_has_parent', $entity); $this->set('fedora_has_parent', $entity);
return $this; return $this;
} }
@ -247,11 +257,10 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
* An array of default values. * An array of default values.
*/ */
public static function getFedoraRoot() { public static function getFedoraRoot() {
// Just stub code, we need to figure out what "root is" in this context // Just stub code, we need to figure out what "root is" in this context.
return array('root'); return array('root');
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

0
src/Entity/FedoraResourceType.php → islandora/src/Entity/FedoraResourceType.php

0
src/Entity/FedoraResourceViewsData.php → islandora/src/Entity/FedoraResourceViewsData.php

0
src/FedoraResourceAccessControlHandler.php → islandora/src/FedoraResourceAccessControlHandler.php

4
src/FedoraResourceHtmlRouteProvider.php → islandora/src/FedoraResourceHtmlRouteProvider.php

@ -44,11 +44,11 @@ class FedoraResourceHtmlRouteProvider extends AdminHtmlRouteProvider implements
$collection->add("entity.{$entity_type_id}.uuid", $uuid_route); $collection->add("entity.{$entity_type_id}.uuid", $uuid_route);
} }
return $collection; return $collection;
} }
/** Gets the UUID route. /**
* Gets the UUID route.
* *
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type. * The entity type.

10
src/FedoraResourceInterface.php → islandora/src/FedoraResourceInterface.php

@ -14,8 +14,6 @@ use Drupal\user\EntityOwnerInterface;
*/ */
interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface { interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/** /**
* Gets the Fedora resource type. * Gets the Fedora resource type.
* *
@ -76,7 +74,8 @@ interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedI
* Sets the published status of a Fedora resource. * Sets the published status of a Fedora resource.
* *
* @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\islandora\FedoraResourceInterface * @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity. * The called Fedora resource entity.
@ -110,11 +109,12 @@ interface FedoraResourceInterface extends ContentEntityInterface, EntityChangedI
/** /**
* Get the parent entity. * Get the parent entity.
* *
* @param \Drupal\islandora\FedoraResourceInterface $parent * @param \Drupal\Core\Entity\EntityTypeInterface $entity
* The parent entity * The parent entity.
* *
* @return \Drupal\islandora\FedoraResourceInterface * @return \Drupal\islandora\FedoraResourceInterface
* The called Fedora resource entity. * The called Fedora resource entity.
*/ */
public function setParent(EntityTypeInterface $entity); public function setParent(EntityTypeInterface $entity);
} }

0
src/FedoraResourceListBuilder.php → islandora/src/FedoraResourceListBuilder.php

0
src/FedoraResourceTypeHtmlRouteProvider.php → islandora/src/FedoraResourceTypeHtmlRouteProvider.php

0
src/FedoraResourceTypeInterface.php → islandora/src/FedoraResourceTypeInterface.php

0
src/FedoraResourceTypeListBuilder.php → islandora/src/FedoraResourceTypeListBuilder.php

10
src/FedoraResourceViewBuilder.php → islandora/src/FedoraResourceViewBuilder.php

@ -1,19 +1,11 @@
<?php <?php
/**
* Created by PhpStorm.
* User: dpino
* Date: 8/16/16
* Time: 11:49 PM
*/
namespace Drupal\islandora; namespace Drupal\islandora;
use Drupal\node\NodeViewBuilder; use Drupal\node\NodeViewBuilder;
/** /**
* Class FedoraResourceViewBuilder * Class FedoraResourceViewBuilder view builder handler.
* view builder handler.
* *
* @TODO this should manage how fedora_resource are build to be viewed. * @TODO this should manage how fedora_resource are build to be viewed.
* *

0
src/Form/FedoraResourceDeleteForm.php → islandora/src/Form/FedoraResourceDeleteForm.php

17
src/Form/FedoraResourceEntityInlineForm.php → islandora/src/Form/FedoraResourceEntityInlineForm.php

@ -173,7 +173,8 @@ class FedoraResourceEntityInlineForm extends EntityInlineForm implements InlineF
foreach ($form_state->getErrors() as $name => $message) { foreach ($form_state->getErrors() as $name => $message) {
// $name may be unknown in $form_state and // $name may be unknown in $form_state and
// $form_state->setErrorByName($name, $message) may suppress the error message. // $form_state->setErrorByName($name, $message)
// may suppress the error message.
$form_state->setError($triggering_element, $message); $form_state->setError($triggering_element, $message);
} }
} }
@ -221,7 +222,12 @@ class FedoraResourceEntityInlineForm extends EntityInlineForm implements InlineF
// Invoke all specified builders for copying form values to entity fields. // Invoke all specified builders for copying form values to entity fields.
if (isset($entity_form['#entity_builders'])) { if (isset($entity_form['#entity_builders'])) {
foreach ($entity_form['#entity_builders'] as $function) { foreach ($entity_form['#entity_builders'] as $function) {
call_user_func_array($function, [$entity->getEntityTypeId(), $entity, &$entity_form, &$form_state]); call_user_func_array($function, [
$entity->getEntityTypeId(),
$entity,
&$entity_form,
&$form_state,
]);
} }
} }
} }
@ -232,11 +238,12 @@ class FedoraResourceEntityInlineForm extends EntityInlineForm implements InlineF
* After field_attach_submit() has run and the form has been closed, the form * After field_attach_submit() has run and the form has been closed, the form
* state still contains field data in $form_state->get('field'). Unless that * state still contains field data in $form_state->get('field'). Unless that
* data is removed, the next form with the same #parents (reopened add form, * data is removed, the next form with the same #parents (reopened add form,
* for example) will contain data (i.e. uploaded files) from the previous form. * for example) will contain data (i.e. uploaded files) from the previous
* form.
* *
* @param $entity_form * @param array $entity_form
* The entity form. * The entity form.
* @param $form_state * @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state of the parent form. * The form state of the parent form.
*/ */
public static function submitCleanFormState(&$entity_form, FormStateInterface $form_state) { public static function submitCleanFormState(&$entity_form, FormStateInterface $form_state) {

0
src/Form/FedoraResourceForm.php → islandora/src/Form/FedoraResourceForm.php

0
src/Form/FedoraResourceSettingsForm.php → islandora/src/Form/FedoraResourceSettingsForm.php

0
src/Form/FedoraResourceTypeDeleteForm.php → islandora/src/Form/FedoraResourceTypeDeleteForm.php

0
src/Form/FedoraResourceTypeForm.php → islandora/src/Form/FedoraResourceTypeForm.php

6
src/Form/IslandoraSettingsForm.php → islandora/src/Form/IslandoraSettingsForm.php

@ -1,9 +1,5 @@
<?php <?php
/**
* @file
* Settings form for Islandora.
*/
namespace Drupal\islandora\Form; namespace Drupal\islandora\Form;
use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\ConfigFormBase;
@ -86,5 +82,5 @@ class IslandoraSettingsForm extends ConfigFormBase {
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
} }
}
}

22
src/ParamConverter/UuidEntityConverter.php → islandora/src/ParamConverter/UuidEntityConverter.php

@ -1,25 +1,8 @@
<?php <?php
/**
* @file
* Contains UuidEntityConverter.php
*
* This file is part of the Islandora Project.
*
* (c) Islandora Foundation
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Diego Pino Navarro <dpino@metro.org> https://github.com/diegopino
*/
namespace Drupal\islandora\ParamConverter; namespace Drupal\islandora\ParamConverter;
use Drupal\Core\ParamConverter\EntityConverter; use Drupal\Core\ParamConverter\EntityConverter;
use Drupal\Core\ParamConverter\ParamConverterInterface;
use Drupal\Component\Uuid\Uuid;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
/** /**
@ -30,18 +13,17 @@ use Symfony\Component\Routing\Route;
class UuidEntityConverter extends EntityConverter { class UuidEntityConverter extends EntityConverter {
/** /**
* @inheritDoc * {@inheritdoc}
*/ */
public function convert($value, $definition, $name, array $defaults) { public function convert($value, $definition, $name, array $defaults) {
return $this->entityManager->loadEntityByUuid($name, $value); return $this->entityManager->loadEntityByUuid($name, $value);
} }
/** /**
* @inheritDoc * {@inheritdoc}
*/ */
public function applies($definition, $name, Route $route) { public function applies($definition, $name, Route $route) {
return (!empty($definition['type']) && $definition['type'] == 'uuid'); return (!empty($definition['type']) && $definition['type'] == 'uuid');
} }
} }

9
src/Plugin/Search/FedoraEntitySearch.php → islandora/src/Plugin/Search/FedoraEntitySearch.php

@ -1,8 +1,4 @@
<? <?php
/**
* @file
* Contains \Drupal\islandora\Plugin\Search\FedoraEntitySearch.
*/
namespace Drupal\islandora\Plugin\Search; namespace Drupal\islandora\Plugin\Search;
@ -510,7 +506,7 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces
/** /**
* Indexes a single contact. * Indexes a single contact.
* *
* @param \Drupal\content_entity_example\ContactInterface $entity * @param \Drupal\islandora\FedoraResourceInterface $entity
* The contact to index. * The contact to index.
*/ */
protected function indexFedoraResource(FedoraResourceInterface $entity) { protected function indexFedoraResource(FedoraResourceInterface $entity) {
@ -675,7 +671,6 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces
$advanced = TRUE; $advanced = TRUE;
} }
// Advanced form, keywords fields. // Advanced form, keywords fields.
if ($form_state->getValue('or') != '') { if ($form_state->getValue('or') != '') {
if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state->getValue('or'), $matches)) { if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state->getValue('or'), $matches)) {

0
templates/fedora-resource-content-add-list.html.twig → islandora/templates/fedora-resource-content-add-list.html.twig

0
templates/fedora_resource.html.twig → islandora/templates/fedora_resource.html.twig

97
src/Controller/FedoraResourceAddController.php

@ -1,97 +0,0 @@
<?php
namespace Drupal\islandora\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Class FedoraResourceAddController.
*
* @package Drupal\islandora\Controller
*/
class FedoraResourceAddController extends ControllerBase {
public function __construct(EntityStorageInterface $storage, EntityStorageInterface $type_storage) {
$this->storage = $storage;
$this->typeStorage = $type_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
/** @var EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $container->get('entity_type.manager');
return new static(
$entity_type_manager->getStorage('fedora_resource'),
$entity_type_manager->getStorage('fedora_resource_type')
);
}
/**
* Displays add links for available bundles/types for entity fedora_resource .
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* A render array for a list of the fedora_resource bundles/types that can be added or
* if there is only one type/bunlde defined for the site, the function returns the add page for that bundle/type.
*/
public function add(Request $request) {
$types = $this->typeStorage->loadMultiple();
if ($types && count($types) == 1) {
$type = reset($types);
return $this->addForm($type, $request);
}
if (count($types) === 0) {
return array(
'#markup' => $this->t('You have not created any %bundle types yet. @link to add a new type.', [
'%bundle' => 'Fedora resource',
'@link' => $this->l($this->t('Go to the type creation page'), Url::fromRoute('entity.fedora_resource_type.add_form')),
]),
);
}
return array('#theme' => 'fedora_resource_content_add_list', '#content' => $types);
}
/**
* Presents the creation form for fedora_resource entities of given bundle/type.
*
* @param EntityInterface $fedora_resource_type
* The custom bundle to add.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* A form array as expected by drupal_render().
*/
public function addForm(EntityInterface $fedora_resource_type, Request $request) {
$entity = $this->storage->create(array(
'type' => $fedora_resource_type->id()
));
return $this->entityFormBuilder()->getForm($entity);
}
/**
* Provides the page title for this controller.
*
* @param EntityInterface $fedora_resource_type
* The custom bundle/type being added.
*
* @return string
* The page title.
*/
public function getAddFormTitle(EntityInterface $fedora_resource_type) {
return t('Create of bundle @label',
array('@label' => $fedora_resource_type->label())
);
}
}
Loading…
Cancel
Save