Newscoop\Services\AttachmentService::fillAttachment PHP Method

fillAttachment() private method

private fillAttachment ( Attachment $attachment, $attributes )
$attachment Newscoop\Entity\Attachment
    private function fillAttachment(Attachment $attachment, $attributes)
    {
        $user = $this->userService->getCurrentUser();
        $attributes = array_merge(array('language' => null, 'name' => null, 'extension' => null, 'mimeType' => null, 'contentDisposition' => Attachment::CONTENT_DISPOSITION, 'httpCharset' => null, 'sizeInBytes' => null, 'description' => null, 'user' => null, 'updated' => new \DateTime(), 'source' => 'local', 'status' => 'unapproved'), $attributes);
        if ($user->hasPermission('AddFile') || $user->hasPermission('ChangeFile')) {
            $attributes['status'] = 'approved';
        }
        if (!is_null($attributes['language'])) {
            $attachment->setLanguage($attributes['language']);
        }
        if (!is_null($attributes['description'])) {
            $attachment->setDescription($attributes['description']);
        }
        $attachment->setName($attributes['name'])->setExtension($attributes['extension'])->setMimeType($attributes['mimeType'])->setContentDisposition($attributes['contentDisposition'])->setHttpCharset($attributes['httpCharset'])->setSizeInBytes($attributes['sizeInBytes'])->setUser($attributes['user'])->setUpdated($attributes['updated'])->setSource($attributes['source'])->setStatus($attributes['status']);
        return $attachment;
    }