parent
a1ed80a9ca
commit
024b9ea4e9
@ -0,0 +1,36 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\Zoom\API; |
||||
|
||||
use Exception; |
||||
|
||||
class RecordingList |
||||
{ |
||||
use Pagination; |
||||
|
||||
/** @var string Start Date */ |
||||
public $from; |
||||
|
||||
/** @var string End Date */ |
||||
public $to; |
||||
|
||||
/** @var RecordingMeeting[] List of recordings */ |
||||
public $meetings; |
||||
|
||||
public function __construct() |
||||
{ |
||||
$this->meetings = []; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function itemClass($propertyName) |
||||
{ |
||||
if ('meetings' === $propertyName) { |
||||
return RecordingMeeting::class; |
||||
} |
||||
throw new Exception("No such array property $propertyName"); |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\Zoom; |
||||
|
||||
use Exception; |
||||
|
||||
class File extends API\RecordingFile |
||||
{ |
||||
/** @var string */ |
||||
public $formattedFileSize; |
||||
|
||||
/** |
||||
* Makes a File out of a RecordingFile. |
||||
* |
||||
* @param API\RecordingFile $source |
||||
* |
||||
* @throws Exception |
||||
* |
||||
* @return static |
||||
*/ |
||||
public static function fromRecordingFile($source) |
||||
{ |
||||
$instance = new static(); |
||||
self::recursivelyCopyObjectProperties($source, $instance); |
||||
|
||||
$instance->formattedFileSize = format_file_size($instance->file_size); |
||||
|
||||
return $instance; |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\Zoom; |
||||
|
||||
use DateInterval; |
||||
use DateTime; |
||||
use DateTimeZone; |
||||
use Exception; |
||||
|
||||
class Recording extends API\RecordingMeeting |
||||
{ |
||||
/** @var File[] List of recording file. */ |
||||
public $recording_files; |
||||
|
||||
/** @var DateTime */ |
||||
public $startDateTime; |
||||
|
||||
/** @var string */ |
||||
public $formattedStartTime; |
||||
|
||||
/** @var DateInterval */ |
||||
public $durationInterval; |
||||
|
||||
/** @var string */ |
||||
public $formattedDuration; |
||||
|
||||
/** |
||||
* Builds a Recording from a RecordingMeeting. |
||||
* |
||||
* @param API\RecordingMeeting $recordingMeeting |
||||
* |
||||
* @throws Exception |
||||
* |
||||
* @return static |
||||
*/ |
||||
public static function fromRecodingMeeting($recordingMeeting) |
||||
{ |
||||
$instance = new static(); |
||||
self::recursivelyCopyObjectProperties($recordingMeeting, $instance); |
||||
|
||||
$newRecordingFiles = []; |
||||
foreach ($instance->recording_files as $file) { |
||||
$newRecordingFiles[] = File::fromRecordingFile($file); |
||||
} |
||||
$instance->recording_files = $newRecordingFiles; |
||||
|
||||
$instance->startDateTime = new DateTime($instance->start_time); |
||||
$instance->startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); |
||||
$instance->formattedStartTime = $instance->startDateTime->format(get_lang('Y-m-d H:i')); |
||||
|
||||
$now = new DateTime(); |
||||
$later = new DateTime(); |
||||
$later->add(new DateInterval('PT'.$instance->duration.'M')); |
||||
$instance->durationInterval = $later->diff($now); |
||||
$instance->formattedDuration = $instance->durationInterval->format(get_lang('DurationFormat')); |
||||
|
||||
return $instance; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function itemClass($propertyName) |
||||
{ |
||||
if ('recording_files' === $propertyName) { |
||||
return File::class; |
||||
} |
||||
return parent::itemClass($propertyName); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue