Write the docker-compose.yml file.

@return bool
177303
public function writeConfig()
    {

        // Create the app/environment folder
        $fs = new FileSystem();
        try {
            $fs->mkdir($this->getDockerComposePath());
        } catch (IOExceptionInterface $e) {
            return false;
        }

        // Create the environments docker-compose file.
        $dumper = new Dumper();
        try {
            $fs->remove($this->getDockerComposePath().'/docker-compose.yml');
            $fs->dumpFile($this->getDockerComposePath().'/docker-compose.yml', $dumper->dump($this->getDockerComposeArray(), 10));

            return true;
        } catch (IOExceptionInterface $e) {
            return false;
        }
    }
723029
public function writeTerraYml()
    {
        // Create the environment's terra.yml file.
        $fs = new Filesystem();
        try {
            $fs->dumpFile($this->getSourcePath().'/.terra.yml', $this->getTerraYmlContent());
            return true;
        } catch (IOExceptionInterface $e) {
            return false;
        }
    }
1222798
public function write()
	{
		// do we have something to write?
		if ( ! empty($this->keys) or ! empty($this->data) or ! empty($this->flash))
		{
			parent::write();

			// rotate the session id if needed
			$this->rotate(false);

			// record the last update time of the session
			$this->keys['updated'] = $this->time->get_timestamp();

			// session payload
			$payload = $this->_serialize(array($this->keys, $this->data, $this->flash));

			// create the session file
			$this->_write_memcached($this->keys['session_id'], $payload);

			// was the session id rotated?
			if ( isset($this->keys['previous_id']) and $this->keys['previous_id'] != $this->keys['session_id'])
			{
				// point the old session file to the new one, we don't want to lose the session
				$payload = $this->_serialize(array('rotated_session_id' => $this->keys['session_id']));
				$this->_write_memcached($this->keys['previous_id'], $payload);
			}

			$this->_set_cookie(array($this->keys['session_id']));
		}

		return $this;
	}
760626
public function write()
    {
        $file_content = null;

        foreach ($this->data_ini_file as $key_1 => $groupe) {
            $file_content .= PHP_EOL.'['.$key_1.']'.PHP_EOL;
            foreach ($groupe as $key_2 => $value_2) {
                if (is_array($value_2)) {
                    foreach ($value_2 as $key_3 => $value_3) {
                        $file_content .= $key_2.'['.$key_3.']='.self::encode($value_3).PHP_EOL;
                    }
                } else {
                    $file_content .= $key_2.'='.self::encode($value_2).PHP_EOL;
                }
            }
        }

        $file_content = preg_replace('#^'.PHP_EOL.'#', '', $file_content);
        $result = @file_put_contents($this->path_to_ini_file, $file_content);
        if (false === $result) {
            throw new \Exception(sprintf('Unable to write in the file ini: %s', $this->path_to_ini_file));
        }

        return ($result !== false) ? true : false;
    }
1086587
protected function generateDockerCompose($dev = false)
    {
        $docker_compose = new DockerComposeConfig();
        $docker_compose->setVersion(static::DOCKER_VERSION);

        $has_proxy = $this->hasTraefik() ? true : false;

        foreach ($this->getServices() as $name => $info) {
            if (!isset($info['type'])) {
                continue;
            }
            $type = $info['type'];
            $instance = self::loadService($this, $type, $name);

            if (!$dev && $has_proxy) {
                $instance->setInternal();
                if (isset($info['bind_ports']) && $info['bind_ports']) {
                    $instance->bindPorts();
                }
            }

            if (isset($info['version'])) {
                $instance->setVersion($info['version']);
            }
            $volumes = $dev ? $instance->devVolumes() : $instance->volumes();
            $service = $dev ? $instance->devService() : $instance->getService();

            if (!empty($volumes)) {
                $docker_compose->setVolumes($volumes);
            }

            if (!$service->isEmpty()) {
                $docker_compose->setService($name, $service);
            }
        }

        if (!$dev && $has_proxy) {
            $docker_compose->setNetworks([
                'internal' => [
                    'external' => 'false',
                ],
                static::TRAEFIK_NETWORK => [
                    'external' => [
                        'name' => static::TRAEFIK_NETWORK
                    ]
                ]
            ]);
        }

        return $docker_compose;
    }
1042465
protected function getDockerComposeFiles()
    {
        $files = [
            'docker-compose.yml',
        ];
        $root = ProjectX::projectRoot();

        // Add docker compose dev configurations.
        $path = "{$root}/docker-compose-dev.yml";
        if ($this->hasDockerSync()
            && $this->useDockerSync && file_exists($path)) {
            $files[] = $path;
        }

        return $files;
    }
342638
public static function configExists($dir = null)
    {
        $dir = ($dir === null) ? getcwd() : $dir;
        return file_exists($dir . '/docker-compose.yml');
    }
1082748
def write_yaml(filename, content):
    '''
    
    '''

    y = _yaml.dump(content, indent=4, default_flow_style=False)
    if y:
        return write_file(filename, y)
1298333
private function write()
    {
        $cache = serialize($this->records);
        flock($this->file, LOCK_EX);
        rewind($this->file);
        ftruncate($this->file, 0);
        $bytes = fwrite($this->file, $cache);
        flock($this->file, LOCK_UN);

        return $bytes === strlen($cache);
    }
469361
public function write_version()
    {
        $this->_version_written = true;
        if (!is_null($this->version())) {
            return $this->writeLine('version: '.$this->version().PHP_EOL, 'Net_LDAP2_LDIF error: unable to write version');
        }
    }
