Created
January 29, 2016 18:24
-
-
Save arturom/d0f86a34914239472ccf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fh = STDIN; | |
while (!feof($fh)) { | |
$command = json_decode(fgets($fh)); | |
if(!is_object($command)) { | |
exit; | |
} | |
$body = json_decode(fgets($fh)); | |
if(!is_object($body)) { | |
throw new Exception('Invalid body'); | |
} | |
if(empty($command->index->_type)) { | |
throw new Exception('Missing type'); | |
} | |
if($command->index->_type === 'amassetversion') { | |
if(empty($body->am_asset_id)) { | |
throw new Exception('missing value for "am_asset_id"'); | |
} | |
$command->index->_parent = $body->am_asset_version; | |
} | |
echo json_encode($command), PHP_EOL; | |
echo json_encode($body), PHP_EOL; | |
} | |
echo PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment