Skip to content

Commit

Permalink
feat: add unset() for better yaml code
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jan 28, 2023
1 parent 3828ae8 commit 564b9d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function getModuleInfo()
{
return [
'title' => 'RockMigrations',
'version' => '2.13.0',
'version' => '2.14.0',
'summary' => 'The Ultimate Automation and Deployment-Tool for ProcessWire',
'autoload' => 2,
'singular' => true,
Expand Down Expand Up @@ -3530,6 +3530,12 @@ public function uninstallModule($name)
$this->wire->session->noMigrate = false;
}

public function unset(&$array, $property)
{
if (!array_key_exists($property, $array)) return;
unset($array[$property]);
}

/**
* PHP var_export() with short array syntax (square brackets) indented 2 spaces.
*
Expand Down Expand Up @@ -3777,6 +3783,9 @@ public function yaml($path, $data = null)

// write yaml data to file
if ($data) {
// remove properties that are not helpful in yaml files
$this->unset($data, 'configPhpHash');

$yaml = Yaml::dump($data, 99, 2);
$this->wire->files->filePutContents($path, $yaml);
return $yaml;
Expand Down

0 comments on commit 564b9d6

Please sign in to comment.