Publish Revision

@return void
964179
public function publishRevision()
    {
        if (empty($this->publishedDate)) {
            $this->publishedDate = new \DateTime();
        }

        $this->published = true;
    }
1241465
public function listen()
    {
        $revisionsCollection = $this->getRevisionsCollection();
        $document = $this->document;

        $createRevisionCallback = function () use ($revisionsCollection, $document) {
            // create new revision
            $revisionsCollection
                ->createDocument()
                ->setDocumentData($document->getOriginalData())
                ->save();
        };

        $this->document->onBeforeUpdate($createRevisionCallback, PHP_INT_MAX);
        $this->document->onBeforeDelete($createRevisionCallback, PHP_INT_MAX);
    }
233334
private function publishContentType()
    {
        $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier('Content');
        $contentTypeCreateStruct = $this->fieldConstructionObject['contentType'];
        $contentTypeDraft = $this->contentTypeService->createContentType(
            $contentTypeCreateStruct,
            array($contentTypeGroup)
        );
        $this->contentTypeService->publishContentTypeDraft($contentTypeDraft);
        $contentTypeIdentifier = $this->fieldConstructionObject['contentType']->identifier;
        $contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
        $this->fieldConstructionObject['contentType'] = $contentType;
        $this->fieldConstructionObject['objectState'] = self::CONTENT_TYPE_PUBLISHED;
    }
1165598
function publish($id, $previous)
    {
        $this->requestDecorator->setId($id  . '/published');
        $this->requestDecorator->addHeader('X-Contentful-Version', $previous['sys']['version']);
        $result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
        $this->refresh();
        return $result;
    }
927069
public function publish($dest = null)
    {
        $this->yell('Publishing Peridot docs');
        if (!$dest) {
            $dest = __DIR__ . '/../peridot-php.github.io';
        }
        $cwd = getcwd();
        chdir($dest);
        $this->taskGitStack()
            ->add('-A')
            ->commit('auto-update')
            ->pull()
            ->push()
            ->run();
        chdir($cwd);
    }
285937
public function doPublish()
    {
        if (!$this->canEdit()) {
            throw new ValidationException(_t('News.PublishPermissionFailure', 'No permission to publish or unpublish news item'));
        }
        $this->Live = true;
        $this->write();
    }
927436
public function save($newRevision = false, $publishRevision = true)
    {
        if ($newRevision) {
            $revision = new Revision;
            $revision->language_id = $this->revision->language_id;

            $this->revision = $revision;
        }

        DB::transaction(
            function () use ($newRevision, $publishRevision) {
                $this->saveContent();

                $this->saveRevision($publishRevision);

                // Prepare and save fields
                foreach (array_keys($this->data) as $fieldName) {
                    /** @var FieldCollection $field */
                    $field = $this->data[$fieldName];

                    if (!$newRevision) {
                        $field->deleted()->each(function (Field $value) {
                            $value->delete();
                        });
                    }

                    $field->each(function (Field $value, $key) use ($newRevision, $fieldName) {
                        $value->weight = $key;
                        $value->name = $fieldName;
                        $this->saveField($value, $newRevision);
                    });

                    $field->syncOriginal();
                }
            }
        );
    }
387771
public function publish($contentTypeId)
    {
        $toType = $this->load($contentTypeId, Type::STATUS_DRAFT);

        try {
            $fromType = $this->load($contentTypeId, Type::STATUS_DEFINED);
            $this->updateHandler->updateContentObjects($fromType, $toType);
            $this->updateHandler->deleteOldType($fromType);
        } catch (Exception\TypeNotFound $e) {
            // If no old type is found, no updates are necessary to it
        }

        $this->updateHandler->publishNewType($toType, Type::STATUS_DEFINED);
    }
775421
public function deleteRevision($clear = true)
    {
        $this->getFieldTypes()->each(function ($type) {
            $type::where('revision_id', $this->revision->id)->delete();
        });

        // If this revision is currently
        // published, we need to publish
        // another revision in place.
        if ($this->revision->published && $this->revision->exists) {
            //TODO :: improve this logic
            Revision::where('content_id', $this->content->id)
                ->where('id', '!=', $this->revision->id)
                ->take(1)
                ->update(['published' => true]);
        }

        $this->revision->delete();

        if ($clear) {
            $this->clearFields();
        }
    }
342207
public function publishFiles()
    {
        // publish config file
        $this->publishes([__DIR__ . '/../config/config.php' => config_path() . '/back-project.php'], 'config');
        // publish lang files
        $this->publishes([__DIR__ . '/../resources/lang' => resource_path('lang/vendor/back-project')], 'lang');
        // publish public BackProject assets
        $this->publishes([__DIR__ . '/../public' => public_path('vendor/back-project')], 'public');
        // publish views
        $this->publishes([__DIR__ . '/../resources/views' => resource_path('views/vendor/back-project')], 'views');
        // publish error views
        $this->publishes([__DIR__ . '/../resources/error_views' => resource_path('views/errors')], 'errors');
        // publish public AdminLTE assets
        $this->publishes(['vendor/almasaeed2010/adminlte/bower_components/bootstrap/dist' => public_path('vendor/adminlte/bootstrap')], 'adminlte');
        $this->publishes(['vendor/almasaeed2010/adminlte/dist' => public_path('vendor/adminlte/dist')], 'adminlte');
        $this->publishes(['vendor/almasaeed2010/adminlte/plugins' => public_path('vendor/adminlte/plugins')], 'adminlte');
    }
