add new function attachDefaultListener() in FileUpload Service and change import function in Reference Service

This commit is contained in:
Jianxuan Li 2015-01-12 20:59:23 +08:00
parent b113f19dce
commit 23f3a7828c
2 changed files with 10 additions and 3 deletions

View File

@ -39,9 +39,6 @@ class Upload extends AbstractEventManager implements ServiceManagerAwareInterfac
public function init() public function init()
{ {
$Listener = new DefaultFileUploadListener;
$this->getEventManager()->attachAggregate($Listener);
$configService = $this->serviceManager->get('ConfigService'); $configService = $this->serviceManager->get('ConfigService');
$this->config = $configService->get('file.php'); $this->config = $configService->get('file.php');
} }
@ -51,6 +48,15 @@ class Upload extends AbstractEventManager implements ServiceManagerAwareInterfac
return $this->upload($files,$rootDir,$childDir,$fileName,$dateDirModel); return $this->upload($files,$rootDir,$childDir,$fileName,$dateDirModel);
} }
/**
* 添加默认侦听器会将信息保存到Attachments数据表
*/
public function attachDefaultListener()
{
$Listener = new DefaultFileUploadListener;
$this->getEventManager()->attachAggregate($Listener);
}
/** /**
* 上传文件 * 上传文件
* @param $files 上传文件的信息 e.g.$_FILE['fileData'] * @param $files 上传文件的信息 e.g.$_FILE['fileData']

View File

@ -97,6 +97,7 @@ class Reference extends AbstractEventManager implements ServiceManagerAwareInter
$appConfig = $configService->get('application.ini'); $appConfig = $configService->get('application.ini');
$fileUploadService = $this->serviceManager->get('File/Upload'); $fileUploadService = $this->serviceManager->get('File/Upload');
$fileUploadService->attachDefaultListener();
$fileUploadService->setParams(['file_type' => 'literature']); $fileUploadService->setParams(['file_type' => 'literature']);
$file_info = $fileUploadService($file,$appConfig['reference_save_path'],"","",$fileUploadService::DATETIME_MODEL_Y); $file_info = $fileUploadService($file,$appConfig['reference_save_path'],"","",$fileUploadService::DATETIME_MODEL_Y);