Release content draft and returns it.

@param  AbstractClassContent $content

@return Revision|NULL
179838
private function releaseDraft($content)
    {
        $draft = null;
        if (
                $content instanceof AbstractClassContent
                && (null !== $draft = $content->getDraft())
        ) {
            $content->releaseDraft();
        }

        return $draft;
    }
700742
public function setContent(\Haven\CmsBundle\Entity\Content $content = null) {
        $this->content = $content;

        return $this;
    }
1037061
public function setContent($content = null)
    {
        if (null !== $content && !is_string($content)) {
            throw new ResponseException('Response content must be a string.');
        }

        $this->content = (string) $content;

        return $this;
    }
564785
public function getSerializedContent($content)
    {
        $serializationContext = clone $this->serializationContext;

        return $this->serializer->serialize(
            $content,
            'json',
            $serializationContext
        );
    }
708592
public function revertToRevision(AbstractClassContent $content, $revision)
    {
        // First remove existing draft for user
        if (null !== $draft = $this->getDraft($content)) {
            $this->entityManager->remove($draft);
        }

        // If asked $revision is the last one, all is done.
        if ($content->getRevision() === (int) $revision) {
            return $this;
        }

        $source = $this->entityManager
                ->getRepository('BackBee\ClassContent\Revision')
                ->getRevision($content, (int) $revision);

        if (null === $source) {
            throw new \InvalidArgumentException(sprintf('Unknown revision %d for content %s.', $revision, $content->getObjectIdentifier()));
        }

        $token = $this->token ? : $this->app->getBBUserToken();

        $draft = clone $source;
        $draft->setOwner($token->getUser());
        $draft->setRevision($content->getRevision());
        $draft->setState(Revision::STATE_MODIFIED);
        $draft->setComment(sprintf('Revert to revision %d.', $revision));
        $draft->setCreated();
        $draft->setModified();

        $this->entityManager->persist($draft);
        $content->setDraft($draft);

        return $this;
    }
174363
private static function write($content)
	{
		self::lock();
		if ( is_null( self::$authFileP ) ) throw new Exception( 'No lock has been requested' );
		ftruncate( self::$authFileP , 0 );
		fwrite( self::$authFileP , $content );

		return fflush( self::$authFileP );
	}
1124826
public function revert(AbstractClassContent $content, array $data = [])
    {
        if (0 === count($data)) {
            $data['parameters'] = array_keys($content->getAllParams());
            if ($content instanceof ContentSet) {
                $data['elements'] = true;
            } else {
                $data['elements'] = array_keys($content->getData());
            }
        }

        if (!isset($data['parameters']) && !isset($data['elements'])) {
            throw new \InvalidArgumentException('Provided data are not valids for ClassContentManager::revert.');
        }

        if (null === $draft = $this->getDraft($content)) {
            throw new InvalidArgumentException(sprintf(
                '%s with identifier "%s" has not draft, nothing to revert.',
                $content->getContentType(),
                $content->getUid()
            ));
        }

        $this->executeRevert($content, $draft, $data);
        $this->revertPostProcess($content, $draft);

        return $this;
    }
337814
public function push(AbstractClassContent $var)
    {
        if (!($this->_content instanceof ContentSet)) {
            throw new ClassContentException(
                sprintf('Can not push in a content %s.', get_class($this)),
                ClassContentException::UNKNOWN_ERROR
            );
        }

        if ($this->isAccepted($var)) {
            $this->_data[] = array(get_class($var) => $var->getUid());
        }

        return $this->getContent();
    }
242169
protected function cloneContent(ContentInterface $content)
    {
        $newContent = clone $content;
        if (false === $content->getStatus()->isOutOfWorkflow()) {
            $status = $this->statusRepository->findOneByInitial();
            $newContent->setStatus($status);
        }
        $newContent->setVersion($this->uniqueIdGenerator->generateUniqueId());
        foreach ($content->getKeywords() as $keyword) {
            $newContent->addKeyword($keyword);
        }
        foreach ($content->getAttributes() as $attribute) {
            $newAttribute = clone $attribute;
            $newContent->addAttribute($newAttribute);
        }

        return $newContent;
    }
