diff --git a/relaxed.info.yml b/relaxed.info.yml index 41532a0..8fa833a 100644 --- a/relaxed.info.yml +++ b/relaxed.info.yml @@ -2,14 +2,14 @@ name: 'RELAXed Web Services' type: module description: 'Provides a RESTful API that exposes all content entities over UUID endpoints. Utility endpoints are also provided subscribing to changes and handling content replication.' package: Web services -core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - - drupal:rest - - drupal:basic_auth - - multiversion:multiversion - - replication:replication - - drupal:system (>=8.3.x) + - rest + - basic_auth + - multiversion + - replication + - system (>=8.3.x) test_dependencies: - - workspace:workspace - - key:key - - encrypt:encrypt + - workspace + - key + - encrypt diff --git a/relaxed.services.yml b/relaxed.services.yml index c85aa65..6f8af32 100644 --- a/relaxed.services.yml +++ b/relaxed.services.yml @@ -1,7 +1,7 @@ services: paramconverter.docid: class: Drupal\relaxed\ParamConverter\DocIdConverter - arguments: ['@entity.manager', '@multiversion.entity_index.uuid', '@multiversion.entity_index.rev', '@multiversion.entity_index.rev.tree'] + arguments: ['@entity_type.manager', '@multiversion.entity_index.uuid', '@multiversion.entity_index.rev', '@multiversion.entity_index.rev.tree'] tags: - { name: paramconverter, priority: 30 } paramconverter.db: @@ -11,7 +11,7 @@ services: - { name: paramconverter, priority: 20 } paramconverter.entity_uuid: class: Drupal\relaxed\ParamConverter\EntityUuidConverter - arguments: ['@entity.manager', '@multiversion.entity_index.uuid'] + arguments: ['@entity_type.manager', '@multiversion.entity_index.uuid'] tags: - { name: paramconverter, priority: 20 } workspace.negotiator.relaxed: diff --git a/src/CouchdbReplicator.php b/src/CouchdbReplicator.php index 844dc1b..dd6a1f9 100644 --- a/src/CouchdbReplicator.php +++ b/src/CouchdbReplicator.php @@ -84,7 +84,7 @@ class CouchdbReplicator implements ReplicatorInterface{ $couchdb_task->setParameters($task->getParameters()); $changes_limit = \Drupal::config('replication.settings')->get('changes_limit'); $couchdb_task->setLimit($changes_limit ?: $task->getLimit()); - $bulk_docs_limit = \Drupal::config('replication.settings')->get('bulk_docs_limit'); + $bulk_docs_limit = \Drupal::config('replication.settings')->get('changes_limit'); $couchdb_task->setBulkDocsLimit($bulk_docs_limit ?: $task->getBulkDocsLimit()); } diff --git a/src/Entity/RemoteListBuilder.php b/src/Entity/RemoteListBuilder.php index 737a99b..4069ca4 100644 --- a/src/Entity/RemoteListBuilder.php +++ b/src/Entity/RemoteListBuilder.php @@ -4,14 +4,15 @@ namespace Drupal\relaxed\Entity; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Routing\UrlGeneratorTrait; +#use Drupal\Core\Routing\UrlGeneratorTrait; +use Drupal\Core\Url; /** * Provides a listing of Remote entities. */ class RemoteListBuilder extends ConfigEntityListBuilder { - use UrlGeneratorTrait; + #use UrlGeneratorTrait; /** * @var bool @@ -79,8 +80,9 @@ class RemoteListBuilder extends ConfigEntityListBuilder { ]; // Indicate to the user that there is a problem with one of the endpoints. if ($this->hasError) { - drupal_set_message( - $this->t('One or more problems were detected with your remotes. Check the status report for more information.', [':status' => $this->url('system.status')]), + \Drupal::messenger()->addMessage( + $this->t('One or more problems were detected with your remotes. Check the status report for more information.', + [':status' => Url::fromRoute('system.status')]), 'error' ); } diff --git a/src/EventSubscriber/ResourceResponseSubscriber.php b/src/EventSubscriber/ResourceResponseSubscriber.php index 3ff5eb0..6e9ddfa 100644 --- a/src/EventSubscriber/ResourceResponseSubscriber.php +++ b/src/EventSubscriber/ResourceResponseSubscriber.php @@ -3,7 +3,8 @@ namespace Drupal\relaxed\EventSubscriber; use Drupal\rest\ResourceResponseInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +#use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Drupal\rest\EventSubscriber\ResourceResponseSubscriber as CoreResourceResponseSubscriber; @@ -12,10 +13,10 @@ class ResourceResponseSubscriber extends CoreResourceResponseSubscriber { /** * Serializes ResourceResponse relaxed response's data. * - * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event + * @param \Symfony\Component\HttpKernel\Event\ResponseEvent $event * The event to process. */ - public function onResponse(FilterResponseEvent $event) { + public function onResponse(ResponseEvent $event) { $response = $event->getResponse(); if (!$response instanceof ResourceResponseInterface) { return; diff --git a/src/Form/RemoteDeleteForm.php b/src/Form/RemoteDeleteForm.php index fcbeb11..92d8b48 100644 --- a/src/Form/RemoteDeleteForm.php +++ b/src/Form/RemoteDeleteForm.php @@ -55,12 +55,13 @@ class RemoteDeleteForm extends EntityConfirmFormBase { // workspace pointer that is being deleted. /** @var Replication $deployment */ foreach ($deployments as $deployment) { - $replication_status = $deployment->getReplicationStatus(); + $replication_status = $deployment->get('replication_status')->value; if (!in_array($replication_status, [Replication::QUEUED, Replication::REPLICATING])) { continue; } + $deployment->set('fail_info', t('The workspace pointer ' . + 'does not exist, this could be cause by the missing target workspace.')); $deployment - ->setReplicationFailInfo(t('The workspace pointer does not exist, this could be cause by the missing target workspace.')) ->setReplicationStatusFailed() ->save(); } diff --git a/src/ParamConverter/DocIdConverter.php b/src/ParamConverter/DocIdConverter.php index c7827d0..6bfd7bb 100644 --- a/src/ParamConverter/DocIdConverter.php +++ b/src/ParamConverter/DocIdConverter.php @@ -3,6 +3,7 @@ namespace Drupal\relaxed\ParamConverter; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\ParamConverter\ParamConverterInterface; use Drupal\multiversion\Entity\Index\RevisionIndexInterface; use Drupal\multiversion\Entity\Index\RevisionTreeIndexInterface; @@ -12,7 +13,7 @@ use Symfony\Component\Routing\Route; class DocIdConverter implements ParamConverterInterface { /** - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManager */ protected $entityManager; @@ -32,12 +33,12 @@ class DocIdConverter implements ParamConverterInterface { protected $revTree; /** - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManager $entity_manager * @param \Drupal\multiversion\Entity\Index\UuidIndexInterface $uuid_index * @param \Drupal\multiversion\Entity\Index\RevisionIndexInterface $rev_index * @param \Drupal\multiversion\Entity\Index\RevisionTreeIndexInterface $rev_tree */ - public function __construct(EntityManagerInterface $entity_manager, UuidIndexInterface $uuid_index, RevisionIndexInterface $rev_index, RevisionTreeIndexInterface $rev_tree) { + public function __construct(EntityTypeManager $entity_manager, UuidIndexInterface $uuid_index, RevisionIndexInterface $rev_index, RevisionTreeIndexInterface $rev_tree) { $this->entityManager = $entity_manager; $this->uuidIndex = $uuid_index; $this->revIndex = $rev_index; diff --git a/src/RemotePointer.php b/src/RemotePointer.php index 1fbefa8..5025f6c 100644 --- a/src/RemotePointer.php +++ b/src/RemotePointer.php @@ -120,14 +120,12 @@ class RemotePointer implements RemotePointerInterface { ->loadByProperties(['target' => $pointer->id()]); /** @var Replication $deployment */ foreach ($deployments as $deployment) { - $replication_status = $deployment->getReplicationStatus(); + $replication_status = $deployment->get('replication_status')->value; if (!in_array($replication_status, [Replication::QUEUED, Replication::REPLICATING])) { continue; } - $deployment - ->setReplicationStatusFailed() - ->setReplicationFailInfo(t('The workspace pointer does not exist, this could be caused by the missing source or target workspace.')) - ->save(); + $deployment->set('fail_info', t('The workspace pointer does not exist, this could be caused by the missing source or target workspace.')); + $deployment->setReplicationStatusFailed()->save(); } $pointer->delete(); } diff --git a/src/Tests/AttachmentResourceTest.php b/src/Tests/AttachmentResourceTest.php index b8d983e..7c79a9e 100644 --- a/src/Tests/AttachmentResourceTest.php +++ b/src/Tests/AttachmentResourceTest.php @@ -220,7 +220,7 @@ class AttachmentResourceTest extends ResourceTestBase { $this->assertTrue(isset($data['rev']), 'PUT request returned a revision hash.'); /** @var \Drupal\file\FileInterface $file */ - $files = \Drupal::entityManager()->getStorage('file')->loadByProperties(['uri' => $file_uri]); + $files = \Drupal::entityTypeManager()->getStorage('file')->loadByProperties(['uri' => $file_uri]); $file = reset($files); $this->assertTrue(!empty($file), 'File was saved.'); $this->assertEqual($file->getFileUri(), $file_uri, 'File was saved with the correct URI.'); diff --git a/src/Tests/ResourceTestBase.php b/src/Tests/ResourceTestBase.php index 43cd8f1..3d3634c 100644 --- a/src/Tests/ResourceTestBase.php +++ b/src/Tests/ResourceTestBase.php @@ -79,7 +79,7 @@ abstract class ResourceTestBase extends RESTTestBase { $this->workspace->save(); $this->dbname = $this->workspace->getMachineName(); - $this->entityManager = $this->container->get('entity.manager'); + $this->entityManager = $this->container->get('entity_type.manager'); $this->entityTypeManager = $this->container->get('entity_type.manager'); $this->entityRepository = $this->container->get('entity.repository'); $this->revTree = $this->container->get('multiversion.entity_index.rev.tree'); diff --git a/tests/bin/run-couchdb.sh b/tests/bin/run-couchdb.sh index 458e0e7..fbbc47c 100644 --- a/tests/bin/run-couchdb.sh +++ b/tests/bin/run-couchdb.sh @@ -1,12 +1,19 @@ #!/bin/sh -docker run -d -p $COUCH_PORT:5984 apache/couchdb:$COUCHDB_VERSION --with-haproxy --with-admin-party-please -n 1 +if [ $COUCHDB_VERSION = "2.3.0" ]; then + docker run -d -p 3001:5984 apache/couchdb:$COUCHDB_VERSION --with-haproxy --with-admin-party-please -n 1 + export COUCH_PORT=3001 +elif [ $COUCHDB_VERSION = "1.6.1" ]; then + export COUCH_PORT=5984 +else + echo "Unknown CouchDB version." +fi npm -g install npm@latest # Wait for couchdb to start, add CORS. npm install add-cors-to-couchdb while [ '200' != $(curl -s -o /dev/null -w %{http_code} http://127.0.0.1:${COUCH_PORT}) ]; do - echo "Waiting for couch to load..."; + echo waiting for couch to load... ; sleep 1; done ./node_modules/.bin/add-cors-to-couchdb http://127.0.0.1:${COUCH_PORT} diff --git a/tests/modules/relaxed_test/relaxed_test.info.yml b/tests/modules/relaxed_test/relaxed_test.info.yml index 4d4cdf3..1c51d6e 100644 --- a/tests/modules/relaxed_test/relaxed_test.info.yml +++ b/tests/modules/relaxed_test/relaxed_test.info.yml @@ -1,10 +1,10 @@ -name: 'Relaxed API Tests' +name: 'Relaxed API tests' type: module description: 'Configures a site for external testing.' package: Testing version: VERSION -core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - - entity:entity_test - - drupal:taxonomy - - relaxed:relaxed + - entity_test + - taxonomy + - relaxed