Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/public/plugin/whispeakauth/Controller/BaseController.php

67 lines
1.5 KiB

<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\WhispeakAuth\Controller;
use Chamilo\UserBundle\Entity\User;
use FFMpeg\FFMpeg;
use FFMpeg\Format\Audio\Wav;
use WhispeakAuthPlugin;
/**
* Class BaseController.
*/
abstract class BaseController
{
/**
* @var WhispeakAuthPlugin
*/
protected $plugin;
/**
* BaseController constructor.
*/
public function __construct()
{
$this->plugin = WhispeakAuthPlugin::create();
}
/**
* @param bool $isFullPage
*
* @return mixed
*/
abstract protected function displayPage($isFullPage, array $variables);
/**
* @throws \Exception
*
* @return string
*/
protected function uploadAudioFile(User $user)
{
throw new Exception('@todo uploadAudioFile');
$pluginName = $this->plugin->get_name();
//$path = api_upload_file($pluginName, $_FILES['audio'], $user->getId());
if (false === $path) {
throw new \Exception(get_lang('UploadError'));
}
$fullPath = api_get_path(SYS_UPLOAD_PATH).$pluginName.$path['path_to_save'];
$mimeType = mime_content_type($fullPath);
if ('wav' !== substr($mimeType, -3)) {
$ffmpeg = FFMpeg::create();
$audioFile = $ffmpeg->open($fullPath);
$fullPath = dirname($fullPath).'/audio.wav';
$audioFile->save(new Wav(), $fullPath);
}
return $fullPath;
}
}