Skip to content

Commit

Permalink
add application/yml to allowed return types
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed May 2, 2024
1 parent 1c9cf57 commit d2ff248
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions LitCalEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$LitCalEngine->APICore->setAllowedOrigins( $allowedOrigins );
$LitCalEngine->APICore->setAllowedRequestMethods( [ RequestMethod::GET, RequestMethod::POST, RequestMethod::OPTIONS ] );
$LitCalEngine->APICore->setAllowedRequestContentTypes( [ RequestContentType::JSON, RequestContentType::FORMDATA ] );
$LitCalEngine->APICore->setAllowedAcceptHeaders( [ AcceptHeader::JSON, AcceptHeader::XML, AcceptHeader::ICS ] );
$LitCalEngine->setAllowedReturnTypes( [ ReturnType::JSON, ReturnType::XML, ReturnType::ICS ] );
$LitCalEngine->APICore->setAllowedAcceptHeaders( [ AcceptHeader::JSON, AcceptHeader::XML, AcceptHeader::ICS, AcceptHeader::YML ] );
$LitCalEngine->setAllowedReturnTypes( [ ReturnType::JSON, ReturnType::XML, ReturnType::ICS, ReturnType::YML ] );
$LitCalEngine->setCacheDuration( CacheDuration::MONTH );
$LitCalEngine->Init();
8 changes: 8 additions & 0 deletions includes/LitCalAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2902,6 +2902,14 @@ private function generateResponse() {
// in the response we return the pretty printed version
$response = $dom->saveXML();
break;
case ReturnType::YML:
// first convert the Object to an Array
$jsonStr = json_encode( $SerializeableLitCal );
$jsonObj = json_decode( $jsonStr, true );

// then create a YAML representation from the Array
$response = yaml_emit( $jsonObj, YAML_UTF8_ENCODING );
break;
case ReturnType::ICS:
$infoObj = $this->getGithubReleaseInfo();
if( $infoObj->status === "success" ) {
Expand Down

0 comments on commit d2ff248

Please sign in to comment.