680756
private function updateParameters(AbstractClassContent $content, array $paramsData)
    {
        foreach ($paramsData as $key => $param) {
            $content->setParam($key, $param);
        }

        return $this;
    }
1070833
protected function _getContent($content)
    {
        if(!isset($content))
            return;

        if(is_array($content))
            return array_map(
                function ($value) {
                    return $this->_getContent($value);
                }, $content
            );

        switch(gettype($content)) {
            case 'string': case 'integer': case 'double': case 'float':
                return $content;
            break;
            case 'object':
                if('Closure' == get_class($content)) {
                    ob_start();
                    ob_clean();
                    $returned = $content($this->data);
                    $output = ob_get_clean();
                    if(isset($returned))
                        return $returned;
                    else
                        return $output;
                } elseif(isset($content->content))
                    return $content->content;
            break;
            default:
                throw new \InvalidArgumentException('wrong view content type : '.gettype($content));
        }
    }
611189
public function setContent($content) : Response
    {
        if (is_resource($content)) {
            $body = new MessageBodyResource($content);
        } else {
            $body = new MessageBodyString($content);
        }

        return $this->setBody($body);
    }
224392
private function autoCommitContent(AbstractClassContent $content)
    {
        // Commit subelement of the Media content
        foreach ($content->getData() as $subcontent) {
            if (!($subcontent instanceof AbstractClassContent)) {
                continue;
            }

            $this->commit($subcontent);
        }

        // Commit the Media content itself
        $this->commit($content);
    }
582648
public static function createFromContent($content)
    {
        $domDocument = new \DOMDocument();

        @$domDocument->loadHTML($content);

        $xpathQueryBuilder = new XpathQueryBuilder();

        $xpathQueryBuilder->setDomXpath(new \DOMXPath($domDocument));

        return $xpathQueryBuilder;
    }
254575
public function setContent($content)
    {
        if (is_null($this->mbRequest)) {
            return $this;
        }

        $this->prepare($this->mbRequest);

        if ($this->mbRequest->isMethod("GET") || $this->mbRequest->isMethod("DELETE")) {
            $this->statusCode = BaseResponse::HTTP_OK;
        } elseif ($this->mbRequest->isMethod("POST") || $this->mbRequest->isMethod("PUT")) {
            $this->statusCode = BaseResponse::HTTP_CREATED;
        } else {
            $this->statusCode = BaseResponse::HTTP_RESET_CONTENT;
        }

        if ($content instanceof \Exception) {
            $this->statusCode = $content->getCode();
            $this->statusCode = $this->isSuccessful() ? $this->statusCode : BaseResponse::HTTP_BAD_REQUEST;
        }

        if($this->isBuffer()){
            $this->original = $content;
        } elseif ($this->mbRequest->isAjax()) {
            $this->ajaxContent($content);
        } else {
            $this->htmlContent($content);
        }

        return $this;
    }
870022
public function setContent(string $content = null): ResponseContextAbstract
    {
        if (is_null($content)) {
            return $this;
        }

        $this->assertIsValid($content);

        $this->content = $content;

        return $this;
    }
980620
public function push(AbstractClassContent $var)
    {
        if (null !== $this->getDraft()) {
            return $this->getDraft()->push($var);
        }

        if ($this->isAccepted($var)) {
            if (
                    (!$this->_maxentry && !$this->_minentry) ||
                    (is_array($this->_maxentry) && is_array($this->_minentry) && 0 == count($this->_maxentry)) ||
                    ($this->_maxentry > $this->count() && $this->_minentry < $this->count())
            ) {
                $this->_data[] = array($this->_getType($var) => $var->getUid());
                if ($this->_subcontent->add($var)) {
                    $this->subcontentmap[$var->getUid()] = $this->_subcontent->indexOf($var);
                }
            }
        }

        return $this;
    }