Create a new content.

@param array  $translatedContent array('en' => array('content' => 'foo', 'title' => 'foo'))
@param string $type              A type of content

@return int the id of the new content
515032
public function createContent(array $translatedContent, $type = null)
    {
        $content = new Content();
        $content->setType($type);
        $locale = $this->request->getSession()->get('_locale');
        $this->updateContent(
            $content,
            $this->setDefault(
                $this->setDefault($translatedContent, 'title', $locale),
                'content',
                $locale
            )
        );

        return $content->getId();
    }
256040
public function getContentArray($type = DOC_TYPE_ARRAY)
  {
    if ($type == DOC_TYPE_SIMPLEXML) {
      $cpsChildren = $this->_simpleXml->children('www.clusterpoint.com');
      if (isset($cpsChildren->content)) {
        return $cpsChildren->content;
      } else {
        return NULL;
      }
    } else if ($type == DOC_TYPE_ARRAY) {
      return $this->_contentArray;
    }
  }
175774
public function addElementToContentSet($element, $type)
    {
        if (!isset($this->content_sets[$type])) {
            $this->content_sets[$type] = '';
        } else {
            $this->content_sets[$type] .= ' | ';
        }
        $this->content_sets[$type] .= $element;
    }
363794
public function create($type)
    {
        switch ($type) {
            case self::AUDIO:
                return new Type\Audio();
            case self::IMAGE:
                return new Type\Image();
            case self::GENERAL:
                return new Type\General();
            case self::VIDEO:
                return new Type\Video();
            case self::SUBTITLE:
                return new Type\Subtitle();
            case self::MENU:
                return new Type\Menu();
            case self::OTHER:
                return new Type\Other();
            default:
                throw new UnknownTrackTypeException($type);
        }
    }
838391
public function createContent( $contentType, $fields, $parentLocationId )
    {
        $repository = $this->getRepository();
        $languageCode = self::DEFAULT_LANGUAGE;

        $content = $this->getRepository()->sudo(
            function(Repository $repository) use ( $parentLocationId, $contentType, $fields, $languageCode )
            {
                $content = $this->createContentDraft($parentLocationId, $contentType, $fields, $languageCode);
                return $content = $repository->getContentService()->publishVersion($content->versionInfo);
            }
        );

        return $content->contentInfo->mainLocationId;
    }
