本文整理汇总了PHP中Thin\Arrays::last方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::last方法的具体用法?PHP Arrays::last怎么用?PHP Arrays::last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\Arrays
的用法示例。
在下文中一共展示了Arrays::last方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (fnmatch('*cli*', php_sapi_name())) {
$dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
if (is_dir($dir)) {
Timer::start();
Cli::show("Start of execution", 'COMMENT');
$files = glob($dir . DS . '*.php');
foreach ($files as $file) {
require_once $file;
$object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
$class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
$instance = lib('app')->make($class);
$methods = get_class_methods($instance);
Cli::show("Start schedule '{$object}'", 'COMMENT');
foreach ($methods as $method) {
$when = $this->getWhen($instance, $method);
$isDue = $this->isDue($object, $method, $when);
if (true === $isDue) {
Cli::show("Execution of {$object}->{$method}", 'INFO');
$instance->{$method}();
} else {
Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
}
}
}
Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
Cli::show("end of execution", 'COMMENT');
}
}
}
示例2: beginTransaction
public function beginTransaction()
{
$last = Arrays::last(explode(DS, $this->dir));
$target = str_replace(DS . $last, DS . 'copy.' . $last, $this->dir);
File::cpdir($this->dir, $target);
$this->dir = $target;
return $this;
}
示例3: all
public function all($dir)
{
$path = $this->path . DS . str_replace('.', DS, $dir);
$files = glob($path . DS . '*.php');
$collection = [];
foreach ($files as $file) {
$content = (include $file);
if (!Arrays::isAssoc($content)) {
$content = current($content);
}
$id = (int) str_replace('.php', '', Arrays::last(explode(DS, $file)));
$collection[$id] = $content;
}
return $collection;
}
示例4: __construct
public function __construct()
{
$class = get_called_class();
if (strstr($class, '\\')) {
$class = Arrays::last(explode('\\', $class));
$class = str_replace('Model_', '', $class);
}
if (fnmatch('*_*', $class)) {
list($database, $table) = explode('_', $class, 2);
} else {
$database = SITE_NAME;
$table = $class;
}
self::$db = Db::instance($database, $table);
$this->model = self::$db->model(func_get_args());
}
示例5: run
public static function run()
{
Request::$route = $route = Utils::get('appDispatch');
container()->setRoute($route);
$render = $route->getRender();
$tplDir = $route->getTemplateDir();
$module = $route->getModule();
$controller = $route->getController();
$action = $route->getAction();
$alert = $route->getAlert();
$page = container()->getPage();
$isCms = !empty($page);
if (!empty($render)) {
$tplMotor = $route->getTemplateMotor();
$tplDir = empty($tplDir) ? APPLICATION_PATH . DS . SITE_NAME . DS . 'app' . DS . 'views' : $tplDir;
$tpl = $tplDir . DS . $render . '.phtml';
if (File::exists($tpl)) {
if ('Twig' == $tplMotor) {
if (!class_exists('Twig_Autoloader')) {
require_once 'Twig/Autoloader.php';
}
$tab = explode(DS, $tpl);
$file = Arrays::last($tab);
$path = repl(DS . $file, '', $tpl);
$loader = new \Twig_Loader_Filesystem($path);
$view = new \Twig_Environment($loader, array('cache' => CACHE_PATH, 'debug' => false, 'charset' => 'utf-8', 'strict_variables' => false));
container()->setView($view);
if ($action instanceof Closure) {
$action($view);
}
$params = null === container()->getViewParams() ? array() : container()->getViewParams();
echo $view->render($file, $params);
/* stats */
if (null === container()->getNoShowStats() && null === $route->getNoShowStats()) {
echo View::showStats();
}
} else {
$view = new View($tpl);
container()->setView($view);
if ($action instanceof Closure) {
$action($view);
}
$view->render();
/* stats */
if (null === container()->getNoShowStats() && null === $route->getNoShowStats()) {
echo View::showStats();
}
}
return;
}
}
$module = Inflector::lower($module);
$controller = Inflector::lower($controller);
$action = Inflector::lower($action);
if (true === container()->getMultiSite()) {
$moduleDir = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module;
} else {
$moduleDir = APPLICATION_PATH . DS . 'modules' . DS . $module;
}
if (!is_dir($moduleDir)) {
throw new Exception("The module '{$module}' does not exist.");
}
$controllerDir = $moduleDir . DS . 'controllers';
if (!is_dir($controllerDir)) {
throw new Exception("The controller '{$controller}' does not exist.");
}
$controllerFile = $controllerDir . DS . $controller . 'Controller.php';
if (!File::exists($controllerFile)) {
throw new Exception("The controller '{$controllerFile}' does not exist.");
}
require_once $controllerFile;
$controllerClass = 'Thin\\' . $controller . 'Controller';
$controller = new $controllerClass();
$controller->view = new View($route->getView());
if (null !== $alert) {
$controller->view->alert($alert);
}
container()->setController($controller);
$actions = get_class_methods($controllerClass);
if (true === $isCms) {
if (!Arrays::inArray($action, $actions)) {
$action = 'page';
}
}
container()->setAction($action);
if (strstr($action, '-')) {
$words = explode('-', $action);
$newAction = '';
for ($i = 0; $i < count($words); $i++) {
$word = trim($words[$i]);
if ($i > 0) {
$word = ucfirst($word);
}
$newAction .= $word;
}
$action = $newAction;
}
$actionName = $action . 'Action';
if (Arrays::in('init', $actions)) {
$controller->init();
//.........这里部分代码省略.........
示例6: hgetall
public function hgetall($h)
{
$dirH = self::$dir . DS . $h;
if (!is_dir($dirH)) {
umask(00);
mkdir($dirH, 0777);
}
$keys = glob($dirH . DS . '*', GLOB_NOSORT);
$collection = [];
if (count($keys)) {
foreach ($keys as $cache) {
$k = str_replace('.cache', '', Arrays::last(explode(DS, $cache)));
$collection[$k] = unserialize(File::read($cache));
}
}
return $collection;
}
示例7: getPaypalPaymentInfos
public static function getPaypalPaymentInfos($paypalUrl)
{
$url = Arrays::first($paypalUrl);
$execute = Arrays::last($paypalUrl);
$tab = parse_url($url);
parse_str($tab['query'], $infos);
extract($infos);
/* turl + oken + execute */
return array('url' => $url, 'token' => $token, 'execute' => $execute);
}
示例8: getTime
private function getTime()
{
$time = microtime();
$time = explode(' ', $time, 2);
return Arrays::last($time) + Arrays::first($time);
}
示例9: upload
private function upload($field)
{
$bucket = container()->bucket();
if (Arrays::exists($field, $_FILES)) {
$fileupload = $_FILES[$field]['tmp_name'];
$fileuploadName = $_FILES[$field]['name'];
if (strlen($fileuploadName)) {
$tab = explode(".", $fileuploadName);
$data = fgc($fileupload);
if (!strlen($data)) {
return null;
}
$ext = Inflector::lower(Arrays::last($tab));
$res = $bucket->data($data, $ext);
return $res;
}
}
return null;
}
示例10: last
public function last(array $results)
{
if (count($results)) {
$row = Arrays::last($results);
if (is_object($row)) {
return $row;
}
}
return null;
}
示例11: last
public function last($results = array())
{
$res = count($results) ? $results : $this->results;
$row = null;
if (count($res)) {
$row = $this->row(Arrays::last($res));
}
$this->reset();
return $row;
}
示例12: extractId
private function extractId($file)
{
return str_replace('.row', '', Arrays::last(explode(DS, $file)));
}
示例13: localFile
private function localFile($key)
{
$tab = explode('::', $key);
$id = Arrays::last($tab);
return $this->model->dir . DS . $id . '.row';
}
示例14: __call
//.........这里部分代码省略.........
$this->{$var} = array();
}
if (!Arrays::is($this->{$var})) {
$this->{$var} = array();
}
array_push($this->{$var}, $value);
return $this;
} elseif (substr($func, 0, 6) == 'remove') {
$uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 6)));
$var = Inflector::lower($uncamelizeMethod) . 's';
$value = Arrays::first($argv);
if (isset($this->{$var})) {
if (Arrays::is($this->{$var})) {
if (count($this->{$var})) {
$remove = false;
foreach ($this->{$var} as $key => $tmpValue) {
$comp = md5(serialize($value)) == md5(serialize($tmpValue));
if (true === $comp) {
$remove = true;
break;
}
}
if (true === $remove) {
unset($this->{$var}[$key]);
}
}
}
}
return $this;
}
if (Arrays::in($func, $this->_fields)) {
if ($this->{$func} instanceof \Closure) {
return call_user_func_array($this->{$func}, $argv);
}
}
if (Arrays::exists($func, $this->_closures)) {
if ($this->_closures[$func] instanceof \Closure) {
return call_user_func_array($this->_closures[$func], $argv);
}
}
if (isset($this->_token)) {
$id = sha1($func . $this->_token);
if (Arrays::is($this->values)) {
if (Arrays::exists($id, $this->values)) {
return call_user_func_array($this->values[$id], $argv);
}
}
}
if (true === hasEvent($func)) {
array_push($argv, $this);
return fire($func, $argv);
}
if (!is_callable($func) || substr($func, 0, 6) !== 'array_' || substr($func, 0, 3) !== 'set' || substr($func, 0, 3) !== 'get' || substr($func, 0, 3) !== 'has' || substr($func, 0, 3) !== 'add' || substr($func, 0, 6) !== 'remove') {
$callable = strrev(repl('_', '', $func));
if (!is_callable($callable)) {
if (method_exists($this, $callable)) {
return call_user_func_array(array($this, $callable), $argv);
}
} else {
return call_user_func_array($callable, $argv);
}
if (isset($this->thin_litedb)) {
$closure = isAke($this->thin_litedb->closures, $func);
if (!empty($closure) && $closure instanceof \Closure) {
return $closure($this);
}
}
if (isset($this->db_instance)) {
return $this->db_instance->{$func}($this, $var, $value);
call_user_func_array(array($this->db_instance, $func), array_merge(array($this), $argv));
}
if (false !== $orm) {
$db = call_user_func_array($orm, array());
$fields = array_keys($db->map['fields']);
if (Arrays::in($func, $fields)) {
if (!count($argv)) {
return $this->{$func};
} else {
$setter = setter($func);
$this->{$setter}(Arrays::first($argv));
return $this;
}
}
$tab = str_split($func);
$many = false;
if (Arrays::last($tab) == 's') {
array_pop($tab);
$table = implode('', $tab);
$many = true;
} else {
$table = $func;
}
$object = count($argv) == 1 ? Arrays::first($argv) : true;
$model = model($table);
return true === $many ? $model->where($db->table . '_id = ' . $this->id())->exec($object) : $model->where($db->table . '_id = ' . $this->id())->first($object);
}
return null;
}
return call_user_func_array($func, array_merge(array($this->getArrayCopy()), $argv));
}
示例15: extension
private function extension($file)
{
return strtolower(Arrays::last(explode('.', $file)));
}