Browse Source

Add travis config and clean up to coding standards (#12)

* Clean up to Drupal coding standards

Add travis config

* Remove codesniffer from travis-setup.sh

* Not needed right now and breaks php on hhvm

* Deleted too much

* Revert type hinting.
pull/756/head
Jared Whiklo 8 years ago committed by dannylamb
parent
commit
38747f1cfd
  1. 39
      .travis.yml
  2. 34
      composer.json
  3. 26
      fedora_resource.page.inc
  4. 8
      islandora.module
  5. 166
      src/Controller/FedoraResourceAddController.php
  6. 145
      src/Entity/FedoraResource.php
  7. 4
      src/FedoraResourceHtmlRouteProvider.php
  8. 10
      src/FedoraResourceInterface.php
  9. 12
      src/FedoraResourceViewBuilder.php
  10. 19
      src/Form/FedoraResourceEntityInlineForm.php
  11. 6
      src/Form/IslandoraSettingsForm.php
  12. 22
      src/ParamConverter/UuidEntityConverter.php
  13. 11
      src/Plugin/Search/FedoraEntitySearch.php
  14. 14
      tests/scripts/line_endings.sh
  15. 81
      tests/scripts/travis_setup.sh

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/tests/scripts/line_endings.sh .
- php vendor/bin/phpcs --standard=Drupal *.module src
- 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

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"
}
]
}

26
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;
@ -41,16 +41,16 @@ function template_preprocess_fedora_resource(array &$variables) {
} }
/** /**
* Prepares variables for a custom entity type creation list templates. * Prepares variables for a custom entity type creation list templates.
* *
* Default template: fedora_resource-content-add-list.html.twig. * Default template: fedora_resource-content-add-list.html.twig.
* *
* @param array $variables * @param array $variables
* An associative array containing: * An associative array containing:
* - content: An array of fedora_resource-types. * - content: An array of fedora_resource-types.
* *
* @see block_content_add_page() * @see block_content_add_page()
*/ */
function template_preprocess_fedora_resource_content_add_list(&$variables) { function template_preprocess_fedora_resource_content_add_list(&$variables) {
$variables['types'] = array(); $variables['types'] = array();
$query = \Drupal::request()->query->all(); $query = \Drupal::request()->query->all();
@ -60,11 +60,11 @@ function template_preprocess_fedora_resource_content_add_list(&$variables) {
'fedora_resource_type' => $type->id(), 'fedora_resource_type' => $type->id(),
), array('query' => $query))), ), array('query' => $query))),
'description' => array( 'description' => array(
'#markup' => $type->label(), '#markup' => $type->label(),
), ),
'title' => $type->label(), 'title' => $type->label(),
'localized_options' => array( 'localized_options' => array(
'query' => $query, 'query' => $query,
), ),
); );
} }

8
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:
@ -51,8 +51,8 @@ function islandora_theme() {
} }
/** /**
* Implements hook_theme_suggestions_HOOK(). * Implements hook_theme_suggestions_HOOK().
*/ */
function islandora_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'];
@ -81,4 +81,4 @@ function islandora_rdf_namespaces() {
'ore' => 'http://www.openarchives.org/ore/terms/', 'ore' => 'http://www.openarchives.org/ore/terms/',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
); );
} }

166
src/Controller/FedoraResourceAddController.php

@ -4,13 +4,11 @@ namespace Drupal\islandora\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
/** /**
* Class FedoraResourceAddController. * Class FedoraResourceAddController.
* *
@ -18,80 +16,104 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class FedoraResourceAddController extends ControllerBase { class FedoraResourceAddController extends ControllerBase {
public function __construct(EntityStorageInterface $storage, EntityStorageInterface $type_storage) { /**
$this->storage = $storage; * The Entity storage.
$this->typeStorage = $type_storage; *
} * @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/** /**
* {@inheritdoc} * The Entity storage type.
*/ *
public static function create(ContainerInterface $container) { * @var \Drupal\Core\Entity\EntityStorageInterface
/** @var EntityTypeManagerInterface $entity_type_manager */ */
$entity_type_manager = $container->get('entity_type.manager'); protected $typeStorage;
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. * FedoraResourceAddController constructor.
* *
* @param EntityInterface $fedora_resource_type * @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The custom bundle to add. * The Entity storage.
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Drupal\Core\Entity\EntityStorageInterface $type_storage
* The current request object. * The Entity storage type.
* */
* @return array public function __construct(EntityStorageInterface $storage, EntityStorageInterface $type_storage) {
* A form array as expected by drupal_render(). $this->storage = $storage;
*/ $this->typeStorage = $type_storage;
public function addForm(EntityInterface $fedora_resource_type, Request $request) { }
$entity = $this->storage->create(array(
'type' => $fedora_resource_type->id() /**
)); * {@inheritdoc}
return $this->entityFormBuilder()->getForm($entity); */
} 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')
);
}
/** /**
* Provides the page title for this controller. * Displays add links for available bundles/types for entity fedora_resource.
* *
* @param EntityInterface $fedora_resource_type * @param \Symfony\Component\HttpFoundation\Request $request
* The custom bundle/type being added. * The current request object.
* *
* @return string * @return array
* The page title. * 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
public function getAddFormTitle(EntityInterface $fedora_resource_type) { * function returns the add page for that bundle/type.
return t('Create of bundle @label', */
array('@label' => $fedora_resource_type->label()) 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())
);
}
} }

