Build a release notes markdown file.

@param array $release An associative array, where the key is the
component ID and the value is structured data describing the
release.
@return void
427210
private function createReleaseNotes(array $release)
    {
        $buildDir = $this->rootPath .'/build';
        $locationTemplate = $buildDir . '/release-%s.md';

        if (!is_dir($buildDir)) {
            mkdir($buildDir);
        }

        $umbrella = $release[self::DEFAULT_COMPONENT];
        $location = sprintf($locationTemplate, $umbrella['version']);

        unset($release[self::DEFAULT_COMPONENT]);

        ksort($release);

        $notes = [];
        foreach ($release as $key => $component) {
            $messages = [];
            foreach ($component['messages'] as $message) {
                $messages[] = sprintf('* %s', $message);
            }

            $notes[] = sprintf('### google/%s v%s', $key, $component['version'])
                . PHP_EOL . PHP_EOL . implode(PHP_EOL, $messages);
        }

        $template = file_get_contents(__DIR__ .'/templates/release-notes.md.txt');
        $template = str_replace('{version}', $umbrella['version'], $template);
        $template = str_replace('{notes}', implode(PHP_EOL . PHP_EOL, $notes), $template);

        file_put_contents($location, $template);

        return $location;
    }
1356257
protected function addChanges(SimpleXMLElement $releaseNode, Release $release)
	{
		$changesNode = $releaseNode->addChild('changes');

		foreach ($release->getAllChanges() as $type => $changes)
		{
			$typeNode = $changesNode->addChild('type');
			$typeNode->addAttribute('name', $type);

			foreach ($changes as $change)
			{
				$typeNode->addChild('change', $change);
			}
		}
	}
1297269
protected function recordDoc(array $comments)
    {
        $callable = $this->phpdocFactory;

        foreach ($comments as $comment) {
            if ($comment instanceof Doc) {
                $this->doc[] = $callable($comment->getText(), $this->context);
            }
        }
    }
923307
private function build(): void
    {
        $prefix = "<?xml version='1.0' encoding='UTF-8'?>" . $this->glue() . "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>";
        $suffix = '</feed>';

        $xml = collect($this->filters)->map(function ($items) {
            return $this->buildEntry($items);
        })->implode($this->glue());

        $this->xml = collect([$prefix, $xml, $suffix])->implode($this->glue());

        if ($this->writeFile) {
            $this->filesystem->dumpFile($this->outputFile, $this->xml);
        }
    }
656732
private function exportentry($record) {
    // Replacing tags
        $patterns = array();
        $replacement = array();

        $files = array();
    // Then we generate strings to replace for normal tags
        $format = $this->get('exporter')->get('format');
        foreach ($this->fields as $field) {
            $patterns[]='[['.$field->field->name.']]';
            if (is_callable(array($field, 'get_file'))) {
                if (!$file = $field->get_file($record->id)) {
                    $replacement[] = '';
                    continue; // probably left empty
                }
                $replacement[] = $format->file_output($file);
                $this->get('exporter')->copy_existing_file($file);
                $files[] = $file;
            } else {
                $replacement[] = $field->display_browse_field($record->id, 'singletemplate');
            }
        }

    // Replacing special tags (##Edit##, ##Delete##, ##More##)
        $patterns[]='##edit##';
        $patterns[]='##delete##';
        $patterns[]='##export##';
        $patterns[]='##more##';
        $patterns[]='##moreurl##';
        $patterns[]='##user##';
        $patterns[]='##approve##';
        $patterns[]='##disapprove##';
        $patterns[]='##comments##';
        $patterns[] = '##timeadded##';
        $patterns[] = '##timemodified##';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = '';
        $replacement[] = userdate($record->timecreated);
        $replacement[] = userdate($record->timemodified);

        // actual replacement of the tags
        return array(str_ireplace($patterns, $replacement, $this->data->singletemplate), $files);
    }
