Skip to content

Commit

Permalink
Move xml generation to central place
Browse files Browse the repository at this point in the history
  • Loading branch information
sanduhrs committed Aug 5, 2020
1 parent a67778b commit 8471ea6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
28 changes: 0 additions & 28 deletions src/BigBlueButton/Member/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
class Document
{

const XML_VERSION = '1.0';

const XML_ENCODING = 'UTF-8';

/**
* The URI.
*
Expand Down Expand Up @@ -156,30 +152,6 @@ public function setBase64($base64)
return $this;
}

/**
* Get XML representation of the document for upload.
*
* @return \DOMElement
*/
public function getXmlString()
{
$xml = new \DOMDocument(self::XML_VERSION, self::XML_ENCODING);
if ($this->isEmbedded()) {
if ($this->getBase64() === '') {
$this->setBase64(base64_encode(file_get_contents($this->getUri())));
}
$document = $xml->createElement("document", $this->getBase64());
$document->setAttribute('name', $this->getName());
$xml->appendChild($document);
} else {
$document = $xml->createElement("document", $this->getBase64());
$document->setAttribute('url', $this->getUri());
$document->setAttribute('filename', $this->getName());
$xml->appendChild($document);
}
return $xml->saveXML($xml->documentElement);
}

/**
* Set the client.
*
Expand Down
31 changes: 28 additions & 3 deletions src/BigBlueButton/Member/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Meeting

const GUEST_POLICY_ASK_MODERATOR = 'ASK_MODERATOR';

const XML_VERSION = '1.0';

const XML_ENCODING = 'UTF-8';

/**
* The meeting name.
*
Expand Down Expand Up @@ -394,7 +398,7 @@ class Meeting
/**
* The slides.
*
* @var array
* @var \sanduhrs\BigBlueButton\Member\Document[]
*/
protected $slides;

Expand Down Expand Up @@ -1601,14 +1605,35 @@ public function create()
'lockSettingsLockedLayout' => $this->getLockSettingsLockedLayout(),
'lockSettingsLockOnJoin' => $this->getLockSettingsLockOnJoin(),
'lockSettingsLockOnJoinConfigurable' => $this->getLockSettingsLockOnJoinConfigurable(),
'body' => '',
];

foreach ($this->getMetadata() as $key => $value) {
$parameters["meta_$key"] = $value;
}


$xml = new \DOMDocument(self::XML_VERSION, self::XML_ENCODING);
$modules = $xml->createElement("modules");
$module = $xml->createElement("module");
$module->setAttribute('name', 'presentation');
$modules->appendChild($module);
foreach ($this->getSlides() as $slide) {
if ($slide->isEmbedded()) {
if ($slide->getBase64() === '') {
$slide->setBase64(base64_encode(file_get_contents($slide->getUri())));
}
$document = $xml->createElement("document", $slide->getBase64());
$document->setAttribute('name', $slide->getName());
$module->appendChild($document);
} else {
$document = $xml->createElement("document", $slide->getBase64());
$document->setAttribute('url', $slide->getUri());
$document->setAttribute('filename', $slide->getName());
$module->appendChild($document);
}
}
$xml->appendChild($modules);
$body = $xml->saveXML($xml->documentElement);
$parameters['body'] = $body;

$response = $this->client->post('create', $parameters);
$this->meetingID = $response->meetingID;
Expand Down

0 comments on commit 8471ea6

Please sign in to comment.