Skip to content

Commit

Permalink
Refactor Service classes for better names (#3946)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-m authored May 3, 2023
1 parent 91d836a commit 66cd8e3
Show file tree
Hide file tree
Showing 76 changed files with 1,890 additions and 2,037 deletions.
10 changes: 10 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ plugins:
channel: beta
config:
standard: "Drupal,DrupalPractice"
checks:
Drupal Commenting Deprecated IncorrectTextLayout:
enabled: false
Drupal Commenting Deprecated DeprecatedMissingSeeTag:
enabled: false
Drupal Semantics FunctionTriggerError TriggerErrorTextLayoutRelaxed:
enabled: false
Drupal Commenting Deprecated DeprecatedWrongSeeUrlFormat:
enabled: false

exclude_patterns:
- "cypress/"
- "config/"
Expand Down
2 changes: 1 addition & 1 deletion dkan.module
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

function dkan_update_8001() {
/** @var $metastoreService \Drupal\metastore\Service */
/** @var $metastoreService \Drupal\metastore\MetastoreService */
$metastoreService = \Drupal::service('dkan.metastore.service');
foreach ($metastoreService->getAll('dataset') as $dataset) {
$metastoreService->publish('dataset', $dataset->identifier);
Expand Down
8 changes: 4 additions & 4 deletions modules/common/src/DatasetInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Drupal\common;

use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\datastore\Service as Datastore;
use Drupal\datastore\DatastoreService;
use Drupal\datastore\Service\Info\ImportInfo;
use Drupal\metastore\ResourceMapper;
use Drupal\metastore\Storage\DataFactory;
Expand All @@ -29,7 +29,7 @@ class DatasetInfo implements ContainerInjectionInterface {
/**
* Datastore.
*
* @var \Drupal\datastore\Service
* @var \Drupal\datastore\DatastoreService
*/
protected $datastore;

Expand Down Expand Up @@ -60,10 +60,10 @@ public function setStorage(DataFactory $dataFactory) {
/**
* Set datastore.
*
* @param \Drupal\datastore\Service $datastore
* @param \Drupal\datastore\DatastoreService $datastore
* Datastore service.
*/
public function setDatastore(Datastore $datastore) {
public function setDatastore(DatastoreService $datastore) {
$this->datastore = $datastore;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/common/tests/src/Traits/CleanUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait CleanUp {
*
*/
private function removeHarvests() {
/** @var \Drupal\harvest\Service $service */
/** @var \Drupal\harvest\HarvestService $service */
$service = \Drupal::service('dkan.harvest.service');
foreach ($service->getAllHarvestIds() as $id) {
$service->deregisterHarvest($id);
Expand Down
6 changes: 3 additions & 3 deletions modules/common/tests/src/Unit/DatasetInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Drupal\common\DatasetInfo;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\datastore\Service as Datastore;
use Drupal\datastore\DatastoreService;
use Drupal\datastore\Service\Info\ImportInfo;
use Drupal\datastore\Storage\DatabaseTable;
use Drupal\metastore\ResourceMapper;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testGather() {
public function testGetStorage() {
// Make some dependencies.
// Initially, we'll make the datastore service return the table object.
$datastore_service = $this->getMockBuilder(Datastore::class)
$datastore_service = $this->getMockBuilder(DatastoreService::class)
->disableOriginalConstructor()
->onlyMethods(['getStorage'])
->getMockForAbstractClass();
Expand Down Expand Up @@ -180,7 +180,7 @@ public function testUuidNotFound() {
->add(DataFactory::class, 'getInstance', NodeData::class)
->add(NodeData::class, 'getEntityLatestRevision', NULL);
$mockDatastore = (new Chain($this))
->add(Datastore::class);
->add(DatastoreService::class);
$mockResourceMapper = (new Chain($this))
->add(ResourceMapper::class);

Expand Down
6 changes: 3 additions & 3 deletions modules/datastore/datastore.services.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
dkan.datastore.service:
class: \Drupal\datastore\Service
class: \Drupal\datastore\DatastoreService
arguments:
- '@dkan.datastore.service.resource_localizer'
- '@dkan.datastore.service.factory.import'
Expand All @@ -11,7 +11,7 @@ services:

dkan.datastore.service.post_import:
class: \Drupal\datastore\Service\PostImport
arguments:
arguments:
- '@database'
- '@dkan.metastore.resource_mapper'

Expand Down Expand Up @@ -82,7 +82,7 @@ services:
- '@dkan.datastore.database'

dkan.datastore.sql_endpoint.service:
class: \Drupal\datastore\SqlEndpoint\Service
class: \Drupal\datastore\SqlEndpoint\DatastoreSqlEndpointService
arguments:
- '@dkan.datastore.service'
- '@config.factory'
Expand Down
6 changes: 3 additions & 3 deletions modules/datastore/src/Controller/ImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\common\JsonResponseTrait;
use Drupal\Component\Uuid\Uuid;
use Drupal\datastore\Service;
use Drupal\datastore\DatastoreService;
use Drupal\metastore\MetastoreApiResponse;
use Drupal\metastore\Reference\ReferenceLookup;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -25,15 +25,15 @@ class ImportController implements ContainerInjectionInterface {
/**
* Datastore Service.
*
* @var \Drupal\datastore\Service
* @var \Drupal\datastore\DatastoreService
*/
protected $datastoreService;

/**
* Api constructor.
*/
public function __construct(
Service $datastoreService,
DatastoreService $datastoreService,
MetastoreApiResponse $metastoreApiResponse,
ReferenceLookup $referenceLookup
) {
Expand Down
Loading

0 comments on commit 66cd8e3

Please sign in to comment.