528550
protected function buildStructuredHeaders(): void
    {
        $this->structuredHeaders = array();
        $headers = $this->entry[PoTokens::TRANSLATED];
        $headers = ($headers === null) ? array() : $headers;
        $full = implode('', $headers);
        $headers = explode("\n", $full);
        // split on ':'
        $pattern = '/([a-z0-9\-]+):\s*(.*)/i';
        foreach ($headers as $h) {
            if (preg_match($pattern, trim($h), $matches)) {
                $this->structuredHeaders[strtolower($matches[1])] = array(
                    'key' => $matches[1],
                    'value' => $matches[2],
                );
            }
        }
    }
187544
protected function buildFields()
    {
        $this->debug->groupCollapsed(__METHOD__);
        $status = &$this->status;
        $persist = $this->persist;
        $pageI = $this->persist->get('i');
        $submitFieldCount = 0;
        $keys = \array_keys($this->currentFields);
        foreach ($keys as $k) {
            $field = $this->currentFields[$k];
            unset($this->currentFields[$k]);
            if (!\is_object($field)) {
                $field = $this->buildField($field, $k);
            }
            $field->pageI = $pageI;
            if ($field->attribs['type'] == 'newPage') {
                $this->debug->info('possible new page', $field->attribs['value']);
                if ($field->isRequired()) {
                    $this->debug->log('adding new page', $field->attribs['value']);
                    $status['additionalPages'][] = $field;
                }
                continue;
            } elseif ($field->attribs['type'] == 'submit') {
                $submitFieldCount++;
            } elseif ($field->attribs['type'] == 'file') {
                $status['multipart'] = true;
            }
            $k = \is_int($k)
                ? $field->attribs['name']
                : $k;
            $this->currentFields[$k] = $field;
        }
        if ($submitFieldCount < 1) {
            $this->debug->info('submit field not set');
            $fieldArray = array(
                'type'  => 'submit',
                'label' => ( !empty($status['additionalPages']) || $persist->pageCount() > $persist->pageCount(true)+1 )
                            ? 'Continue'
                            : 'Submit',
                'attribs' => array('class' => array('btn btn-primary', 'replace')),
                'tagOnly' => true,
            );
            $this->currentFields['submit'] = $this->fieldFactory->build($fieldArray);
            $this->debug->log('array_keys(currentFields)', \array_keys($this->currentFields));
        }
        if ($status['multipart']) {
            $this->debug->log('<a target="_blank" href="http://www.php.net/manual/en/ini.php">post_max_size</a> = '.Str::getBytes(\ini_get('post_max_size')));
            $this->debug->log('<a target="_blank" href="http://www.php.net/manual/en/ini.php">upload_max_filesize</a> = '.Str::getBytes(\ini_get('upload_max_filesize')));
        }
        $this->debug->groupEnd();
    }
148147
protected static function generateConfig($releases, $phpFile)
    {
        $data = '<?php' . PHP_EOL;
        $data .= '// DO NOT EDIT! This file has been automatically generated.' . PHP_EOL;
        $data .= '// Run composer update to fetch a new version.' . PHP_EOL;
        $data .= 'return array(' . PHP_EOL;
        foreach ($releases as $version => $date) {
            $data .= '   \'' . $version . '\' => \'' . $date . '\',' . PHP_EOL;
        }
        $data .= ');' . PHP_EOL;

        file_put_contents($phpFile, $data);
    }
