本文整理汇总了PHP中Shell::loadTasks方法的典型用法代码示例。如果您正苦于以下问题:PHP Shell::loadTasks方法的具体用法?PHP Shell::loadTasks怎么用?PHP Shell::loadTasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shell
的用法示例。
在下文中一共展示了Shell::loadTasks方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadTasks
/**
* Override loadTasks() to handle paths
*
* @access public
*/
function loadTasks()
{
parent::loadTasks();
$task = Inflector::classify($this->command);
if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
if (empty($this->{$task}->path)) {
$path = Inflector::underscore(Inflector::pluralize($this->command));
$this->{$task}->path = $this->params['working'] . DS . $path . DS;
}
if (isset($this->params['connection'])) {
$this->{$task}->connection = $this->params['connection'];
}
foreach ($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;
}
}
if (isset($this->params['plugin'])) {
$this->{$task}->plugin = $this->params['plugin'];
}
if (!is_dir($this->{$task}->path)) {
$this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
$this->_stop();
}
}
}
示例2: main
function main()
{
parent::loadTasks();
$this->out('Import Upload Shell');
$this->hr();
$this->_setAvailableImportFiles();
if (empty($this->args)) {
$imports = $this->_interactive();
} else {
$imports = $this->_determineImportIds(implode(' ', $this->args));
}
if (!empty($imports)) {
foreach ($imports as $import) {
$importUpload = $this->ImportUpload->create($import);
if ($filename = $this->ImportUpload->filePath()) {
$importUpload['ImportUpload']['file_path'] = $filename;
if (!empty($import['ImportDelimiter'])) {
$options = array('delimiter' => $import['ImportDelimiter']['delimiter'], 'excel_reader' => $import['ImportDelimiter']['use_excel_reader'], 'qualifier' => $import['ImportUpload']['text_qualifier']);
}
if ($this->Parser->execute($filename, $options)) {
$this->ImportUpload->saveField('total', $this->Parser->getRowCount());
$this->ImportUpload->saveField('is_importing', 1);
}
die('here');
} else {
}
}
}
}
示例3: main
/**
* The main function, executed automatically when running the shell
*
*/
function main()
{
parent::loadTasks();
$this->out('Build Search Index Shell');
$this->hr();
// Figure out which db config we are using
$this->_setDbConfig();
// Determine the models for the selected db config that have Searchable
$this->_setAvailableModels();
// If no args on command line, run interactively
if (empty($this->args)) {
$modelNames = $this->_interactive();
} else {
// Pass command line args off to validate input
$modelNames = $this->_determineModelnames(implode(' ', $this->args));
}
foreach ($modelNames as $modelName) {
// Confirm rebuild index for this model
$skip = $this->in(__("Are you sure you want to rebuild the search index for {$modelName}, 'y' or 'n' or 'q' to exit", true), null, 'n');
// Quit if they want to
if (strtolower($skip) === 'q') {
$this->out(__("Exit", true));
$this->_stop();
}
// Skip if they want to
if (strtolower($skip) !== 'y') {
$this->out(__("Skipping " . $modelName, true));
continue;
}
// Instantiate the model object
$ModelObj = ClassRegistry::init($modelName);
// Delete the records in the search index for the current model
if (!$ModelObj->deleteSearchIndex(true)) {
$this->err(__('Could not delete search index', true));
$this->_stop();
}
// Find all records
if (method_exists($ModelObj, 'getAllSearchableData')) {
$records = $ModelObj->getAllSearchableData();
} else {
$records = $ModelObj->find('all', array('recursive' => 0));
}
foreach ($records as $record) {
// Set model->data property
$ModelObj->set($record);
// Set the _records property of the Searchable Behavior
$ModelObj->setSearchableRecords(false, true);
// Save the search index record
$ModelObj->saveSearchIndex(true);
// Report progress
$this->out($ModelObj->alias . ' ' . $ModelObj->id . ' ' . $record[$ModelObj->alias][$ModelObj->displayField]);
}
}
$this->hr();
}
示例4: loadTasks
/**
* Override loadTasks() to handle paths
*
* @access public
*/
function loadTasks()
{
parent::loadTasks();
$task = Inflector::classify($this->command);
if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
$path = Inflector::underscore(Inflector::pluralize($this->command));
$this->{$task}->path = $this->params['working'] . DS . $path . DS;
if (!is_dir($this->{$task}->path)) {
$this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
exit;
}
}
}
示例5: loadTasks
function loadTasks()
{
Configure::write('debug', 0);
//設置されているプラグインを取得
$this->installed_plugins = getPlugins();
foreach ($this->installed_plugins as $plugin) {
$taskPath = APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . 'shells' . DS;
$installerPath = APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . "install_{$plugin}.php";
if (file_exists($installerPath)) {
$this->Dispatch->shellPaths[] = $taskPath;
$this->tasks[] = $this->getPluginInstallerTaskName($plugin);
}
}
parent::loadTasks();
}
示例6: loadTasks
/**
* Override loadTasks() to handle paths
*
* @access public
*/
function loadTasks() {
parent::loadTasks();
$task = Inflector::classify($this->command);
if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
if (isset($this->params['connection'])) {
$this->{$task}->connection = $this->params['connection'];
}
foreach($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;
}
}
if (isset($this->params['plugin'])) {
$this->{$task}->plugin = $this->params['plugin'];
}
}
}
示例7: loadTasks
/**
* loadTasks method
*
* @return void
* @access public
*/
function loadTasks()
{
parent::loadTasks();
foreach ($this->Find->settings as $key => $val) {
if (isset($this->settings[$key])) {
$this->Find->settings[$key] =& $this->settings[$key];
}
}
$this->Find->startup();
}