145
src/Entity/FedoraResource.php

@ -65,18 +65,28 @@ use Drupal\user\UserInterface;
* field_ui_base_route = "entity.fedora_resource_type.edit_form" * field_ui_base_route = "entity.fedora_resource_type.edit_form"
* ) * )
*/ */
class FedoraResource extends ContentEntityBase implements FedoraResourceInterface{ class FedoraResource extends ContentEntityBase implements FedoraResourceInterface {
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}
*/ */
@ -301,56 +310,56 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE); ->setDisplayConfigurable('view', TRUE);
$fields['fedora_has_parent'] = BaseFieldDefinition::create('entity_reference') $fields['fedora_has_parent'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Fedora has Parent')) ->setLabel(t('Fedora has Parent'))
->setDescription(t('Parent Fedora Resource.')) ->setDescription(t('Parent Fedora Resource.'))
->setRevisionable(TRUE) ->setRevisionable(TRUE)
->setSetting('target_type', 'fedora_resource') ->setSetting('target_type', 'fedora_resource')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\islandora\Entity\FedoraResource::getFedoraRoot') ->setDefaultValueCallback('Drupal\islandora\Entity\FedoraResource::getFedoraRoot')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', array( ->setDisplayOptions('view', array(
'label' => 'hidden', 'label' => 'hidden',
'type' => 'author', 'type' => 'author',
'weight' => 0, 'weight' => 0,
)) ))
->setDisplayOptions('form', array( ->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete', 'type' => 'entity_reference_autocomplete',
'weight' => 5, 'weight' => 5,
'settings' => array( 'settings' => array(
'match_operator' => 'CONTAINS', 'match_operator' => 'CONTAINS',
'size' => '60', 'size' => '60',
'autocomplete_type' => 'tags', 'autocomplete_type' => 'tags',
'placeholder' => '', 'placeholder' => '',
), ),
)) ))
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE); ->setDisplayConfigurable('view', TRUE);
$fields['ldp_contains'] = 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)
->setSetting('target_type', 'fedora_resource_type') ->setSetting('target_type', 'fedora_resource_type')
->setSetting('handler', 'default') ->setSetting('handler', 'default')
->setTranslatable(TRUE) ->setTranslatable(TRUE)
->setDisplayOptions('view', array( ->setDisplayOptions('view', array(
'label' => 'hidden', 'label' => 'hidden',
'type' => 'author', 'type' => 'author',
'weight' => 0, 'weight' => 0,
)) ))
->setDisplayOptions('form', array( ->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete', 'type' => 'entity_reference_autocomplete',
'weight' => 5, 'weight' => 5,
'settings' => array( 'settings' => array(
'match_operator' => 'CONTAINS', 'match_operator' => 'CONTAINS',
'size' => '60', 'size' => '60',
'autocomplete_type' => 'tags', 'autocomplete_type' => 'tags',
'placeholder' => '', 'placeholder' => '',
), ),
)) ))
->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE); ->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string') $fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name')) ->setLabel(t('Name'))

4
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

@ -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);
} }

12
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.
* *
@ -23,4 +15,4 @@ use Drupal\node\NodeViewBuilder;
class FedoraResourceViewBuilder extends NodeViewBuilder { class FedoraResourceViewBuilder extends NodeViewBuilder {
} }

19
src/Form/FedoraResourceEntityInlineForm.php

@ -171,9 +171,10 @@ class FedoraResourceEntityInlineForm extends EntityInlineForm implements InlineF
$form_display->validateFormValues($entity, $entity_form, $form_state); $form_display->validateFormValues($entity, $entity_form, $form_state);
$entity->setValidationRequired(FALSE); $entity->setValidationRequired(FALSE);
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) {

6
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

@ -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');
} }
} }

11
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)) {
@ -839,4 +834,4 @@ class FedoraResourceSearch extends ConfigurableSearchPluginBase implements Acces
} }
} }
} }

14
tests/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
tests/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
Loading…
Cancel
Save