@param ContentInterface $content

@return array
395
protected function extractMediasFromContentType(ContentTypeInterface $contentType)
    {
        $mediaIds = array();
        $fields = $contentType->getFields();

        foreach ($fields as $field) {
            if ($this->isMediaAttribute($field->getDefaultValue())) {
                $mediaIds[] = $field->getDefaultValue()['id'];
            }
        }

        return $mediaIds;
    }
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;
    }
312853
public function encode(Content $content): string
    {
        $results     = [];
        $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
        foreach ($content->getFields() as $field) {
            $identifier      = $field->fieldDefIdentifier;
            $fieldDefinition = $contentType->getFieldDefinition($identifier);
            if (!$fieldDefinition->isTranslatable) {
                continue;
            }
            $type = \get_class($field->value);
            // Note that TextBlock is a TextLine
            if ($field->value instanceof TextLineValue) {
                $value                = (string) $field->value;
                $results[$identifier] = ['#' => $value, '@type' => $type];
                continue;
            }
            if ($field->value instanceof RichTextValue
                || $field->value instanceof EzPlatformRichTextValue
            ) {
                // we need to remove that to make it a good XML
                $value                = $this->richTextEncode($field->value);
                $results[$identifier] = ['#' => $value, '@type' => $type];
            }
        }

        $encoder = new XmlEncoder();
        $payload = $encoder->encode($results, XmlEncoder::FORMAT);
        // here Encoder has  decorated with CDATA, we don't want the CDATA
        $payload = str_replace(
            ['<![CDATA[', ']]>'],
            ['<' . self::CDATA_FAKER_TAG . '>', '</' . self::CDATA_FAKER_TAG . '>'],
            $payload
        );

        return $payload;
    }
1226201
public function findAllShortcodeIds( $content ) {
		$ids = [];
		$matches = [];
		$regex = get_shortcode_regex( [ self::SHORTCODE ] );
		if ( preg_match_all( '/' . $regex . '/s', $content, $matches, PREG_SET_ORDER ) ) {
			foreach ( $matches as $shortcode ) {
				$shortcode_attrs = shortcode_parse_atts( $shortcode[3] );
				if ( is_array( $shortcode_attrs ) && isset( $shortcode_attrs['id'] ) ) {
					// Remove quotes, return just the integer
					$my_id = $shortcode_attrs['id'];
					$my_id = trim( $my_id, "'" );
					$my_id = trim( $my_id, '"' );
					$my_id = str_replace( '&quot;', '', $my_id );
					$ids[] = (int) $my_id;
				}
			}
		}
		return $ids;
	}
1195065
public function duplicateContent(ContentInterface $content, $contentId = null)
    {
        $newContent = $this->cloneContent($content);
        $newContent->setContentId($contentId);
        $newContent->setName($this->duplicateLabel($content->getName()));
        $newContent = $this->setVersionName($newContent);

        return $newContent;
    }
555327
public function parseStackTrace($content)
    {
        $content = trim($content);
        $pattern = "/^".self::STACK_TRACE_INDEX_PATTERN."/m";

        if (empty($content)) {
            return [];
        }

        $traces = preg_split($pattern, $content);

        if (empty($trace[0])) {
            array_shift($traces);
        }

        return $traces;
    }
573719
public function getPosts(Content $content)
    {
        if (isset($this->site->categories[$content->id])) {
            return $this->site->categories[$content->id];
        }
        else {
            if (isset($content->category) && isset($this->site->categories[$content->category])) {
                return $this->site->categories[$content->category];
            }
        }

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

        return $this->serializer->serialize(
            $content,
            'json',
            $serializationContext
        );
    }
347048
public function includeChildren(Content $content)
    {
        if ($content->isChildrenLoaded()) {
            return $this->collection($content->children, new ContentTransformer()); // We don't want LAZY LOADING !
        }
        return null;
    }
115553
public function getFunctions(string $content): array
    {

        $functions = array();

        $tokenised_content = $this->getTokenisedContent($content);

        // Check for $tokenised_content["methods"];
        if (isset($tokenised_content["methods"])) {
            $functions = $tokenised_content["methods"];
        } elseif (isset($tokenised_content["functions"])) {
            $functions = $tokenised_content["functions"];
        }

        return $functions;

    }
1169556
protected function convertCookieToArray(CookieInterface $cookie)
    {
        return [
            'name' => $cookie->getName(),
            'value' => $cookie->getValue(),
            'path' => $cookie->getPath(),
            'domain' => $cookie->getDomain(),
            'secure' => $cookie->isSecure(),
            'httponly' => $cookie->isHttpOnly(),
            'expires' => $cookie->getFormattedExpires()
        ];
    }
665640
public function coreScriptFilter($content) {

        $attributes = [];

        $attributes["type"] = "text/javascript";

        $innerHTML = null !== $content ? implode("", ["\n", $content, "\n"]) : "";

        return static::coreHTMLElement("script", $innerHTML, $attributes);
    }
579302
public function transform($content)
    {
        $content = $this->entityToArray(Content::class, $content);
        return [
            'id'               => $this->setNullableValue($content['id']),
            'parentId'         => $this->setNullableValue($content['parent_id']),
            'type'             => $content['type'],
            'theme'            => $content['theme'],
            'weight'           => (int) $content['weight'],
            'rating'           => (int) $content['rating'],
            'visits'           => (int) $content['visits'],
            'isActive'         => (bool) $content['is_active'],
            'isOnHome'         => (bool) $content['is_on_home'],
            'isCommentAllowed' => (bool) $content['is_comment_allowed'],
            'isPromoted'       => (bool) $content['is_promoted'],
            'isSticky'         => (bool) $content['is_sticky'],
            'path'             => $this->buildPath($content['path']),
            'publishedAt'      => $content['published_at'],
            'createdAt'        => $content['created_at'],
            'updatedAt'        => $content['updated_at']
        ];
    }
95356
public static function metadata(string $content): array
	{
		if (preg_match_all(self::$metadataPattern, $content, $matches) !== false) {
			$combine = array_combine($matches[1], $matches[2]);

			if ($combine === false) {
				throw new LogicException('Matches count is not equal.');
			}

			return $combine;
		}

		return [];
	}
1106849
protected function _getSetOfLines($content)
    {
        if (!is_array($content)) $content = array( $content );
        reset($content);
        if (!is_array(current($content))) {
            $content = array( 0=>$content );
        }
        return $content;
    }
247965
public function exportFiles($content)
    {
        $content = $this->_defaultData($content);
        if ($content->file && (strpos($content->file, '/') === 0 || strpos($content->file, URL::to('/')) === 0)) {
            return [str_replace(URL::to('/'), '', $content->file)];
        } else {
            return [];
        }
    }
799389
protected function getAttributes(ContentInterface $owner)
    {
        /** @var AttributeInterface $attributes */
        $attributes = $owner->getValueSet()->getAttributes();

        $choices = [];
        foreach ($attributes as $attribute) {
            if (!in_array($attribute->getValueType(), ['select', 'radio', 'checklist'])) {
                continue;
            }
            $choices[$attribute->getDisplayName()] = $attribute->getName();
        }

        return $choices;
    }