0

我正在尝试为新创建的用户添加新的文件挂载。是否可以使用 Typo3 中的 Datahandler?我尝试了以下方法,但它不起作用:

$file_data['sys_filemounts']['NEW'] = array(
    'base' => 2,
    'description' => '',
    'hidden' => 0,
    'read_only' => 0,
    'title' => strtolower($userName[0]."-".$userName[1]),
    'path' => '/user_upload/MPL-People/'.strtolower($userName[0]."-".$userName[1].'/'),
    'tx_gdemployeeimport_adid' => $adid
);
$this->createDir($userName);

$this->datahandler->start($file_data,array());

$this->datahandler->process_datamap();
$this->datahandler->clear_cacheCmd('all');
4

1 回答 1

0
    $userName = explode(" ", $json['cn']);
    $formatedName = strtolower($userName[0]."-".$userName[1]);
    $extbaseObjectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
    $newfileMountModel = $extbaseObjectManager->get('Graphodata\Gdemployeeimport\Domain\Model\GdFileMount');
    $fileMountRepository = $extbaseObjectManager->get('Graphodata\Gdemployeeimport\Domain\Repository\GdFileMountRepository');

    $newfileMountModel->setBase(2);
    $newfileMountModel->setPid(0);
    $newfileMountModel->setDescription('');
    $newfileMountModel->setPath('/user_upload/MPL-People/'.$formatedName.'/');
    $newfileMountModel->setReadOnly(0);
    $newfileMountModel->setTitle($formatedName);
    $newfileMountModel->setTitle($formatedName);
    $newfileMountModel->setTxGdemployeeimportAdid($adid);

    $fileMountRepository->add($newfileMountModel);
    unset($newfileMountModel);

这行得通...无论如何,谢谢:)

于 2018-01-17T07:52:45.617 回答