diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index d1048ea..25c996b 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\StringTranslation\TranslationManager; -use Symfony\Component\Yaml\Dumper; +use Drupal\Core\Serialization\Yaml; /** * The ConfigManager provides helper functions for the configuration system. @@ -101,11 +101,8 @@ public function diff(StorageInterface $source_storage, StorageInterface $target_ // The output should show configuration object differences formatted as YAML. // But the configuration is not necessarily stored in files. Therefore, they // need to be read and parsed, and lastly, dumped into YAML strings. - $dumper = new Dumper(); - $dumper->setIndentation(2); - - $source_data = explode("\n", $dumper->dump($source_storage->read($name), PHP_INT_MAX)); - $target_data = explode("\n", $dumper->dump($target_storage->read($name), PHP_INT_MAX)); + $source_data = explode("\n", Yaml::encode($source_storage->read($name))); + $target_data = explode("\n", Yaml::encode($target_storage->read($name))); // Check for new or removed files. if ($source_data === array('false')) { diff --git a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php index cd7a17d..e68e60e 100644 --- a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php +++ b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php @@ -7,12 +7,12 @@ namespace Drupal\Core\DependencyInjection; +use Drupal\Core\Serialization\Yaml; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Yaml\Parser; /** * YamlFileLoader loads YAML files service definitions. @@ -194,8 +194,7 @@ protected function parseDefinition($id, $service, $filename) { * The file content. */ protected function loadFile($filename) { - $parser = new Parser(); - return $this->validate($parser->parse(file_get_contents($filename)), $filename); + return $this->validate(Yaml::decode(file_get_contents($filename)), $filename); } /** diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 17b4239..81a3b21 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -8,9 +8,9 @@ namespace Drupal\Core\Extension; use Drupal\Component\Graph\Graph; -use Symfony\Component\Yaml\Parser; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Serialization\Yaml; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -819,8 +819,7 @@ protected function removeCacheBins($module) { // Remove any cache bins defined by a module. $service_yaml_file = drupal_get_path('module', $module) . "/$module.services.yml"; if (file_exists($service_yaml_file)) { - $parser = new Parser; - $definitions = $parser->parse(file_get_contents($service_yaml_file)); + $definitions = Yaml::decode(file_get_contents($service_yaml_file)); if (isset($definitions['services'])) { foreach ($definitions['services'] as $id => $definition) { if (isset($definition['tags'])) { diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php index 46a14d4..d386024 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php @@ -7,8 +7,8 @@ namespace Drupal\config\Tests; +use Drupal\Core\Serialization\Yaml; use Drupal\simpletest\WebTestBase; -use Symfony\Component\Yaml\Yaml; /** * Tests the user interface for importing/exporting a single configuration. @@ -111,12 +111,11 @@ public function testImport() { */ public function testImportSimpleConfiguration() { $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); - $yaml = new Yaml(); $config = \Drupal::config('system.site')->set('name', 'Test simple import'); $edit = array( 'config_type' => 'system.simple', 'config_name' => $config->getName(), - 'import' => $yaml->dump($config->get()), + 'import' => Yaml::encode($config->get()), ); $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration'))); diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php index d430bd3..39c2e62 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/FileStorageTest.php @@ -8,7 +8,7 @@ namespace Drupal\config\Tests\Storage; use Drupal\Core\Config\FileStorage; -use Symfony\Component\Yaml\Yaml; +use Drupal\Core\Serialization\Yaml; /** * Tests FileStorage controller operations. @@ -33,7 +33,7 @@ function setUp() { protected function read($name) { $data = file_get_contents($this->storage->getFilePath($name)); - return Yaml::parse($data); + return Yaml::decode($data); } protected function insert($name, $data) { diff --git a/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php b/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php index 5e8e1ce..0522e95 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/StaticMenuLinks.php @@ -6,7 +6,8 @@ */ namespace Drupal\menu_link; -use Drupal\Component\Discovery\YamlDiscovery; + +use Drupal\Core\Discovery\YamlDiscovery; use Drupal\Core\Extension\ModuleHandlerInterface; /** @@ -60,7 +61,7 @@ public function getLinks() { /** * Creates a YAML discovery for menu links. * - * @return \Drupal\Component\Discovery\YamlDiscovery + * @return \Drupal\Core\Discovery\YamlDiscovery * An YAML discovery instance. */ protected function getDiscovery() { diff --git a/core/modules/system/lib/Drupal/system/Tests/Installer/DistributionProfileTest.php b/core/modules/system/lib/Drupal/system/Tests/Installer/DistributionProfileTest.php index 4e3ae04..4049bb7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Installer/DistributionProfileTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Installer/DistributionProfileTest.php @@ -7,8 +7,8 @@ namespace Drupal\system\Tests\Installer; +use Drupal\Core\Serialization\Yaml; use Drupal\simpletest\InstallerTestBase; -use Symfony\Component\Yaml\Yaml; /** * Tests the installer translation detection. @@ -45,7 +45,7 @@ protected function setUp() { // File API functions are not available yet. $path = $this->siteDirectory . '/profiles/mydistro'; mkdir($path, 0777, TRUE); - file_put_contents("$path/mydistro.info.yml", Yaml::dump($this->info, PHP_INT_MAX, 2)); + file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info)); file_put_contents("$path/mydistro.profile", "