Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce dependency on getdkan/contracts (part 1) #4177

Draft
wants to merge 22 commits into
base: 2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"fmizzell/maquina": "^1.1.1",
"fylax/forceutf8": "^3.0",
"getdkan/contracts": "^1.1.3",
"getdkan/csv-parser": "^1.3.2",
"getdkan/csv-parser": "dev-no-contracts",
"getdkan/file-fetcher": "^5.0.4",
"getdkan/harvest": "^1.0.4",
"getdkan/pdlt": "^0.1.7",
Expand Down
13 changes: 9 additions & 4 deletions modules/common/src/Storage/DatabaseTableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

namespace Drupal\common\Storage;

use Contracts\BulkRetrieverInterface;
use Contracts\BulkStorerInterface;
use Contracts\RemoverInterface;
use Contracts\RetrieverInterface;
use Contracts\StorerInterface;
use Contracts\BulkRetrieverInterface;
use Contracts\BulkStorerInterface;
use Contracts\CountableInterface;

/**
* Databaset table interface.
*/
interface DatabaseTableInterface extends StorerInterface, RetrieverInterface, RemoverInterface, BulkStorerInterface, CountableInterface, BulkRetrieverInterface {
interface DatabaseTableInterface extends
BulkRetrieverInterface,
BulkStorerInterface,
\Countable,
RemoverInterface,
RetrieverInterface,
StorerInterface {

/**
* Remove the table from the database.
Expand Down
13 changes: 8 additions & 5 deletions modules/common/src/Storage/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

namespace Drupal\common\Storage;

use Contracts\SorterInterface;
use Contracts\ConditionerInterface;
use Contracts\OffsetterInterface;
use Contracts\LimiterInterface;
use Contracts\OffsetterInterface;
use Contracts\SorterInterface;

/**
* DKAN API Query data object.
*
* @todo Should we remove these external interfaces and only declare
* QueryInterface?
*/
class Query implements
SorterInterface,
ConditionerInterface,
LimiterInterface,
OffsetterInterface,
LimiterInterface {
SorterInterface {

/**
* The collection of records (usually, a database table) to query against.
Expand Down Expand Up @@ -135,7 +138,7 @@ public function filterByProperty($property) {
* @param string $value
* Property value to filter against.
* @param bool $case
* Case sensitive filter?
* Case-sensitive filter?
*/
public function conditionByIsEqualTo(string $property, string $value, bool $case = FALSE) {
$this->conditions[] = (object) [
Expand Down
1 change: 0 additions & 1 deletion modules/common/tests/src/Traits/CleanUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Drupal\Tests\common\Traits;

use Drupal\node\Entity\Node;
use FileFetcher\FileFetcher;

/**
*
Expand Down
1 change: 0 additions & 1 deletion modules/common/tests/src/Unit/DkanApiDocsGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Drupal\common\DkanApiDocsGenerator;
use Drupal\common\Plugin\DkanApiDocsBase;
use Drupal\common\Plugin\DkanApiDocsPluginManager;
use Drupal\common\Plugin\OpenApiSpec;
use MockChain\Chain;
use PHPUnit\Framework\TestCase;

Expand Down
4 changes: 2 additions & 2 deletions modules/data_dictionary_widget/data_dictionary_widget.module
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @file
* Module for creating Data Dictionary Widget.
*/

use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
Expand Down Expand Up @@ -77,7 +77,7 @@ function data_dictionary_widget_form_alter(&$form, &$form_state, $form_id) {
$formObject = $form_state->getFormObject();
$target_form_ids = ['node_data_edit_form', 'node_data_form'];

if ($formObject instanceof \Drupal\Core\Entity\EntityFormInterface && in_array($form_id, $target_form_ids)) {
if ($formObject instanceof EntityFormInterface && in_array($form_id, $target_form_ids)) {
$entity = $formObject->getEntity();
$data_type = $entity->get('field_data_type')->value;
if (isset($form["field_json_metadata"]["widget"][0]["dictionary_fields"])) {
Expand Down
8 changes: 4 additions & 4 deletions modules/datastore/src/Plugin/QueueWorker/ImportJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Drupal\datastore\Plugin\QueueWorker;

use Contracts\ParserInterface;
use CsvParser\Parser\ParserInterface;
use Drupal\common\Storage\DatabaseTableInterface;
use ForceUTF8\Encoding;
use Procrastinator\Job\AbstractPersistentJob;
use Procrastinator\Result;
use ForceUTF8\Encoding;

/**
* Procrastinator job for importing to the datastore.
Expand Down Expand Up @@ -82,7 +82,7 @@ class ImportJob extends AbstractPersistentJob {
/**
* Parser object.
*
* @var \Contracts\ParserInterface
* @var \CsvParser\Parser\ParserInterface
*/
protected $parser;

Expand Down Expand Up @@ -378,7 +378,7 @@ protected function assertUniqueHeaders(array $header) {
/**
* Get the parser object.
*
* @return \Contracts\ParserInterface
* @return \CsvParser\Parser\ParserInterface
* Parser object.
*/
public function getParser(): ParserInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Drupal\common\Storage\FileFetcherJobStoreFactory;
use Drupal\datastore\Plugin\QueueWorker\ImportJob;
use Drupal\common\Storage\JobStore;
use Drupal\common\Storage\JobStoreFactory;
use Drupal\datastore\Service\Info\ImportInfo;
use Drupal\KernelTests\KernelTestBase;
use Drupal\metastore\ResourceMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Drupal\Tests\datastore\Unit\Plugin\QueueWorker;

use Contracts\ParserInterface;
use CsvParser\Parser\Csv;
use Contracts\Mock\Storage\Memory;
use CsvParser\Parser\Csv;
use CsvParser\Parser\ParserInterface;
use Drupal\common\Storage\DatabaseTableInterface;
use Drupal\datastore\DatastoreResource;
use Drupal\datastore\Plugin\QueueWorker\ImportJob;
use Drupal\common\Storage\DatabaseTableInterface;
use Procrastinator\Result;
use PHPUnit\Framework\TestCase;
use Procrastinator\Result;

/**
* Unit tests for Importer class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@

use Contracts\Mock\Storage\Memory;
use CsvParser\Parser\Csv;
use Drupal\common\FileFetcher\FileFetcherFactory;
use Drupal\datastore\DatastoreResource;
use Drupal\datastore\Plugin\QueueWorker\ImportJob;
use Drupal\common\Storage\JobStore;
use Drupal\common\Storage\JobStoreFactory;
use Drupal\datastore\Service\Info\ImportInfo;
use Drupal\datastore\Service\Info\ImportInfoList;
use Drupal\Tests\datastore\Unit\Plugin\QueueWorker\TestMemStorage;
use FileFetcher\FileFetcher;
use MockChain\Chain;
use MockChain\Options;
use PHPUnit\Framework\TestCase;
use Procrastinator\Job\Job;
use Procrastinator\Result;
use Symfony\Component\DependencyInjection\Container;

/**
* @coversDefaultClass \Drupal\datastore\Service\Info\ImportInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Drupal\common\FileFetcher\FileFetcherFactory;
use Drupal\common\Storage\DatabaseTableInterface;
use Drupal\common\Storage\FileFetcherJobStoreFactory;
use Drupal\common\Storage\JobStoreFactory;
use Drupal\common\Util\DrupalFiles;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\File\FileSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Drupal\datastore\DatastoreResource;
use Drupal\datastore\Storage\DatabaseTable;
use Drupal\datastore\Storage\DatabaseTableFactory;
use Drupal\indexer\IndexManager;
use MockChain\Chain;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function store($data, string $id = NULL) : string {
* @param string $id
* Dataset node UUID.
*
* @return \Contracts\HydratableInterface|string|null
* @return \Procrastinator\HydratableInterface
* JSON-encoded result of query.
*/
public function retrieve(string $id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Drupal\Tests\metastore_search\Unit\Plugin\search_api\datasource;

use _PHPStan_7d6f0f6a4\Psr\Container\ContainerInterface;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManager;
Expand Down
10 changes: 5 additions & 5 deletions modules/metastore/src/Controller/MetastoreRevisionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Drupal\metastore\Controller;

use Contracts\FactoryInterface as ContractsFactoryInterface;
use Drupal\common\JsonResponseTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Contracts\FactoryInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\common\JsonResponseTrait;
use Drupal\metastore\Exception\MissingObjectException;
use Drupal\metastore\MetastoreApiResponse;
use Drupal\metastore\Storage\MetastoreEntityStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ class MetastoreRevisionController implements ContainerInjectionInterface {
*
* @var \Contracts\FactoryInterface
*/
private ContractsFactoryInterface $storageFactory;
private FactoryInterface $storageFactory;

/**
* Inherited.
Expand All @@ -72,7 +72,7 @@ public static function create(ContainerInterface $container) {
*/
public function __construct(
MetastoreApiResponse $apiResponse,
ContractsFactoryInterface $storageFactory
FactoryInterface $storageFactory
) {
$this->apiResponse = $apiResponse;
$this->storageFactory = $storageFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Drupal\Tests\metastore\Unit\Commands;

use Drupal\Core\Logger\LoggerChannel;
use Drupal\metastore\Commands\MetastoreCommands;
use Drupal\metastore\Storage\Data;
use Drupal\metastore\Storage\DataFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Drupal\common\DataResource;
use Drupal\common\Events\Event;
use Drupal\common\Storage\JobStore;
use Drupal\metastore\EventSubscriber\MetastoreSubscriber;
use Drupal\metastore\MetastoreService;
use Drupal\metastore\ReferenceLookupInterface;
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
<env name="SIMPLETEST_BASE_URL" value="http://web"/>
<env name="SIMPLETEST_DB" value="mysql://drupal:123@db/drupal"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<!-- env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=0&amp;max[self]=0&amp;max[direct]=0"/ -->
</php>
</phpunit>