210256
public function insertType(Type $type, $typeId = null)
    {
        $q = $this->dbHandler->createInsertQuery();
        $q->insertInto($this->dbHandler->quoteTable('ezcontentclass'));
        $q->set(
            $this->dbHandler->quoteColumn('id'),
            isset($typeId) ? $q->bindValue($typeId, null, \PDO::PARAM_INT) : $this->dbHandler->getAutoIncrementValue('ezcontentclass', 'id')
        )->set(
            $this->dbHandler->quoteColumn('version'),
            $q->bindValue($type->status, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('created'),
            $q->bindValue($type->created, null, \PDO::PARAM_INT)
        )->set(
            $this->dbHandler->quoteColumn('creator_id'),
            $q->bindValue($type->creatorId, null, \PDO::PARAM_INT)
        );
        $this->setCommonTypeColumns($q, $type);

        $q->prepare()->execute();

        if (empty($typeId)) {
            $typeId = $this->dbHandler->lastInsertId(
                $this->dbHandler->getSequenceName('ezcontentclass', 'id')
            );
        }

        $this->insertTypeNameData($typeId, $type->status, $type->name);

        return $typeId;
    }
1355941
public function withContentType($contentType)
    {
        $contentType = $this->normalizeContentType($contentType);

        $contentType = explode(';', $contentType, 2);

        $this->type = $contentType[0];

        $contentType[0] .= ';' . (isset($contentType[1]) ? $contentType[1] : ' charset=utf-8');

        return $this->withHeader('Content-Type', $contentType[0]);
    }
609809
public function create(
        $contentTypes,
        $limit,
        $titleWords,
        $timeRange,
        $language = LanguageInterface::LANGCODE_NOT_SPECIFIED
    ) {
        $nodes = [];
        $bundles = $this->drupalApi->getBundles();
        for ($i = 0; $i < $limit; $i++) {
            try {
                $contentType = $contentTypes[array_rand($contentTypes)];
                $node = $this->entityTypeManager->getStorage('node')->create(
                    [
                        'nid' => null,
                        'type' => $contentType,
                        'created' => REQUEST_TIME - mt_rand(0, $timeRange),
                        'uid' => $this->getUserID(),
                        'title' => $this->getRandom()->sentences(mt_rand(1, $titleWords), true),
                        'revision' => mt_rand(0, 1),
                        'status' => true,
                        'promote' => mt_rand(0, 1),
                        'langcode' => $language
                    ]
                );

                $this->generateFieldSampleData($node);
                $node->save();
                $nodes['success'][] = [
                    'nid' => $node->id(),
                    'node_type' => $bundles[$contentType],
                    'title' => $node->getTitle(),
                    'created' => $this->dateFormatter->format(
                        $node->getCreatedTime(),
                        'custom',
                        'Y-m-d h:i:s'
                    )
                ];
            } catch (\Exception $error) {
                $nodes['error'][] = $error->getMessage();
            }
        }

        return $nodes;
    }
1353493
public function postContent($type = 'content')
    {
        $output = [];

        if ($type === 'excerpt') {
            ob_start();
            the_excerpt();
            $output[] = ob_get_clean();
        } else {
            ob_start();
            the_content(sprintf(__('Continue reading %s', 'novusopress'), the_title('<span class="sr-only">', '</span>', false)));
            $output[] = ob_get_clean();
        }

        return apply_filters('novusopress_view_post_content_output', implode('', $output));
    }
310506
public function send($content = null, $type = null) 
    {
        if (!is_null($content)) {
            $this->setContents(is_array($content) ? $content : array($content));
        }
        if (!is_null($type)) {
            $this->setContentType($type);
        }
        return parent::send();
    }
1091876
private function resolveContentEditData(
        Content $content,
        string $languageCode,
        ContentType $contentType
    ): ContentUpdateData {
        $contentUpdateMapper = new ContentUpdateMapper();

        return $contentUpdateMapper->mapToFormData($content, [
            'languageCode' => $languageCode,
            'contentType' => $contentType,
        ]);
    }
537555
public function createContentType($alias)
    {
        $ct = $this->normalizeBoltName($alias);

        return
            isset($this->contenttypes[$ct])
            ? new ContentType($ct, $this->contenttypes[$ct])
            : null;
    }
39327
private function internalLoadContent(array $contentIds, int $version = null, array $translations = null): array
    {
        $queryBuilder = $this->connection->createQueryBuilder();
        $expr = $queryBuilder->expr();
        $queryBuilder
            ->select(
                'c.id AS ezcontentobject_id',
                'c.contentclass_id AS ezcontentobject_contentclass_id',
                'c.section_id AS ezcontentobject_section_id',
                'c.owner_id AS ezcontentobject_owner_id',
                'c.remote_id AS ezcontentobject_remote_id',
                'c.current_version AS ezcontentobject_current_version',
                'c.initial_language_id AS ezcontentobject_initial_language_id',
                'c.modified AS ezcontentobject_modified',
                'c.published AS ezcontentobject_published',
                'c.status AS ezcontentobject_status',
                'c.name AS ezcontentobject_name',
                'c.language_mask AS ezcontentobject_language_mask',
                'c.is_hidden AS ezcontentobject_is_hidden',
                'v.id AS ezcontentobject_version_id',
                'v.version AS ezcontentobject_version_version',
                'v.modified AS ezcontentobject_version_modified',
                'v.creator_id AS ezcontentobject_version_creator_id',
                'v.created AS ezcontentobject_version_created',
                'v.status AS ezcontentobject_version_status',
                'v.language_mask AS ezcontentobject_version_language_mask',
                'v.initial_language_id AS ezcontentobject_version_initial_language_id',
                'a.id AS ezcontentobject_attribute_id',
                'a.contentclassattribute_id AS ezcontentobject_attribute_contentclassattribute_id',
                'a.data_type_string AS ezcontentobject_attribute_data_type_string',
                'a.language_code AS ezcontentobject_attribute_language_code',
                'a.language_id AS ezcontentobject_attribute_language_id',
                'a.data_float AS ezcontentobject_attribute_data_float',
                'a.data_int AS ezcontentobject_attribute_data_int',
                'a.data_text AS ezcontentobject_attribute_data_text',
                'a.sort_key_int AS ezcontentobject_attribute_sort_key_int',
                'a.sort_key_string AS ezcontentobject_attribute_sort_key_string',
                't.main_node_id AS ezcontentobject_tree_main_node_id'
            )
            ->from('ezcontentobject', 'c')
            ->innerJoin(
                'c',
                'ezcontentobject_version',
                'v',
                $expr->andX(
                    $expr->eq('c.id', 'v.contentobject_id'),
                    $expr->eq('v.version', $version ?? 'c.current_version')
                )
            )
            ->innerJoin(
                'v',
                'ezcontentobject_attribute',
                'a',
                $expr->andX(
                    $expr->eq('v.contentobject_id', 'a.contentobject_id'),
                    $expr->eq('v.version', 'a.version')
                )
            )
            ->leftJoin(
                'c',
                'ezcontentobject_tree',
                't',
                $expr->andX(
                    $expr->eq('c.id', 't.contentobject_id'),
                    $expr->eq('t.node_id', 't.main_node_id')
                )
            );

        $queryBuilder->where(
            $expr->in(
                'c.id',
                $queryBuilder->createNamedParameter($contentIds, Connection::PARAM_INT_ARRAY)
            )
        );

        if (!empty($translations)) {
            $queryBuilder->andWhere(
                $expr->in(
                    'a.language_code',
                    $queryBuilder->createNamedParameter($translations, Connection::PARAM_STR_ARRAY)
                )
            );
        }

        return $queryBuilder->execute()->fetchAll(FetchMode::ASSOCIATIVE);
    }
1007632
private function seedRandomContent(string $type, $parent, $languages, $users)
    {
        $user  = $users->random();
        $en    = $languages['en'];
        $pl    = $languages['pl'];
        $faker = Factory::create($en->i18n);
        $title = $faker->realText(38, 1);

        $content = dispatch_now(CreateContent::make($title, $en, $user, array_merge(
            [
                'type'               => $type,
                'parent_id'          => array_get($parent, 'id', null),
                'weight'             => rand(0, 10),
                'rating'             => rand(0, 5),
                'is_on_home'         => (bool) rand(0, 1),
                'is_comment_allowed' => (bool) rand(0, 1),
                'is_promoted'        => (bool) rand(0, 1),
                'is_sticky'          => (bool) rand(0, 1),
                'is_active'          => (bool) rand(0, 1),
                'published_at'       => Carbon::now()
            ],
            $this->generateContentTranslation($en)
        )));

        $faker = Factory::create($pl->i18n);
        $title = $faker->realText(38, 1);
        dispatch_now(new AddContentTranslation($content, $title, $pl, $user, $this->generateContentTranslation($pl)));

        return $content;
    }
115102
public function getContent($type = self::URL_TYPE_SHORTENED_TRACKED)
    {
        if (self::URL_TYPE_ORIGINAL === $type) {
            return $this->content;
        } else {
            return ParserUtil::replaceURLsInText($this->content, $this->getReplacementUrls($type));
        }
    }
715373
public function addContent($type, $value = null)
    {
        if ($type instanceof Content) {
            $content = $type;
        } else {
            $content = new Content($type, $value);
        }
        $this->contents[] = $content;
    }
505658
public static function createFromArticleTranslation(ArticleTranslation $translation): self
    {
        $message = new self();
        $message->setLocale($translation->getLocale());
        $message->setTitle($translation->getTitle());
        $message->setBody($translation->getBody());

        return $message;
    }