Creates CreateStruct from $content.

@param \eZ\Publish\SPI\Persistence\Content $content

@return \eZ\Publish\SPI\Persistence\Content\CreateStruct
431239
public function createCreateStructFromContent(Content $content)
    {
        $struct = new CreateStruct();
        $struct->name = $content->versionInfo->names;
        $struct->typeId = $content->versionInfo->contentInfo->contentTypeId;
        $struct->sectionId = $content->versionInfo->contentInfo->sectionId;
        $struct->ownerId = $content->versionInfo->contentInfo->ownerId;
        $struct->locations = array();
        $struct->alwaysAvailable = $content->versionInfo->contentInfo->alwaysAvailable;
        $struct->remoteId = md5(uniqid(get_class($this), true));
        $struct->initialLanguageId = $this->languageHandler->loadByLanguageCode($content->versionInfo->initialLanguageCode)->id;
        $struct->mainLanguageId = $this->languageHandler->loadByLanguageCode($content->versionInfo->contentInfo->mainLanguageCode)->id;
        $struct->modified = time();

        foreach ($content->fields as $field) {
            $newField = clone $field;
            $newField->id = null;
            $struct->fields[] = $newField;
        }

        return $struct;
    }
377809
public function wrapInner($content)
    {
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            self::create($node->childNodes)->wrapAll($content);
        }
        return $this;
    }
76217
public function prepare($content = null)
    {
        is_null($content) || $this->setContent($content);

        $content = $this->getContent();

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

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

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

        if (! $this->jsonErrors($content)) {
            $this->header('Content-Type: application/json');
        }

        $this->setContent($content);

        return $this;
    }
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;
    }
342980
public function buildContent(Model\ContentInterface $content)
    {
        $view = new ContentView();
        $attributes = $view->getAttributes()->addClass('cms-content');

        if ($this->editor->isEnabled()) {
            $attributes
                ->setId('cms-content-' . $content->getId())
                ->setData([
                    'id'      => $content->getId(),
                    'actions' => [
                        // TODO
                    ],
                ]);
        }

        // Layout
        $this->editor->getLayoutAdapter()->buildContent($content, $view);

        foreach ($content->getContainers() as $container) {
            $view->containers[] = $this->buildContainer($container);
        }

        return $view;
    }
1208135
public function createMissingValueSet(Content $content)
    {
        if ($content->getContentType() !== null && $content->getValueSet() === null)
        {
            $valueSet = new ValueSet();
            $this->em->persist($valueSet);

            $valueSet->setSchema($content->getContentType()->getSchema());
            $content->setValueSet($valueSet);

            $content = $this->save($content);
        }

        return $content;
    }
363758
public function writeCachedContent($content)
    {
        return $this->smarty->ext->_updateCache->writeCachedContent($this->cached, $this, $content);
    }
993152
private function createTemporaryResource(string $content)
    {
        $tempResource = fopen('php://memory', 'r+');
        fwrite($tempResource, $content);
        rewind($tempResource);

        return $tempResource;
    }
341824
protected function createParser(string $content): Parser
    {
        $parser = new Parser($this->createLexer($content)->tokenize());
        $parser->setLibraries($this->libraries);

        return $parser;
    }
1326778
public function fileContent($content)
    {
        if (is_resource($this->fileContent)) {
            fclose($this->fileContent);
        }

        $this->fileContent = $content;

        if (is_resource($content) && empty($this->fileType)) {
            $this->fileType($this->getTypeFromResource($content));
        }

        return $this;
    }
1310425
public static function createFromString(string $content = '')
    {
        $resource = fopen('php://temp', 'r+');
        fwrite($resource, $content);

        $instance = new static($resource);
        $instance->should_close_stream = true;

        return $instance;
    }
821902
public function duplicate(ContentInterface $content)
    {
        //duplicate content
        $duplicatedContent = clone $content;
        $duplicatedContent->setTitle(sprintf("%s copy %s", $duplicatedContent->getTitle(), date('r')));
        $duplicatedContent->setSlug(null);
        $duplicatedContent->setActive(false);
        $duplicatedContent->setCreatedAt(new \DateTime());

        //get valueset to clone
        if (null !== $valueset = $content->getValueSet()) {
            //clone valueset
            $duplicatedValueset = clone $valueset;

            $this->detachAndPersist($duplicatedValueset);
            $duplicatedContent->setValueSet($duplicatedValueset);
        }

        $duplicatedContent->setBlocks(null);
        $this->detachAndPersist($duplicatedContent);

        if ($valueset) {
            //iterate values, clone each and assign duplicate valueset to it
            foreach ($valueset->getValues() as $value) {

                //skip empty attributes
                if (is_null($value->getId())) continue;

                $duplicatedValue = clone ($value);
                $duplicatedValue->setValueSet($duplicatedValueset);

                $this->detachAndPersist($duplicatedValue);
            }
        }
        $this->em->flush();

        return $duplicatedContent;
    }
798290
public function save($content)
    {
        $this->_isSaved = true;
        $this->_contentSaved = (string) $content;
        $this->_block->updateContent($this->_contentSaved);
        return $this;
    }
1168780
public function after($content)
    {
        $content = self::create($content);
        $newnodes = array();
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            $refnode = $node->nextSibling;
            foreach ($content as $newnode) {
                /** @var \DOMNode $newnode */
                $newnode = static::importNewnode($newnode, $node, $i);
                if ($refnode === null) {
                    $node->parentNode->appendChild($newnode);
                } else {
                    $node->parentNode->insertBefore($newnode, $refnode);
                }
                $newnodes[] = $newnode;
            }
        }
        $content->clear();
        $content->add($newnodes);
        return $this;
    }
42727
public function setContent($content)
    {
        $this->content = null;
        if ($content === null) {
            return;
        }

        if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) {
            $this->content = (string)$content;
        }

        if (is_resource($content)) {
            $this->content = $content;
        }

        return $this;
    }
1311438
public static function create(string $content): Stream
    {
        $resource = \fopen('php://temp', 'rwb+');
        $stream   = self::createFromResource($resource);
        $stream->write($content);

        return $stream;
    }
942447
public static function create($content = null, $contentType = 'text/plain')
    {
        $instance = new static();

        $instance->content = $content;
        $instance->contentType = $contentType;

        return $instance;
    }