1122953
function rewriteDockerCompose(compose) {
  const services = compose.services;
  if (!services) {
    return compose;
  }
  const host = services._host;
  delete services._host;
  Object.keys(services).forEach((k) => {
    if (!isHelperContainer(k)) {
      mergeWith(services[k], host);
    }
  });
  return compose;
}
1251109
public function compile()
    {
        $container = $this->container->getContainer();
        foreach ($container as $dependencyIndex => $dependency) {
            $code = $this->dependencyCompiler->getCode($dependency);
            ($this->dependencySaver)($dependencyIndex, $code);
        }
        $this->savePointcuts($this->container);
        \file_put_contents($this->scriptDir . ScriptInjector::MODULE, \serialize($this->module));
    }
1021796
public function write()
    {
        
        $tf = $this->getTranslationFile();
        $buffer = "<?php\n";
        foreach ($tf->getTranslationUnits() as $tu){
            // Prevent empty messages.
            if ($tu->getSource() != '' && $tu->getTarget() != ''){
                $escapes = array("\\", '$', '"', "\n", "\t", "\v", "\r", "\f");
                $replace = array("\\\\", '\\$', '\\"', "\\n", "\\t", "\\v", "\\r", "\\f");
                $source = str_replace($escapes, $replace, $tu->getSource());
                $target = str_replace($escapes, $replace, $tu->getTarget());
                $buffer .= '$GLOBALS[\'__l10n\']["' . $source . '"]="' . $target . '";' . "\n";
            }
        }
        $buffer .= "\n?>";
        
        file_put_contents($this->getFilePath(), $buffer);
        
    }
638924
def __write_docker_compose(path, docker_compose, already_existed):
    '''
    
    '''
    if path.lower().endswith(('.yml', '.yaml')):
        file_path = path
        dir_name = os.path.dirname(path)
    else:
        dir_name = path
        file_path = os.path.join(dir_name, DEFAULT_DC_FILENAMES[0])
    if os.path.isdir(dir_name) is False:
        os.mkdir(dir_name)
    try:
        with salt.utils.files.fopen(file_path, 'w') as fl:
            fl.write(salt.utils.stringutils.to_str(docker_compose))
    except EnvironmentError:
        return __standardize_result(False,
                                    'Could not write {0}'.format(file_path),
                                    None, None)
    project = __load_project_from_file_path(file_path)
    if isinstance(project, dict):
        if not already_existed:
            os.remove(file_path)
        return project
    return file_path
129006
public function writeManifest() {
        $written = false;
        if (!empty ($this->vehicles)) {
            if (!empty($this->attributes['setup-options']) && is_array($this->attributes['setup-options'])) {
                $cacheManager = $this->xpdo->getCacheManager();
                $cacheManager->copyFile($this->attributes['setup-options']['source'],$this->path . $this->signature . '/setup-options.php');

                $this->attributes['setup-options'] = $this->signature . '/setup-options.php';
            }
            $manifest = array(
                xPDOTransport::MANIFEST_VERSION => $this->manifestVersion,
                xPDOTransport::MANIFEST_ATTRIBUTES => $this->attributes,
                xPDOTransport::MANIFEST_VEHICLES => $this->vehicles
            );
            $content = var_export($manifest, true);
            $cacheManager = $this->xpdo->getCacheManager();
            if ($content && $cacheManager) {
                $fileName = $this->path . $this->signature . '/manifest.php';
                $content = "<?php return {$content};";
                if (!($written = $cacheManager->writeFile($fileName, $content))) {
                    $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error writing manifest to ' . $fileName);
                }
            }
        }
        return $written;
    }
1320516
protected function _writeFiles()
    {
        $overwriteAll = false;
        if (!empty($this->params['overwrite'])) {
            $overwriteAll = true;
        }
        foreach ($this->_storage as $domain => $sentences) {
            $output = $this->_writeHeader();
            foreach ($sentences as $sentence => $header) {
                $output .= $header . $sentence;
            }

            // Remove vendor prefix if present.
            $slashPosition = strpos($domain, '/');
            if ($slashPosition !== false) {
                $domain = substr($domain, $slashPosition + 1);
            }

            $filename = str_replace('/', '_', $domain) . '.pot';
            $File = new File($this->_output . $filename);
            $response = '';
            while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
                $this->out();
                $response = $this->in(
                    sprintf('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename),
                    ['y', 'n', 'a'],
                    'y'
                );
                if (strtoupper($response) === 'N') {
                    $response = '';
                    while (!$response) {
                        $response = $this->in('What would you like to name this file?', null, 'new_' . $filename);
                        $File = new File($this->_output . $response);
                        $filename = $response;
                    }
                } elseif (strtoupper($response) === 'A') {
                    $overwriteAll = true;
                }
            }
            $File->write($output);
            $File->close();
        }
    }
986129
public function baseWrite()
    {
        set_error_handler(function(){});
        if ($this->transport === 'ssl') {
            $len = fwrite($this->_socket, $this->_sendBuffer, 8192);
        } else {
            $len = fwrite($this->_socket, $this->_sendBuffer);
        }
        restore_error_handler();
        if ($len === strlen($this->_sendBuffer)) {
            $this->bytesWritten += $len;
            Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);
            $this->_sendBuffer = '';
            // Try to emit onBufferDrain callback when the send buffer becomes empty.
            if ($this->onBufferDrain) {
                try {
                    call_user_func($this->onBufferDrain, $this);
                } catch (\Exception $e) {
                    Worker::log($e);
                    exit(250);
                } catch (\Error $e) {
                    Worker::log($e);
                    exit(250);
                }
            }
            if ($this->_status === self::STATUS_CLOSING) {
                $this->destroy();
            }
            return true;
        }
        if ($len > 0) {
            $this->bytesWritten += $len;
            $this->_sendBuffer = substr($this->_sendBuffer, $len);
        } else {
            self::$statistics['send_fail']++;
            $this->destroy();
        }
    }