938651
private function doUpdate(array $changes) {
        $db     = $this->db();
        $entity = $this->dao()->getEntityMapping();
        $table  = $entity->getTableName();

        // collect identity infos
        $identity = $entity->getIdentity();
        $idColumn = $identity->getColumn();
        $idValue  = $identity->convertToDBValue($this->getObjectId(), $db);

        // collect version infos
        $versionMapping = $versionName = $versionColumn = $oldVersion = null;
        //if ($versionMapping = $entity->getVersion()) {
        //    $versionName   = $versionMapping->getName();
        //    $versionColumn = $versionMapping->getColumn();
        //    $oldVersion    = $object->getSnapshot()->$versionName;        // TODO: implement dirty check via snapshot
        //    $oldVersion    = $versionMapping->convertToDBValue($oldVersion, $db);
        //}

        // create SQL
        $sql = 'update '.$table.' set';                                     // update table
        foreach ($changes as $name => $value) {                             //    set ...
            $mapping     = $entity->getProperty($name);                     //        ...
            $columnName  = $mapping->getColumn();                           //        ...
            $columnValue = $mapping->convertToDBValue($value, $db);         //        column1 = value1,
            $sql .= ' '.$columnName.' = '.$columnValue.',';                 //        column2 = value2,
        }                                                                   //        ...
        $sql  = strLeft($sql, -1);                                          //        ...
        $sql .= ' where '.$idColumn.' = '.$idValue;                         //    where id = value
        if ($versionMapping) {                                              //        ...
            $op   = $oldVersion=='null' ? 'is':'=';                         //        ...
            $sql .= ' and '.$versionColumn.' '.$op.' '.$oldVersion;         //      and version = oldVersion
        }

        // execute SQL and check for concurrent modifications
        if ($db->execute($sql)->lastAffectedRows() != 1) {
            if ($versionMapping) {
                $this->reload();
                $msg = 'expected version: '.$oldVersion.', found version: '.$this->$versionName;
            }
            else $msg = 'record not found';
            throw new ConcurrentModificationException('Error updating '.get_class($this).' (oid='.$this->getObjectId().'), '.$msg);
        }
        return true;
    }
511804
private function generateDocumentConstructor(array $metadata)
    {
        $fields = [];

        foreach ($metadata['properties'] as $prop) {
            if ($prop['annotation'] == 'embedded' && isset($prop['property_multiple']) && $prop['property_multiple']) {
                $fields[] = sprintf('%s$this->%s = new Collection();', $this->spaces, $prop['field_name']);
            }
        }

        return $this->prefixWithSpaces(
            str_replace('<fields>', implode("\n", $fields), $this->constructorTemplate)
        ) . "\n";
    }
1288783
public function format(array $record)
    {
        $output = $this->addTitle($record['level_name'], $record['level']);
        $output .= '<table cellspacing="1" width="100%" class="monolog-output">';

        if (isset($record['context']['bug'])) {
            $bug = $record['context']['bug'];
            if ($bug instanceof Bug) {
                $output .= $this->addRow('Bug ID', $bug->getId());
                $output .= $this->addRow('Bug Title', $bug->getTitle());
                $output .= $this->addRow('Task Title', $bug->getTask()->getTitle());
                $output .= $this->addRow('Bug Message', $record['message']);
            }
            if (isset($record['context']['path'])) {
                $path = $record['context']['path'];
                if ($path instanceof Path) {
                    $embeddedTable = '<table cellspacing="1" width="100%">';
                    foreach ($path as $index => $step) {
                        $embeddedTable .= $this->addRow('Step', $this->convertToString($index + 1));
                        $embeddedTable .= $this->addRow('Transition', $this->convertToString($step[0]));
                        $embeddedTable .= $this->addRow('Data', $this->convertToString($step[1]));
                        $embeddedTable .= $this->addRow('Places', $this->convertToString(implode('|', $step[2])));

                        $transitionName = $step[0];
                        $subject = $record['context']['subject'];
                        if ($transitionName && $subject instanceof AbstractSubject) {
                            $url = $subject->getScreenshotUrl($bug->getId(), $index);
                            if ($url) {
                                $embeddedTable .= $this->addRow('Screenshot', $this->addImage($url), false);
                            }
                        }
                    }
                    $embeddedTable .= '</table>';
                    $output .= $this->addRow('Steps', $embeddedTable, false);
                }
            }
        }

        return $output.'</table>';
    }
