TYPO3 CMS  TYPO3_6-2
ImportExportUtility.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
35  public function importT3DFile($file, $pid) {
36  if (!is_string($file)) {
37  throw new \InvalidArgumentException('Input parameter $file has to be of type string', 1377625645);
38  }
39  if (!is_int($pid)) {
40  throw new \InvalidArgumentException('Input parameter $int has to be of type integer', 1377625646);
41  }
43  $import = GeneralUtility::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
44  $import->init(0, 'import');
45 
46  $importResponse = 0;
48 
49  if ($file && @is_file($file)) {
50  if ($import->loadFile($file, 1)) {
51  // Import to root page:
52  $import->importData($pid);
53  // Get id of first created page:
54  $newPages = $import->import_mapId['pages'];
55  $importResponse = (int)reset($newPages);
56  }
57  }
58 
59  // Check for errors during the import process:
60  $errors = $import->printErrorLog();
61  if ($errors !== '') {
63  $logger = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogManager')->getLogger(__CLASS__);
64  $logger->warning($errors);
65 
66  if (!$importResponse) {
67  throw new \ErrorException('No page records imported', 1377625537);
68  }
69  }
70  return $importResponse;
71  }
72 
78  protected function getSignalSlotDispatcher() {
79  return GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
80  }
81 
89  protected function emitAfterImportExportInitialisationSignal(\TYPO3\CMS\Impexp\ImportExport $import) {
90  $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'afterImportExportInitialisation', array($import));
91  }
92 
93 }
emitAfterImportExportInitialisationSignal(\TYPO3\CMS\Impexp\ImportExport $import)