public static function write(Blueprint $blueprint) { $tag = "BlueprintWriter: write()"; Log::debug("{$tag}"); $xml = $blueprint->asXml(); $blueprint_file_name = $blueprint->signature(); $blueprint_file_path = BPConfig::$path_blueprints . $blueprint_file_name; if (is_writable(BPConfig::$path_blueprints)) { if ($file = fopen($blueprint_file_path, "w")) { if ($bytes = fwrite($file, $xml)) { Log::debug("{$tag}: {$bytes} bytes written to {$file}"); return $xml; } else { throw new Exception("Unable to write to file"); } fclose($file); } else { throw new Exception("Unable to open file for writing"); } } else { throw new Exception("Target directory is not writable"); } }