/** * 获取命令行参数,并执行匿名函数 * @param $callable * @param $argv */ static function getVal($callable, $argv) { $argv = getArgs($argv); if (is_callable($callable)) { call_user_func($callable, $argv); } }
function getArg($short, $long, $def = null) { $args = getArgs(); $r = get($args, $short, false); if ($r === false) { if ($long) { $r = get($args, $long, $def); } else { $r = $def; } } return $r; }
<?php session_start(); require 'get_ryan_quotes.class.php'; require 'curl.class.php'; require 'settings.php'; require 'get_args.include.php'; $args = getArgs(); $days_offset = isset($args['days_offset']) ? $args['days_offset'] : 0; $day_to_check = isset($args['days_to_check']) ? $args['days_to_check'] : NULL; $obj = new get_ryan_quotes(); $obj->setDaysOffset($days_offset); $obj->setDaysToCheck($day_to_check); $obj->setDbConnectionInfo($db); $obj->session_id = session_id(); $obj->getFares();
/** * Set a Task’s Progress. Work only inside a worker * * Example (inside a worker): * <code> * require_once "phar://iron_worker.phar"; * $worker = new IronWorker(); # assuming you have iron.json inside a worker * $worker->setCurrentTaskProgress(50, "Task is half-done"); * </code> * @param int $percent An integer, between 0 and 100 inclusive, that describes the completion of the task. * @param string $msg Any message or data describing the completion of the task. Must be a string value, * and the 64KB request limit applies. * @return mixed * @throws RuntimeException */ public function setCurrentTaskProgress($percent, $msg = '') { if (!function_exists('getArgs')) { throw new RuntimeException("Method can be used only inside a worker"); } $args = getArgs(); $task_id = $args['task_id']; return $this->setProgress($task_id, $percent, $msg); }
function getConfig($assoc = true) { $args = getArgs($assoc); return $args['config']; }
function procedures_callreturn($block) { $mutate = $block->firstChild; if ($mutate->nodeName == 'mutation') { $funcName = $mutate->getAttribute('name'); $args = getArgs($block); $i = 0; $argcode = array(); if ($args != NULL) { foreach ($args as $arg) { $argcode[$i] = valueToCode($block, "ARG" . $i); $i++; } return $funcName . "(" . join(", ", $argcode) . ")"; } else { return $funcName . "()"; } } return null; }
<?php //We need to set this in order for the code to execute in a PHP 5.5 environment date_default_timezone_set('UTC'); /** * This is the Yii bootstrap file for running code on IronWorkers * * @author John Eskilsson <*****@*****.**> * @link https://github.com/br0sk/yiiron * @link http://br0sk.blogspot.co.uk/ * @copyright 2013 * @license New BSD License */ //Get all the params $params = getArgs(); //The path from the base folder to the folder of the app, usually called protected $relativeAppPath = $params['payload']->relativeAppPath; //For the Iron Worker we only need the Yiic params, if more data is needed just add it //as parameters to your yiic command $yiicParams = $params['payload']->yiicParams; //This array will keep the data that you add to the config file that is configured in the //Yiiron plugin $configParamsArray = $params['config']; //Update the app path to reflect the path on IronWorkers. This will overwrite anything //that you added in the file locally in your system. $configParamsArray['basePath'] = '/task/app/' . $relativeAppPath; //Check that we are not trying to upload the iron worker when we run as an Iron worker if ($yiicParams[2] == 'uploadIronWorker') { throw new Exception("You cannot run command \"" . $yiicParams[2] . "\" from an Iron Worker. You can only run that command locally!"); } else { echo "Command \"" . $yiicParams[2] . "\" started!\n";
/** * 获取实例化工作对象 * @param $_work * @param $argv */ public function getInit($_work, $argv) { $this->_work = $_work; $this->_cliData = getArgs($argv); }