Milliner/src/Service/MillinerService.php
protected function createNode(
        $uuid,
        $jsonld_url,
        $token = null
    ) {
        // Mint a new Fedora URL.
        $fedora_url = $this->gemini->mintFedoraUrl($uuid, $token);

        // Get the jsonld from Drupal.
        $headers = empty($token) ? [] : ['Authorization' => $token];
        $drupal_response = $this->drupal->get(
            $jsonld_url,
            ['headers' => $headers]
        );

        $jsonld = json_decode(
            $drupal_response->getBody(),
            true
        );

        // Mash it into the shape Fedora accepts.
        $jsonld = $this->processJsonld(
            $jsonld,
            $jsonld_url,
            $fedora_url
        );

        // Save it in Fedora.
        $headers['Content-Type'] = 'application/ld+json';
        $headers['Prefer'] = 'return=minimal; handling=lenient';
        $response = $this->fedora->saveResource(
            $fedora_url,
            json_encode($jsonld),
            $headers
        );

        $status = $response->getStatusCode();
        if (!in_array($status, [201, 204])) {
            $reason = $response->getReasonPhrase();
            throw new \RuntimeException(
                "Client error: `PUT $fedora_url` resulted in a `$status $reason` response: " . $response->getBody(),
                $status
            );
        }

        // Map the URLS.
        $this->gemini->saveUrls(
            $uuid,
            $jsonld_url,
            $fedora_url,
            $token
        );

        // Return the response from Fedora.
        return $response;
    }
protected function createNode(
        $uuid,
        $jsonld_url,
        $token = null
    ) {
        // Mint a new Fedora URL.
        $fedora_url = $this->gemini->mintFedoraUrl($uuid, $token);

        // Get the jsonld from Drupal.
        $headers = empty($token) ? [] : ['Authorization' => $token];
        $drupal_response = $this->drupal->get(
            $jsonld_url,
            ['headers' => $headers]
        );

        $jsonld = json_decode(
            $drupal_response->getBody(),
            true
        );

        // Mash it into the shape Fedora accepts.
        $jsonld = $this->processJsonld(
            $jsonld,
            $jsonld_url,
            $fedora_url
        );

        // Save it in Fedora.
        $headers['Content-Type'] = 'application/ld+json';
        $headers['Prefer'] = 'return=minimal; handling=lenient';
        $response = $this->fedora->saveResource(
            $fedora_url,
            json_encode($jsonld),
            $headers
        );

        $status = $response->getStatusCode();
        if (!in_array($status, [201, 204])) {
            $reason = $response->getReasonPhrase();
            throw new \RuntimeException(
                "Client error: `PUT $fedora_url` resulted in a `$status $reason` response: " . $response->getBody(),
                $status
            );
        }

        // Map the URLS.
        $this->gemini->saveUrls(
            $uuid,
            $jsonld_url,
            $fedora_url,
            $token
        );

        // Return the response from Fedora.
        return $response;
    }
protected function createNode ( $ uuid , $ jsonld_url , $ token = null ) { // Mint a new Fedora URL. $ fedora_url = $ this -> gemini -> mintFedoraUrl ( $ uuid , $ token ) ; // Get the jsonld from Drupal. $ headers = empty ( $ token ) ? [ ] : [ 'Authorization' => $ token ] ; $ drupal_response = $ this -> drupal -> get ( $ jsonld_url , [ 'headers' => $ headers ] ) ; $ jsonld = json_decode ( $ drupal_response -> getBody ( ) , true ) ; // Mash it into the shape Fedora accepts. $ jsonld = $ this -> processJsonld ( $ jsonld , $ jsonld_url , $ fedora_url ) ; // Save it in Fedora. $ headers [ 'Content-Type' ] = 'application/ld+json' ; $ headers [ 'Prefer' ] = 'return=minimal; handling=lenient' ; $ response = $ this -> fedora -> saveResource ( $ fedora_url , json_encode ( $ jsonld ) , $ headers ) ; $ status = $ response -> getStatusCode ( ) ; if ( ! in_array ( $ status , [ 201 , 204 ] ) ) { $ reason = $ response -> getReasonPhrase ( ) ; throw new \ RuntimeException ( "Client error: `PUT $fedora_url` resulted in a `$status $reason` response: " . $ response -> getBody ( ) , $ status ) ; } // Map the URLS. $ this -> gemini -> saveUrls ( $ uuid , $ jsonld_url , $ fedora_url , $ token ) ; // Return the response from Fedora. return $ response ; }
Creates a new LDP-RS in Fedora from a Node.

@param string $uuid
@param string $jsonld_url
@param string $token

@return \GuzzleHttp\Psr7\Response

@throws \RuntimeException
@throws \GuzzleHttp\Exception\RequestException
Creates a new LDP - RS in Fedora from a Node .