This repository has been archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2011b6d
commit e33225a
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
||
} |