Neos.Neos/Classes/Command/SiteCommandController.php
public function importCommand($packageKey = null, $filename = null)
    {
        $exceedingArguments = $this->request->getExceedingArguments();
        if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
            if (file_exists($exceedingArguments[0])) {
                $filename = $exceedingArguments[0];
            } elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
                $packageKey = $exceedingArguments[0];
            }
        }

        if ($packageKey === null && $filename === null) {
            $this->outputLine('You have to specify either "--package-key" or "--filename"');
            $this->quit(1);
        }

        // Since this command uses a lot of memory when large sites are imported, we warn the user to watch for
        // the confirmation of a successful import.
        $this->outputLine('<b>This command can use a lot of memory when importing sites with many resources.</b>');
        $this->outputLine('If the import is successful, you will see a message saying "Import of site ... finished".');
        $this->outputLine('If you do not see this message, the import failed, most likely due to insufficient memory.');
        $this->outputLine('Increase the <b>memory_limit</b> configuration parameter of your php CLI to attempt to fix this.');
        $this->outputLine('Starting import...');
        $this->outputLine('---');


        $site = null;
        if ($filename !== null) {
            try {
                $site = $this->siteImportService->importFromFile($filename);
            } catch (\Exception $exception) {
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', [$filename, $exception->getMessage()]);
                $this->quit(1);
            }
        } else {
            try {
                $site = $this->siteImportService->importFromPackage($packageKey);
            } catch (\Exception $exception) {
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', [$packageKey, $exception->getMessage()]);
                $this->quit(1);
            }
        }
        $this->outputLine('Import of site "%s" finished.', [$site->getName()]);
    }
public function importCommand($packageKey = null, $filename = null)
    {
        $exceedingArguments = $this->request->getExceedingArguments();
        if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
            if (file_exists($exceedingArguments[0])) {
                $filename = $exceedingArguments[0];
            } elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
                $packageKey = $exceedingArguments[0];
            }
        }

        if ($packageKey === null && $filename === null) {
            $this->outputLine('You have to specify either "--package-key" or "--filename"');
            $this->quit(1);
        }

        // Since this command uses a lot of memory when large sites are imported, we warn the user to watch for
        // the confirmation of a successful import.
        $this->outputLine('<b>This command can use a lot of memory when importing sites with many resources.</b>');
        $this->outputLine('If the import is successful, you will see a message saying "Import of site ... finished".');
        $this->outputLine('If you do not see this message, the import failed, most likely due to insufficient memory.');
        $this->outputLine('Increase the <b>memory_limit</b> configuration parameter of your php CLI to attempt to fix this.');
        $this->outputLine('Starting import...');
        $this->outputLine('---');


        $site = null;
        if ($filename !== null) {
            try {
                $site = $this->siteImportService->importFromFile($filename);
            } catch (\Exception $exception) {
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', [$filename, $exception->getMessage()]);
                $this->quit(1);
            }
        } else {
            try {
                $site = $this->siteImportService->importFromPackage($packageKey);
            } catch (\Exception $exception) {
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', [$packageKey, $exception->getMessage()]);
                $this->quit(1);
            }
        }
        $this->outputLine('Import of site "%s" finished.', [$site->getName()]);
    }
public function importCommand ( $ packageKey = null , $ filename = null ) { $ exceedingArguments = $ this -> request -> getExceedingArguments ( ) ; if ( isset ( $ exceedingArguments [ 0 ] ) && $ packageKey === null && $ filename === null ) { if ( file_exists ( $ exceedingArguments [ 0 ] ) ) { $ filename = $ exceedingArguments [ 0 ] ; } elseif ( $ this -> packageManager -> isPackageAvailable ( $ exceedingArguments [ 0 ] ) ) { $ packageKey = $ exceedingArguments [ 0 ] ; } } if ( $ packageKey === null && $ filename === null ) { $ this -> outputLine ( 'You have to specify either "--package-key" or "--filename"' ) ; $ this -> quit ( 1 ) ; } // Since this command uses a lot of memory when large sites are imported, we warn the user to watch for // the confirmation of a successful import. $ this -> outputLine ( '<b>This command can use a lot of memory when importing sites with many resources.</b>' ) ; $ this -> outputLine ( 'If the import is successful, you will see a message saying "Import of site ... finished".' ) ; $ this -> outputLine ( 'If you do not see this message, the import failed, most likely due to insufficient memory.' ) ; $ this -> outputLine ( 'Increase the <b>memory_limit</b> configuration parameter of your php CLI to attempt to fix this.' ) ; $ this -> outputLine ( 'Starting import...' ) ; $ this -> outputLine ( '---' ) ; $ site = null ; if ( $ filename !== null ) { try { $ site = $ this -> siteImportService -> importFromFile ( $ filename ) ; } catch ( \ Exception $ exception ) { $ logMessage = $ this -> throwableStorage -> logThrowable ( $ exception ) ; $ this -> logger -> error ( $ logMessage , LogEnvironment :: fromMethodName ( __METHOD__ ) ) ; $ this -> outputLine ( '<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>' , [ $ filename , $ exception -> getMessage ( ) ] ) ; $ this -> quit ( 1 ) ; } } else { try { $ site = $ this -> siteImportService -> importFromPackage ( $ packageKey ) ; } catch ( \ Exception $ exception ) { $ logMessage = $ this -> throwableStorage -> logThrowable ( $ exception ) ; $ this -> logger -> error ( $ logMessage , LogEnvironment :: fromMethodName ( __METHOD__ ) ) ; $ this -> outputLine ( '<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>' , [ $ packageKey , $ exception -> getMessage ( ) ] ) ; $ this -> quit ( 1 ) ; } } $ this -> outputLine ( 'Import of site "%s" finished.' , [ $ site -> getName ( ) ] ) ; }
Import sites content

This command allows for importing one or more sites or partial content from an XML source. The format must
be identical to that produced by the export command.

If a filename is specified, this command expects the corresponding file to contain the XML structure. The
filename php://stdin can be used to read from standard input.

If a package key is specified, this command expects a Sites.xml file to be located in the private resources
directory of the given package (Resources/Private/Content/Sites.xml).

@param string $packageKey Package key specifying the package containing the sites content
@param string $filename relative path and filename to the XML file containing the sites content
@return void
Import sites content