141983
protected function bootPublishes()
    {
        $configPath = __DIR__.'/../../config';

        $this->mergeConfigFrom($configPath.'/config.php', 'graphql');

        $this->publishes([
            $configPath.'/config.php' => config_path('graphql.php'),
        ], 'config');

        $viewsPath = __DIR__.'/../../resources/views';
        $this->loadViewsFrom($viewsPath, 'graphql');
    }
50548
public function publish($blocks)
    {
        if ($blocks instanceof PersistentCollection) {
            $blocks = $blocks->getValues();
        }

        if (!$blocks ||
            (is_array($blocks) && !count($blocks))) {
            return;
        }

        if (! is_array($blocks)) {
            $blocks = [$blocks];
        }

        $this->disableRevisionListener();

        $deletes = [];

        foreach ($blocks as $block) {
            if (null !== $revision = $this->revisionManager->getDraftRevision($block)) {
                try {
                    $this->revisionManager->revert($block, $revision);
                } catch (DeletedException $e) {
                    // $this->em->remove($block);
                    $deletes[] = $block;
                }
            }
        }

        $this->em->flush();

        // Cycle through all deleted blocks to perform cascades manually 
        foreach ($deletes as $block) {
            if ($block instanceof CompositeBlock) {
                $descendants = $this->findDescendants($block, false);
            } else {
                $descendants = [$block];
            }

            foreach ($descendants as $descendant) {
                $descendant->setDeletedAt(new \DateTime);
                $this->em->flush($descendant);
            }
        }

        $cacheDriver = $this->em->getConfiguration()->getResultCacheImpl();
        $cacheDriver->deleteAll();

        $this->enableRevisionListener();
    }
776899
public function setPublishing($publishing = null)
    {
        if ($publishing === null) {
            $this->_publishing = null;
        } else {
            $this->_publishing = $this->validatePublishing($publishing);
        }

        return $this;
    }
534296
protected function registerPublishes(): void
    {
        $this->publishes([
            __DIR__.'/../../config/rating.php' => config_path('rating.php'),
        ], 'config');

        if ($this->app->runningInConsole()) {
            if (! class_exists('CreateRatingTables')) {
                $timestamp = date('Y_m_d_His', time());
                $this->publishes([
                    __DIR__.'/../../database/migrations/create_rating_tables.php.stub' => database_path('migrations/'.$timestamp.'_create_rating_tables.php'),
                ], 'migrations');
            }
        }
    }
200273
def publish():
    """"""
    print("To be ready for release, remember:")
    print("      1) Update the version number (and associated test)")
    print("      2) Update the ChangeLog.rst (and other documentation)")
    print(
        "         ChangeLog should have an line (title) consisting of the version number"
    )
    print("      3) Tag Mercurial with 'Release <version>'")
    print("      4) Push updates to BitBucket")
    print("      5) Set the RELEASE environment variable")
    print("           $ export RELEASE=formic")

    cmd = [
        'bash', '-c',
        'yolk -M formic | grep "^version: " | sed "s/^version: \\(.*\\)$/\\1/"'
    ]
    published_version = subprocess.check_output(cmd).strip()
    our_version = open(os.path.join("formic", "VERSION.txt"), "r").read()

    # sanity test on version
    if "\n" in published_version or\
       len(published_version) < 3 or len(published_version) > 10:
        raise Exception(
            "Published version number seems weird: " + published_version)

    print("Published version:", published_version)
    print("Current version:  ", our_version)

    if our_version == published_version:
        raise Exception(
            "You are attempting to republish version " + our_version)

    # sanity: check ChangeLog starts with our version
    changelog = open("CHANGELOG.rst", "r")
    found = False
    for line in changelog.readlines():
        if line.strip() == our_version:
            print("ChangeLog has an entry")
            found = True
            break
    changelog.close()
    if not found:
        raise Exception(
            "The ChangeLog does not appear to include comments on this release"
        )

    # Sanity check: is there a release tag
    tags = subprocess.check_output("hg tags".split())
    found = False
    looking_for = "Release " + our_version
    for line in tags.split("\n"):
        match = re.match(r"^(.*)\s+[0-9]+:[0-9a-f]+$", line)
        if match:
            tag = match.group(1).strip()
            if tag == looking_for:
                print("Found tag", tag)
                found = True
                break

    if not found:
        raise Exception(
            "Mercurial does not have the release tag: " + looking_for)

    status = subprocess.check_output(["hg", "status"])
    for line in status.split("\n"):
        if len(line) > 0:
            raise Exception("Uncommitted changes present")

    try:
        v = os.environ["RELEASE"]
        if v != "formic":
            raise KeyError()
    except KeyError:
        print("$RELEASE environment variable is not set")
        raise

    subprocess.check_call("python setup.py bdist_egg upload".split())
    subprocess.check_call("python setup.py sdist upload".split())
954104
protected function publishViews($load = true)
    {
        $this->publishes([
            $this->getViewsPath() => $this->getViewsDestinationPath()
        ], 'views');

        if ($load) $this->loadViews();
    }
64092
public function publish()
    {
        if (empty($this->handlers)) {
            return false;
        }

        foreach ($this->handlers as $handler) {
            $handler->handle($this->eventData);
        }
        return true;
    }