@param      $filenameRecords
@param      $filenameCMDL
@param null $contentTypeName
@param null $contentTypeTitle

@return $this
@throws AnyContentClientException
487194
public function addContentType($contentTypeName, $filenameCMDL, $filenameRecords)
    {
        /*$fs = new Filesystem();

        if (!$fs->exists($filenameCMDL))
        {
            throw new AnyContentClientException('File ' . $filenameRecords . ' not found.');
        }

        if (!$fs->exists($filenameRecords))
        {
            throw new AnyContentClientException('File ' . $filenameRecords . ' not found.');
        }*/

        $this->contentTypes[$contentTypeName] = [ 'records' => $filenameRecords, 'cmdl' => $filenameCMDL ];

        return $this;
    }
1284299
public function setFile(Swift_FileStream $file, $contentType = null)
    {
        $this->setFilename(basename($file->getPath()));
        $this->setBody($file, $contentType);
        if (!isset($contentType)) {
            $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1));

            if (array_key_exists($extension, $this->mimeTypes)) {
                $this->setContentType($this->mimeTypes[$extension]);
            }
        }

        return $this;
    }
1325133
public function uploadString($name, $content, $contentType = 'text/plain')
    {
        $fileName = $this->path . '/' . $this->getFilePathAndUniquePrefix() . $name;

        if ($contentType === 'application/json') {
            $content = Json::prettyPrint($content);
        }

        (new Filesystem)->dumpFile($fileName, $content);

        return $fileName;
    }
506130
public static void initFileSendHeader(HttpServletResponse res, String filename, String contentType) {

        filename = getEncodingFileName(filename);
        if (contentType != null) {
            res.setContentType(contentType);
        } else {
            res.setContentType("applicaiton/download;charset=utf-8");
        }
        res.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\";");
        res.setHeader("Content-Transfer-Encoding", "binary");
        res.setHeader("file-name", filename);

    }
861447
public function getAllRecords($contentTypeName = null, DataDimensions $dataDimensions = null)
    {
        if ($contentTypeName == null) {
            $contentTypeName = $this->getCurrentContentTypeName();
        }

        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        $tableName = $this->getContentTypeTableName($contentTypeName);

        $sql = 'SELECT * FROM ' . $tableName . ' WHERE workspace = ? AND language = ? AND deleted = 0 AND validfrom_timestamp <= ? AND validuntil_timestamp > ?';

        $timestamp = TimeShifter::getTimeshiftTimestamp($dataDimensions->getTimeShift());

        $rows = $this->getDatabase()
                     ->fetchAllSQL($sql, [$dataDimensions->getWorkspace(), $dataDimensions->getLanguage(), $timestamp, $timestamp]);

        $records = [];
        foreach ($rows as $row) {
            $records[$row['id']] = $this->createRecordFromRow($row, $contentTypeName, $dataDimensions);
        }

        return $records;
    }
909863
public function getRevisionsOfRecord($recordId, $contentTypeName = null)
    {
        if (!$this->readConnection instanceof RevisionConnection) {
            throw new AnyContentClientException ('Current connection doesn\'t support revision operations.');
        }

        $contentTypeName = $this->getCurrentContentTypeName();
        $dataDimensions  = $this->getCurrentDataDimensions();

        return $this->readConnection->getRevisionsOfRecord($recordId, $contentTypeName, $dataDimensions);
    }
636377
public function setContentType($contentType, $charset=NULL){
        $this->setHeader("Content-Type", $contentType);
        if($charset != NULL){
            $this->setHeader("charset", $charset);
        }
    }
471066
private function logChange($contentType, $contentId, $newContent = null, $oldContent = null, $comment = null)
    {
        $type = $oldContent ? 'Update' : 'Insert';

        $this->loggerChange->info(
            $type . ' record',
            [
                'action'      => strtoupper($type),
                'contenttype' => $contentType,
                'id'          => $contentId,
                'new'         => $newContent ? $newContent->toArray() : null,
                'old'         => $oldContent ? $oldContent->toArray() : null,
                'comment'     => $comment,
            ]
        );
    }
604424
public function createNewFields(Content $content, Type $contentType)
    {
        $fieldsToCopy = array();
        $languageCodes = array();
        $fields = $this->getFieldMap($content->fields, $languageCodes);
        $languageCodes[$content->versionInfo->contentInfo->mainLanguageCode] = true;

        foreach ($contentType->fieldDefinitions as $fieldDefinition) {
            foreach (array_keys($languageCodes) as $languageCode) {
                // Create fields passed from struct
                if (isset($fields[$fieldDefinition->id][$languageCode])) {
                    $field = $fields[$fieldDefinition->id][$languageCode];
                    $this->createNewField($field, $content);
                } elseif (
                    !$fieldDefinition->isTranslatable
                    && isset($fields[$fieldDefinition->id][$content->versionInfo->contentInfo->mainLanguageCode])
                ) {
                    // Copy only for untranslatable field and when field in main language exists
                    // Only register here, process later as field copied should be already stored
                    $fieldsToCopy[$fieldDefinition->id][$languageCode] =
                        $fields[$fieldDefinition->id][$content->versionInfo->contentInfo->mainLanguageCode];
                } else { // In all other cases create empty field
                    $field = $this->getEmptyField($fieldDefinition, $languageCode);
                    $content->fields[] = $field;
                    $this->createNewField($field, $content);
                }
            }
        }

        $this->copyFields($fieldsToCopy, $content);
    }
