Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created February 13, 2013 15:39
Show Gist options
  • Save radmiraal/4945477 to your computer and use it in GitHub Desktop.
Save radmiraal/4945477 to your computer and use it in GitHub Desktop.
<?php
/* *
* This script belongs to the TYPO3 Flow framework. *
* *
* It is free software; you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License, either version 3 *
* of the License, or (at your option) any later version. *
* *
* The TYPO3 project - inspiring people to share! *
* */
/**
* Bootstrap for the command line
*/
if (PHP_SAPI !== 'cli') {
echo(sprintf("The TYPO3 Flow command line script or sub process was executed with a '%s' PHP binary. Make sure that you specified a CLI capable PHP binary in your PATH or Flow's Settings.yaml.", PHP_SAPI) . PHP_EOL);
exit(1);
}
if (isset($argv[1]) && ($argv[1] === 'typo3.flow:core:setfilepermissions' || $argv[1] === 'flow:core:setfilepermissions' || $argv[1] === 'core:setfilepermissions')) {
if (DIRECTORY_SEPARATOR !== '/') {
exit('The core:setfilepermissions command is only available on UNIX platforms.' . PHP_EOL);
}
array_shift($argv);
array_shift($argv);
$returnValue = 0;
system(__DIR__ . '/setfilepermissions.sh ' . implode($argv, ' '), $returnValue);
exit($returnValue);
} elseif (isset($argv[1]) && ($argv[1] === 'typo3.flow:core:migrate' || $argv[1] === 'flow:core:migrate' || $argv[1] === 'core:migrate')) {
array_shift($argv);
array_shift($argv);
require(__DIR__ . '/migrate.php');
} else {
$_SERVER['FLOW_ROOTPATH'] = trim(getenv('FLOW_ROOTPATH'), '"\' ') ?: dirname($_SERVER['PHP_SELF']);
if (!empty($argv[1])) {
$commandParts = explode(':', $argv[1], 2);
if (count($commandParts) === 2) {
foreach (glob($_SERVER['FLOW_ROOTPATH'] . '/Packages/*/*') as $packageDirectory) {
$packageDirectoryParts = explode(DIRECTORY_SEPARATOR, $packageDirectory);
$scriptFilename = $packageDirectory . '/Scripts/' . str_replace(':', '_', $commandParts[1]) . '.php';
if (strtolower(array_pop($packageDirectoryParts)) === $commandParts[0] && is_file($scriptFilename)) {
array_shift($argv);
array_shift($argv);
require($scriptFilename);
exit(0);
}
}
}
}
require(__DIR__ . '/../Classes/TYPO3/Flow/Core/Bootstrap.php');
$context = trim(getenv('FLOW_CONTEXT'), '"\' ') ?: 'Development';
$bootstrap = new \TYPO3\Flow\Core\Bootstrap($context);
$bootstrap->run();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment