Get an array of the column name(s) of the title.

@param ContentType|array $contentType

@return array
767015
protected function getTitleColumnNames($contentType)
    {
        Deprecated::method();

        // If we specified a specific field name or array of field names as 'title'.
        if (!empty($contentType['title_format'])) {
            return (array) $contentType['title_format'];
        }

        $names = [
            'title', 'name', 'caption', 'subject', 'heading', //EN
            'titel', 'naam', 'onderwerp', // NL
            'nom', 'sujet', // FR
            'nombre', 'sujeto', // ES
            'titulo', 'nome', 'subtitulo', 'assunto', // PT
        ];

        foreach ($names as $name) {
            if (isset($contentType['fields'][$name])) {
                return [$name];
            }
        }

        // Otherwise, grab the first field of type 'text', and assume that's the title.
        if (!empty($contentType['fields'])) {
            foreach ($contentType['fields'] as $key => $field) {
                if ($field['type'] === 'text') {
                    return [$key];
                }
            }
        }

        // If this is a ContentType without any text fields, we can't provide a proper title.
        return [];
    }
240353
public function getContentIdsByContentTypeId($contentTypeId)
    {
        try {
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
965401
protected function getAllMultiViewRecords($contentTypeName = null, DataDimensions $dataDimensions)
    {

        $data = $this->readRecords($this->getConfiguration()->getUriRecords($contentTypeName));

        if ($data)
        {
            $data = json_decode($data, true);

            $data['records'] = array_filter($data['records']);

            $definition = $this->getContentTypeDefinition($contentTypeName);

            $records = $this->getRecordFactory()
                            ->createRecordsFromJSONRecordsArray($definition, $data['records']);

            return $records;
        }

        return [ ];

    }
1289585
public function getConfig($contentType)
    {
        if (array_key_exists($contentType, $this->searchableTypes)) {
            return $this->searchableTypes[$contentType];
        }

        if ($this->canSearchInvisible() && array_key_exists($contentType, $this->invisibleTypes)) {
            return $this->invisibleTypes[$contentType];
        }

        return false;
    }
662727
private function getTemplateFieldTemplates(ContentType $contentType, Content $content)
    {
        $templateFieldTemplates = [];
        $templateFieldsConfig = $this->config->get('theme/templatefields');

        if ($templateFieldsConfig) {
            $templateFieldTemplates = array_keys($templateFieldsConfig);
            // Special case for default template
            $toRepair = [];
            foreach ($contentType['fields'] as $name => $field) {
                if ($field['type'] === 'templateselect' && !empty($content->values[$name])) {
                    $toRepair[$name] = $content->values[$name];
                    $content->set($name, '');
                }
            }
            if ($content->hasTemplateFields()) {
                $templateFieldTemplates[] = '';
            }

            foreach ($toRepair as $name => $value) {
                $content->set($name, $value);
            }
        }

        return $templateFieldTemplates;
    }
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;
    }
981879
public function getContentsParentUids($contentUids)
    {
        $contentUids = (array) $contentUids;
        if (0 === count($contentUids)) {
            return [];
        }

        $contentUids = implode(', ', array_unique(array_map(function ($uid) {
            return '"'.$uid.'"';
        }, $contentUids)));

        $parentUids = $this->_em->getConnection()->executeQuery(
            sprintf('SELECT parent_uid FROM content_has_subcontent WHERE content_uid IN (%s)', $contentUids)
        )->fetchAll(\PDO::FETCH_COLUMN);

        return array_merge($parentUids, $this->getContentsParentUids($parentUids));
    }
401394
protected function getLanguageCode(ContentType $contentType)
    {
        $contentTypeLanguages = array_keys($contentType->getNames());

        foreach ($this->languages as $languageCode) {
            if (in_array($languageCode, $contentTypeLanguages, true)) {
                return $languageCode;
            }
        }

        return $contentType->mainLanguageCode;
    }
630553
public function match($contentType)
    {
        $parts = explode(';', $contentType);
        $mime = array_shift($parts);

        return (bool)preg_match('#[/+]json$#', trim($mime));
    }
622648
public function getRelated($contentType = null)
    {
        if ($contentType !== null) {
            return $this->getRelation($contentType);
        }

        return $this->getRelation()->all();
    }
305605
public function & GetFieldsByType ($fieldType = '') {
		$result = [];
		foreach ($this->fields as & $field) {
			if ($field->GetType() == $fieldType)
				$result[$field->GetName()] = $field;
		}
		return $result;
	}
262034
public function getClassnames(array $contentUids)
    {
        $contentUids = array_map(function ($uid) {
            return '"'.$uid.'"';
        }, array_filter($contentUids));

        if (0 === count($contentUids)) {
            return [];
        }

        $qb = $this->_em->getConnection()->createQueryBuilder();

        return $qb
            ->select('DISTINCT c.classname')
            ->from('content', 'c')
            ->where($qb->expr()->in('c.uid', $contentUids))
            ->execute()
            ->fetchAll(\PDO::FETCH_COLUMN)
        ;
    }
564040
public function getChangedFields(array $contentType)
    {
        $changedFields = [];

        if (empty($this->diff)) {
            return $changedFields;
        }

        // Get the ContentType that we're dealing with
        $fields = $contentType['fields'];

        $hash = [
            'html'        => 'fieldText',
            'markdown'    => 'fieldText',
            'textarea'    => 'fieldText',
            'filelist'    => 'fieldList',
            'imagelist'   => 'fieldList',
            'geolocation' => 'fieldGeolocation',
            'image'       => 'fieldImage',
            'embed'       => 'fieldVideo',
            'select'      => 'fieldSelect',
            'video'       => 'fieldVideo',
        ];

        foreach ($this->diff as $key => $value) {
            if (!isset($fields[$key])) {
                continue;
            }

            $type = $fields[$key]['type'];
            $changedFields[$key] = [
                'type'   => $type,
                'label'  => empty($fields[$key]['label']) ? $key : $fields[$key]['label'],
                'before' => [
                    'raw'    => $value[0],
                    'render' => $value[0],
                ],
                'after'  => [
                    'raw'    => $value[1],
                    'render' => $value[1],
                ],
            ];

            /** @var string $type */
            $type = $fields[$key]['type'];
            if (isset($hash[$type])) {
                $func = $hash[$type];
                $changedFields[$key] = array_merge($changedFields[$key], $this->{$func}($key, $value, $fields));
            }
        }

        return $changedFields;
    }
1316415
public function getRolesByContentTypePermission($permissionName, $contenttype)
    {
        // Here's how it works:
        // - if a permission is granted through 'contenttype-all', it is effectively granted
        // - if a permission is granted through 'contenttypes/$contenttype', it is effectively granted
        // - if 'contenttypes/$contenttype/$permissionName' is not set, *and* the permission is granted through 'contenttype-default', it is effectively granted
        // - otherwise, the permission is denied
        $overrideRoles = $this->app['config']->get("permissions/contenttype-all/$permissionName");
        if (!is_array($overrideRoles)) {
            $overrideRoles = [];
        }
        $contenttypeRoles = $this->app['config']->get("permissions/contenttypes/$contenttype/$permissionName");
        if (!is_array($contenttypeRoles)) {
            $contenttypeRoles = $this->app['config']->get("permissions/contenttype-default/$permissionName");
        }
        if (!is_array($contenttypeRoles)) {
            $contenttypeRoles = [];
        }
        $effectiveRoles = array_unique(array_merge($overrideRoles, $contenttypeRoles));

        return $effectiveRoles;
    }
1277073
private function prepareFields(ApiContentType $contentType, $fields = null)
    {
        if ($fields !== null) {
            if (strpos($fields, ',') !== false) {
                return explode(',', $fields);
            }

            return array($fields);
        }

        $fields = array();
        $contentFields = $contentType->getFieldDefinitions();

        foreach ($contentFields as $field) {
            $fields[] = $field->identifier;
        }

        return $fields;
    }
933210
public function getContent(string $contentType = null): string
    {
/*
        if(null == $contentType)
            $contentType = $this->contentType;
*/
        switch($contentType) {
            case 'application/vnd.transitive.document+json':
                return $this->route->getDocument();
            break;
            case 'application/vnd.transitive.document+xml':
                return $this->route->getDocument()->asXML('document');
            break;
            case 'application/vnd.transitive.document+yaml':
                return $this->route->getDocument()->asYAML();
            break;
            case 'application/vnd.transitive.head+json':
                return $this->route->getHead()->asJson();
            break;
            case 'application/vnd.transitive.head+xml':
                return $this->route->getHead()->asXML('head');
            break;
            case 'application/vnd.transitive.head+yaml':
                return $this->route->getHead()->asYAML();
            break;
            case 'application/vnd.transitive.content+xhtml': case 'application/vnd.transitive.content+html':
                return $this->route->getContent();
            break;
            case 'application/vnd.transitive.content+json':
                return $this->route->getContent()->asJson();
            break;
            case 'application/vnd.transitive.content+xml':
                return $this->route->getContent()->asXML('content');
            break;
            case 'application/vnd.transitive.content+yaml':
                return $this->route->getContent()->asYAML();
            break;

            case 'text/plain':
                return $this->layout->getContent()->asString();
            break;

            case 'application/json':
                if($this->route->hasContent('application/json'))
                    return $this->route->getContentByType('application/json')->asJson();
                elseif(404 != http_response_code()) {
                    http_response_code(404);
                    $_SERVER['REDIRECT_STATUS'] = 404;

                    return '';
                }
            break;
            case 'application/xml':
                if($this->route->hasContent('application/xml'))
                    return $this->route->getContentByType('application/xml')->asJson();
                elseif(404 != http_response_code()) {
                    http_response_code(404);
                    $_SERVER['REDIRECT_STATUS'] = 404;

                    return '';
                }

            break;

            default:
                return $this->layout->getView();
        }
    }
551384
public function getContentTypeName($contentType)
    {
        if (!$contentType instanceof ContentType) {
            try {
                $contentType = $this->contentTypeService->loadContentType($contentType);
            } catch (NotFoundException $e) {
                return '';
            }
        }

        return $contentType->getName();
    }