1138055
private function publishAssets($register)
    {
        $build = $this->path . '/assets/build.php';
        if (!file_exists($build)) {
            return;
        }

        if (!$register) {
            DI::getInstance()->get('asset-manager')->remove(null, $this->plugin);
        }

        // update manifest
        $manifest = $this->getManifest('assets');
        /** @noinspection PhpIncludeInspection */
        $list = file_exists($manifest) ? include $manifest : [];
        if ($register) {
            // make absolute path to relative path
            $basePath = base_path();
            $basePathLength = strlen($basePath);
            /** @noinspection PhpIncludeInspection */
            $assets = include $build;
            foreach ($assets as $asset => $sources) {
                foreach ($sources as $i => $source) {
                    if (substr($source, 0, $basePathLength) == $basePath) {
                        $assets[$asset][$i] = substr($source, $basePathLength + 1);
                    }
                }
            }
            // insert asset build information
            /** @noinspection PhpIncludeInspection */
            $list[$this->plugin] = $assets;
        }
        else {
            // remove asset build information
            unset($list[$this->plugin]);
        }
        $this->saveArray($manifest, $list);

        if ($register) {
            DI::getInstance()->get('asset-manager')->publish(null, true, $this->plugin);
        }
    }
537790
public static function apply_version_and_release() {
        global $CFG;

        if ($CFG->backup_version < backup::VERSION) {
            set_config('backup_version', backup::VERSION);
            set_config('backup_release', backup::RELEASE);
        }
    }
751621
public function release( $version = 'dev-master' ) {
        $package = "youzanyun/open-sdk";
		list( $vendor, $name ) = explode( '/', $package );
		if ( empty( $vendor ) || empty( $name ) ) {
			return;
		}
		$this->_mkdir( 'release' );
		$this->taskExec( "composer create-project {$package} {$name} {$version}" )
		     ->dir( __DIR__ . '/release' )
		     ->arg( '--prefer-dist' )
		     ->arg( '--no-dev' )
		     ->run();
		$this->taskExec( 'composer remove composer/installers --update-no-dev' )
		     ->dir( __DIR__ . "/release/{$name}" )
		     ->run();
		$this->taskExec( 'composer dump-autoload --optimize' )
		     ->dir( __DIR__ . "/release/{$name}" )
		     ->run();
		$zipFile = "release/{$vendor}-{$name}.zip";
		$this->_remove( $zipFile );
		$this->taskPack( $zipFile )
		     ->addDir( $name, "release/{$name}" )
		     ->run();
		if ( ! empty( $name ) ) {
			$this->_deleteDir( "release/{$name}" );
		}
	}
124134
protected function write( array $record )
    {
        if ($this->_debugbar->hasCollector('log') && $this->_debugbar->shouldCollect('log') ) {
            $type = array_keys( $this->_levelMap,$record['level_name']);
            $this->_debugbar->getCollector('log')
                ->add( $record['message'], end($type), microtime(true), $record['context']);
        }
    }
845615
protected function setLink(Release $release, $line)
	{
		$matches = [];

		if (preg_match('/^## \[([\w\.-\.]+)\](?:\[(\w+)\])?/', $line, $matches))
		{
			if (count($matches) >= 3)
			{
				$release->setLink($matches[2]);
				$release->setLinkName($matches[2]);
			}
			else
			{
				$release->setLink($matches[1]);
			}
		}
	}
1343247
private function readRelease( $domNode )
	{
		$release	= array();
		foreach( $domNode->childNodes as $node )
		{
			$nodeName	= $node->nodeName;
			switch( $nodeName )
			{
				case 'deps':
					foreach( $node->childNodes as $dep )
						$release['dependencies'][]	= $this->getNodeValue( $dep );
					break;
				case 'filelist':
					foreach( $node->childNodes as $file )
						$release['files'][]	= $this->getNodeAttributes( $file );
					break;
				default:
					$release[$nodeName]	= $this->getNodeValue( $node );
					break;
			}
		}
		return $release;
	}