当前位置: 首页>>代码示例>>PHP>>正文


PHP Arrays::in方法代码示例

本文整理汇总了PHP中Arrays::in方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::in方法的具体用法?PHP Arrays::in怎么用?PHP Arrays::in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arrays的用法示例。


在下文中一共展示了Arrays::in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 public function search($word, $coords, $distance = 5, $limit = 25, $offset = 0)
 {
     $collection = $tmp = $idEtabs = [];
     $nb = $incr = 0;
     $services = rdb('geo', 'service')->select('id')->where(['family', 'LIKE', '%' . $word . '%'])->where(['code', 'LIKE', '%' . $word . '%'], 'OR')->where(['label', 'LIKE', '%' . $word . '%'], 'OR')->exec(true);
     foreach ($services as $service) {
         $sEtabs = $service->pivots(rdb('geo', 'etablissement')->model())->exec();
         foreach ($sEtabs as $sEtab) {
             $idEtabs[] = $sEtab['etablissement_id'];
         }
     }
     $idEtabs = array_unique($idEtabs);
     $db = Model::Location();
     $odm = $db->getOdm();
     $coll = $odm->selectCollection($db->collection);
     $coll->ensureIndex(['value' => '2d', 'object_motor' => 1, 'object_database' => 1, 'object_table' => 1]);
     $filter = ["value" => ['$within' => ['$center' => [[floatval($coords['lng']), floatval($coords['lat'])], floatval($distance / 111.12)]]], 'object_motor' => 'dbredis', 'object_database' => 'geo', 'object_table' => 'etablissement'];
     $results = $coll->find($filter);
     foreach ($results as $result) {
         if (Arrays::in($result['object_id'], $idEtabs)) {
             $etab = rdb('geo', 'etablissement')->find($result['object_id']);
             $distances = distanceKmMiles($coords['lng'], $coords['lat'], $etab->lng, $etab->lat);
             $distance = $distances['km'];
             $item = $etab->assoc();
             $item['distance'] = $distance;
             $collection[] = $item;
         }
     }
     $collection = $this->orderBy($collection, 'distance');
     if ($limit == 0) {
         return $collection;
     } else {
         return array_slice($collection, $offset, $limit);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:35,代码来源:services.php

示例2: can

 private function can()
 {
     $nonLoginPages = array('login', 'password');
     $this->user = session('backend')->getUser();
     if (is_null($this->user) && !Arrays::in($this->action, $nonLoginPages)) {
         $this->_url->redirect('login');
     } else {
         if (!is_null($this->user)) {
             $this->view->isLogged = true;
         }
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:12,代码来源:staticController.php

示例3: __callStatic

 public static function __callStatic($method, $args)
 {
     $auth = ['GET', 'POST', 'COOKIE', 'SESSION', 'SERVER', 'REQUEST', 'GLOBALS'];
     $method = Inflector::upper($method);
     if (Arrays::in($method, $auth) && count($args) > 0) {
         $default = isset($args[1]) ? $args[1] : null;
         return isAke(self::tab($method), Arrays::first($args), $default);
     } elseif (Arrays::in($method, $auth) && count($args) == 0) {
         return self::tab($method);
     } else {
         throw new Exception("Wrong parameters.");
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Input.php

示例4: execute

 public static function execute($module, $controller, $action, $args = [])
 {
     $dirModule = APPLICATION_PATH . DS . 'modules' . DS . SITE_NAME . DS . Inflector::lower($module);
     if (!is_dir($dirModule)) {
         throw new Exception("The directory '{$dirModule}' does not exist.");
     }
     $dirController = $dirModule . DS . 'controllers';
     if (!is_dir($dirController)) {
         throw new Exception("The directory '{$dirController}' does not exist.");
     }
     $controllerFile = $dirController . DS . Inflector::lower($controller) . 'Controller.php';
     if (!File::exists($controllerFile)) {
         throw new Exception("The file '{$controllerFile}' does not exist.");
     }
     require_once $controllerFile;
     $oldRoute = container()->getRoute();
     container()->setRoute(with(new Container())->setModule($module)->setController($controller)->setAction($action));
     $controllerClass = 'Thin\\' . Inflector::lower($controller) . 'Controller';
     $controllerInstance = new $controllerClass();
     $actions = get_class_methods($controllerClass);
     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($actionName, $actions)) {
         throw new Exception("The action '{$actionName}' does not exist in {$controllerFile}.");
     }
     if (Arrays::in('init', $actions)) {
         $controllerInstance->init();
     }
     if (Arrays::in('preDispatch', $actions)) {
         $controllerInstance->preDispatch();
     }
     $res = call_user_func_array([$controllerInstance, $actionName], $args);
     if (Arrays::in('postDispatch', $actions)) {
         $controllerInstance->preDispatch();
     }
     container()->setRoute($oldRoute);
     return $res;
 }
开发者ID:schpill,项目名称:thin,代码行数:49,代码来源:Hmvc.php

示例5: factory

 public function factory()
 {
     if (File::exists($this->file)) {
         require_once $this->file;
         $instance = new $this->class();
         $methods = get_class_methods($this->class);
         $tab = explode('\\', get_class($instance));
         $item = Inflector::lower(Arrays::last($tab));
         if (Arrays::in('init', $methods)) {
             $instance->init();
         }
         $this->app->bindShared($this->type . '.' . $item, function ($app) use($instance) {
             return $instance;
         });
         return $this;
     } else {
         throw new Exception("The file '{$file}' does not exist.");
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:19,代码来源:Provider.php

示例6: required

 /**
  * Require specified ENV vars to be present, or throw Exception.
  * You can also pass through an set of allowed values for the environment variable.
  *
  * @throws \RuntimeException
  * @param  mixed             $environmentVariables the name of the environment variable or an array of names
  * @param  string[]          $allowedValues
  * @return true              (or throws exception on error)
  */
 public static function required($environmentVariables, array $allowedValues = array())
 {
     $environmentVariables = (array) $environmentVariables;
     $missingEnvironmentVariables = [];
     foreach ($environmentVariables as $environmentVariable) {
         $value = static::findEnvironmentVariable($environmentVariable);
         if (is_null($value)) {
             $missingEnvironmentVariables[] = $environmentVariable;
         } elseif ($allowedValues) {
             if (!Arrays::in($value, $allowedValues)) {
                 // may differentiate in the future, but for now this does the job
                 $missingEnvironmentVariables[] = $environmentVariable;
             }
         }
     }
     if ($missingEnvironmentVariables) {
         throw new \RuntimeException(sprintf("Required environment variable missing, or value not allowed: '%s'", implode("', '", $missingEnvironmentVariables)));
     }
     return true;
 }
开发者ID:schpill,项目名称:thin,代码行数:29,代码来源:Env.php

示例7: sanitize

 private function sanitize($_)
 {
     if (!is_string($_)) {
         return false;
     }
     if (empty($_)) {
         return false;
     }
     $stop = strlen($_);
     $_ = str_replace('/url?q=', '', Inflector::lower($_));
     for ($i = 0; $i < $stop; $i++) {
         if (Arrays::in($_[$i], array('&amp;', '"', '&', "'"))) {
             $stop = $i;
             $i = strlen($_);
         }
     }
     $url = '';
     for ($j = 0; $j < $stop; $j++) {
         $url .= $_[$j];
     }
     return rawurldecode($url);
 }
开发者ID:schpill,项目名称:thin,代码行数:22,代码来源:Googlesearch.php

示例8: getCategories

 private function getCategories($articles)
 {
     $collection = $tuples = [];
     foreach ($articles as $article) {
         $item_id = isAke($article, 'item_id', 0);
         if (0 < $item_id) {
             $family = repo('segment')->getFamilyfromItem($item_id);
             $cat = isset($family[1]) ? $family[1] : false;
             if (false !== $cat) {
                 $item = [];
                 $item['id'] = $cat['id'];
                 $item['name'] = $cat['name'];
                 $item['icon'] = $cat['icon'];
                 if (!Arrays::in($cat['id'], $tuples)) {
                     array_push($collection, $item);
                     array_push($tuples, $cat['id']);
                 }
             }
         } else {
             $item = [];
             $item['id'] = 0;
             $item['name'] = 'autre';
             $item['icon'] = 'fa fa-cubes';
             if (!Arrays::in('o', $tuples)) {
                 array_push($collection, $item);
                 array_push($tuples, 'o');
             }
         }
     }
     return $collection;
 }
开发者ID:schpill,项目名称:standalone,代码行数:31,代码来源:bourse.php

示例9: query

 public function query($condition)
 {
     list($field, $op, $value) = explode(' ', $condition, 3);
     $collection = array();
     $attribute = $this->dba->where('name = ' . $field)->first();
     $results = $this->dbr->where('attribute = ' . $attribute->getId())->where('entity_name = ' . $this->entity)->where('value ' . $op . ' ' . $value)->fetch();
     foreach ($results as $result) {
         if (!Arrays::in($result->getEntity(), $collection)) {
             array_push($collection, $result->getEntity());
         }
     }
     return $collection;
 }
开发者ID:schpill,项目名称:thin,代码行数:13,代码来源:Attributes.php

示例10: run

 private static function run(Container $route)
 {
     container()->setRoute($route);
     $is404 = true;
     $module = !isset($route->module) ? 'default' : $route->module;
     $controller = $route->controller;
     $action = $route->action;
     $render = !isset($route->render) ? $action : $route->render;
     $stats = !isset($route->stats) ? true : $route->stats;
     if ($action instanceof \Closure) {
         return call_user_func_array($action, [$route]);
     }
     if (!empty($module) && !empty($controller) && !empty($action)) {
         if (fnmatch('*-*', $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';
         $controllersDir = APPLICATION_PATH . DS . 'modules' . DS . strtolower($module) . DS . 'controllers';
         $viewsDir = APPLICATION_PATH . DS . 'modules' . DS . strtolower($module) . DS . 'views';
         $controllerFile = $controllersDir . DS . strtolower($controller) . 'Controller.php';
         $tplFile = $viewsDir . DS . Inflector::lower($controller) . DS . Inflector::lower($render) . '.phtml';
         if (File::exists($controllerFile)) {
             require_once $controllerFile;
             $controllerClass = 'Thin\\' . Inflector::lower($controller) . 'Controller';
             $controllerInstance = new $controllerClass();
             $actions = get_class_methods($controllerClass);
             if (Arrays::in($actionName, $actions)) {
                 $is404 = false;
                 $keyEvent = Inflector::lower($module) . '.' . Inflector::lower($controller) . '.' . $action;
                 if (File::exists($tplFile)) {
                     $view = new View($tplFile);
                     $controllerInstance->view = $view;
                 }
                 if (Arrays::in('boot', $actions)) {
                     $keyEv = $keyEvent . '.init';
                     Event::run($keyEv);
                     $controllerInstance->boot();
                 }
                 if (Arrays::in('preDispatch', $actions)) {
                     $keyEv = $keyEvent . '.before';
                     Event::run($keyEv);
                     $controllerInstance->preDispatch();
                 }
                 $controllerInstance->{$actionName}();
                 if (isset($controllerInstance->view)) {
                     $controllerInstance->view->render();
                 }
                 if (Arrays::in('postDispatch', $actions)) {
                     $keyEv = $keyEvent . '.after';
                     Event::run($keyEv);
                     $controllerInstance->postDispatch();
                 }
                 if (Arrays::in('exit', $actions)) {
                     $keyEv = $keyEvent . '.done';
                     Event::run($keyEv);
                     $controllerInstance->exit();
                 }
                 if (isset($controllerInstance->view)) {
                     if (true === $stats) {
                         echo $controllerInstance->view->showStats();
                     }
                 }
             }
         }
     }
     if (true === $is404) {
         return static::run(static::route(['controller' => 'static', 'action' => 'is404']));
     } else {
         exit;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:80,代码来源:Mvc.php

示例11: getPics

 private function getPics()
 {
     $seg = $this->tag('<div id="links">', '</div>', $this->seg);
     $tab = explode('<a href=', $seg);
     $picIds = array();
     if (!empty($seg)) {
         for ($i = 1; $i < count($tab); $i++) {
             $img = $this->tag('"', '"', trim($tab[$i]));
             $picId = $this->tag('-big-', '.', $img);
             if (!Arrays::in($picId, $picIds)) {
                 array_push($picIds, $picId);
             }
         }
     }
     $this->property['pics'] = implode(',', $picIds);
     return $this;
 }
开发者ID:schpill,项目名称:thin,代码行数:17,代码来源:Duproprio.php

示例12: dispatchBundle

 public static function dispatchBundle(Container $route)
 {
     $bundle = $route->getBundle();
     $controller = $route->getController();
     $action = $route->getAction();
     $path = realpath(APPLICATION_PATH . '/../');
     $bundle = ucfirst(Inflector::lower($bundle));
     $viewsDir = $path . DS . 'bundles' . DS . $bundle . DS . 'views';
     $controllersDir = $path . DS . 'bundles' . DS . $bundle . DS . 'controllers';
     $tpl = $viewsDir . DS . Inflector::lower($controller) . ucfirst(Inflector::lower($action)) . '.phtml';
     $controllerFile = $controllersDir . DS . Inflector::lower($controller) . '.php';
     $file = $path . DS . 'bundles' . DS . $bundle . DS . $bundle . '.php';
     if (File::exists($file)) {
         $getNamespaceAndClassNameFromCode = getNamespaceAndClassNameFromCode(fgc($file));
         list($namespace, $class) = $getNamespaceAndClassNameFromCode;
         if (File::exists($controllerFile)) {
             if (File::exists($tpl)) {
                 $view = new View($tpl);
                 container()->setView($view);
             }
             require_once $controllerFile;
             $controllerClass = $namespace . '\\' . Inflector::lower($controller) . 'Controller';
             $controller = new $controllerClass();
             if (File::exists($tpl)) {
                 $controller->view = $view;
             }
             container()->setController($controller);
             $actions = get_class_methods($controllerClass);
             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();
             }
             if (Arrays::in('preDispatch', $actions)) {
                 $controller->preDispatch();
             }
             if (!Arrays::in($actionName, $actions)) {
                 throw new Exception("The action '{$actionName}' does not exist.");
             }
             $controller->{$actionName}();
             if (File::exists($tpl)) {
                 $controller->view->render();
             }
             /* stats */
             if (File::exists($tpl) && null === container()->getNoShowStats() && null === $route->getNoShowStats()) {
                 echo View::showStats();
             }
             if (Arrays::in('postDispatch', $actions)) {
                 $controller->preDispatch();
             }
             if (Arrays::in('exit', $actions)) {
                 $controller->exit();
             }
         } else {
             context()->is404();
         }
     } else {
         context()->is404();
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:72,代码来源:Route.php

示例13: validateLineBreak

 public function validateLineBreak()
 {
     $lineBreak = $this->getLineBreak();
     if (Arrays::in($lineBreak, array("\r\n", "\n"))) {
         return $lineBreak;
     }
     throw new Exception("Invalid line break. Please use unix \\n or win \\r\\n line breaks.");
 }
开发者ID:schpill,项目名称:thin,代码行数:8,代码来源:Csv.php

示例14: unique

 /**
  * Determine if a key and message combination already exists.
  *
  * @param  string  $key
  * @param  string  $message
  * @return bool
  */
 protected function unique($key, $message)
 {
     return !isset($this->messages[$key]) || !Arrays::in($message, $this->messages[$key]);
 }
开发者ID:schpill,项目名称:thin,代码行数:11,代码来源:Messages.php

示例15: hasRowId

 /**
  * Check if a rowid exists in the current cart instance
  *
  * @param  string  $id  Unique ID of the item
  * @return boolean
  */
 protected function hasRowId($rowId)
 {
     $cart = $this->getContent();
     $rows = $cart->_fields;
     return Arrays::in($rowId, $rows);
 }
开发者ID:schpill,项目名称:thin,代码行数:12,代码来源:Cart.php


注:本文中的Arrays::in方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。