Doctrine\ODM\CouchDB\UnitOfWork::createDocumentAttachments PHP 메소드

createDocumentAttachments() 개인적인 메소드

private createDocumentAttachments ( string $documentId, array $data ) : array
$documentId string
$data array
리턴 array
    private function createDocumentAttachments($documentId, $data)
    {
        $attachments = array();
        $client = $this->dm->getHttpClient();
        $basePath = '/' . $this->dm->getCouchDBClient()->getDatabase() . '/' . $documentId . '/';
        foreach ($data as $filename => $attachment) {
            if (isset($attachment['stub']) && $attachment['stub']) {
                $instance = Attachment::createStub($attachment['content_type'], $attachment['length'], $attachment['revpos'], $client, $basePath . $filename);
            } else {
                if (isset($attachment['data'])) {
                    $instance = Attachment::createFromBase64Data($attachment['data'], $attachment['content_type'], $attachment['revpos']);
                }
            }
            $attachments[$filename] = $instance;
        }
        return $attachments;
    }