877112
public static function serve($filename, $contentType, $options)
    {
        $options = array_merge(self::$defaultOptions, $options);

        if ($options['set-last-modified-header'] === true) {
            Header::setHeader("Last-Modified: " . gmdate("D, d M Y H:i:s", @filemtime($filename)) ." GMT");
        }

        if ($options['set-content-type-header'] === true) {
            Header::setHeader('Content-type: ' . $contentType);
        }

        if ($options['add-vary-accept-header'] === true) {
            Header::addHeader('Vary: Accept');
        }

        if ($options['set-cache-control-header'] === true) {
            if (!empty($options['cache-control-header'])) {
                Header::setHeader('Cache-Control: ' . $options['cache-control-header']);

                // Add exprires header too (#126)
                // Check string for something like this: max-age:86400
                if (preg_match('#max-age\\s*=\\s*(\\d*)#', $options['cache-control-header'], $matches)) {
                    $seconds = $matches[1];
                    Header::setHeader('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + intval($seconds)));
                }
            }
        }

        if (@readfile($filename) === false) {
            Header::addHeader('X-WebP-Convert-Error: Could not read file');
            throw new ServeFailedException('Could not read file');
        }
    }
129840
public function countRecords($contentTypeName = null, DataDimensions $dataDimensions = null)
    {
        if ($contentTypeName == null) {
            $contentTypeName = $this->getCurrentContentTypeName();
        }

        if ($dataDimensions == null) {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        $tableName = $this->getContentTypeTableName($contentTypeName);

        $sql = 'SELECT COUNT(*) AS C FROM ' . $tableName . ' WHERE workspace = ? AND language = ? AND deleted = 0 AND validfrom_timestamp <= ? AND validuntil_timestamp > ?';

        $timestamp = TimeShifter::getTimeshiftTimestamp($dataDimensions->getTimeShift());

        $row = $this->getDatabase()
                    ->fetchOneSQL($sql, [$dataDimensions->getWorkspace(), $dataDimensions->getLanguage(), $timestamp, $timestamp]);

        return $row['C'];
    }
792526
private function logInsert($contenttype, $contentid, $content, $comment = null)
    {
        $this->app['logger.change']->info(
            'Insert record',
            [
                'action'      => 'INSERT',
                'contenttype' => $contenttype,
                'id'          => $contentid,
                'new'         => $content,
                'old'         => null,
                'comment'     => $comment,
            ]
        );
    }
1327953
public function countRecords($contentTypeName = null, DataDimensions $dataDimensions = null)
    {
        if ($contentTypeName == null)
        {
            $contentTypeName = $this->getCurrentContentTypeName();
        }

        if ($dataDimensions == null)
        {
            $dataDimensions = $this->getCurrentDataDimensions();
        }

        if ($this->hasContentType($contentTypeName))
        {

            $info = $this->getRepositoryInfo($dataDimensions);

            return $info['content'][$contentTypeName]['count'];
        }

        throw new AnyContentClientException ('Unknown content type ' . $contentTypeName);

    }
92736
@Override
    public void setContent(final InputStream content, final String contentType,
                           final Collection<URI> checksums, final String originalFileName,
                           final StoragePolicyDecisionPoint storagePolicyDecisionPoint)
            throws UnsupportedOperationException {
        throw new UnsupportedOperationException(
                "Cannot call setContent() on local file, call setExternalContent() instead");
    }
1281140
public function upload($filePath, $contentType = 'text/plain')
    {
        $fileName = $this->path . '/' . $this->getFilePathAndUniquePrefix() . basename($filePath);

        (new Filesystem)->copy($filePath, $fileName);

        return $fileName;
    }
1043290
public function changeLogRecord($contenttype, $contentid)
    {
        $options = [
            'contentid' => $contentid,
            'limit'     => 4,
            'order'     => 'date',
            'direction' => 'DESC',
        ];

        /** @var Repository\LogChangeRepository $repo */
        $repo = $this->storage()->getRepository(Entity\LogChange::class);

        $context = [
            'contenttype' => $contenttype,
            'entries'     => $repo->getChangeLogByContentType($contenttype, $options),
        ];

        return $this->render('@bolt/components/panel-change-record.twig', ['context' => $context]);
    }
1173598
public function addFile($filename, FormatChainInterface $formatChain = null)
    {
        if (null === $formatChain) {
            if (null === $this->formatGuesser) {
                throw new FormatGuesserRequiredException();
            }

            $formatChain = $this->formatGuesser->guess($filename);
        }

        $this->files[] = new File($filename, $formatChain);

        return $this;
    }