Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed Jan 10, 2019
1 parent 2011b6d commit e33225a
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rdf_entity.install
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ function rdf_entity_update_8002() {
* Split out the SPARQL entity storage.
*/
function rdf_entity_update_8003() {
\Drupal::service('module_installer')->install(['sparql_entity_storage']);

// 1. Rename rdf_entity.graph.* > sparql_entity_storage.graph.*.
// 2. Rename third_party.rdf_entity > third_party.sparql_entity_storage in
// each field storage.
Expand Down
63 changes: 63 additions & 0 deletions src/RdfEntityServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

declare(strict_types = 1);

namespace Drupal\rdf_entity;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\Update\UpdateKernel;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Reference;

class RdfEntityServiceProvider implements ServiceModifierInterface {

/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
return;
$kernel = $container->get('kernel');

// Act only on update.
if (!in_array(get_class($kernel), [UpdateKernel::class, 'Drush\Drupal\UpdateKernel'])) {
return;
}

$container->removeDefinition('date.formatter');

// $container->removeDefinition('twig.extension');
// $container->removeDefinition('migrate_run.commands');

$remove = ['date.formatter' => TRUE];
while ($remove) {
$a = [];
foreach ($container->getDefinitions() as $key => $definition) {
foreach ($definition->getArguments() as $argument) {
if ($argument instanceof Reference) {
$argument_key = $argument->__toString();
if (isset($remove[$argument_key])) {
print_r("a $argument_key\n");
print "r $key\n";
$container->removeDefinition($key);
$a[$key] = TRUE;
}
}
}
}

$remove = $a;
print_r($remove);
}


// Remove any aliases which point to undefined services.
$aliases = $container->getAliases();
foreach ($aliases as $key => $alias) {
if (!$container->has((string) $alias)) {
$container->removeAlias($key);
}
}
}

}

0 comments on commit e33225a

Please sign in to comment.