From b073e26cd1fb694f0ec87cdfc47e7e132d7d3716 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 26 Jan 2016 11:47:10 -0400 Subject: [PATCH 1/3] Add alter during Tuque connection construction. --- includes/tuque_wrapper.inc | 16 +++++++++++++++- islandora.api.php | 13 +++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/includes/tuque_wrapper.inc b/includes/tuque_wrapper.inc index f075c402..6a38ad4a 100644 --- a/includes/tuque_wrapper.inc +++ b/includes/tuque_wrapper.inc @@ -322,7 +322,21 @@ class IslandoraFedoraObject extends FedoraObject { } } -class IslandoraRepositoryConnection extends RepositoryConnection {} +class IslandoraRepositoryConnection extends RepositoryConnection { + /** + * Constructor. + * + * Invokes parent, but additionally invokes an alter to allow modules to + * effect the configuration of the connection. + */ + public function __construct($url = NULL, $username = NULL, $password = NULL) { + if ($url === NULL) { + $url = static::FEDORA_URL; + } + parent::__construct($url, $username, $password); + drupal_alter('islandora_repository_connection_construction', $this); + } +} class IslandoraFedoraApi extends FedoraApi { diff --git a/islandora.api.php b/islandora.api.php index c88f0c20..a53b7e99 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -873,3 +873,16 @@ function hook_islandora_edit_datastream_registry_alter(&$edit_registry, $context 'url' => "islandora/custom_form/{$context['object']->id}/{$context['datastream']->id}" ); } + +/** + * Permit configuration of connection parameters. + * + * @param IslandoraRepositoryConnection $instance + * The connection being constructed. See the relevant Tuque ancestor classes + * for the particulars. + * + * @see https://github.com/Islandora/tuque/blob/1.x/HttpConnection.php + */ +function hook_islandora_repository_connection_construction_alter($instance) { + $instance->userAgent = "Tuque/cURL"; +} From 0b3af6b9821a23f8d63e1c121c386d0b1baa5320 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 26 Jan 2016 11:48:07 -0400 Subject: [PATCH 2/3] Fix random coding standard issues. --- islandora.api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora.api.php b/islandora.api.php index a53b7e99..8334a2e3 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -868,9 +868,9 @@ function hook_islandora_edit_datastream_registry_alter(&$edit_registry, $context unset($edit_registry['xml_form_builder_edit_form_registry']); } // Add custom form to replace the removed form builder edit_form. - $edit_registry['somemodule_custom_form'] = array( + $edit_registry['somemodule_custom_form'] = array( 'name' => t('Somemodule Custom Form'), - 'url' => "islandora/custom_form/{$context['object']->id}/{$context['datastream']->id}" + 'url' => "islandora/custom_form/{$context['object']->id}/{$context['datastream']->id}", ); } From 2b2bd54f3c135b0fc78708dc24577b8db1aabb44 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 28 Jan 2016 14:08:07 -0400 Subject: [PATCH 3/3] Add hinting and use more ancestor. --- islandora.api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/islandora.api.php b/islandora.api.php index 8334a2e3..1d0d9872 100644 --- a/islandora.api.php +++ b/islandora.api.php @@ -877,12 +877,12 @@ function hook_islandora_edit_datastream_registry_alter(&$edit_registry, $context /** * Permit configuration of connection parameters. * - * @param IslandoraRepositoryConnection $instance + * @param RepositoryConnection $instance * The connection being constructed. See the relevant Tuque ancestor classes * for the particulars. * * @see https://github.com/Islandora/tuque/blob/1.x/HttpConnection.php */ -function hook_islandora_repository_connection_construction_alter($instance) { +function hook_islandora_repository_connection_construction_alter(RepositoryConnection $instance) { $instance->userAgent = "Tuque/cURL"; }