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


PHP Assert::isNotEmptyArray方法代码示例

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


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

示例1: handleRequest

 /**
  * @return ModelAndView
  **/
 public function handleRequest(HttpRequest $request)
 {
     Assert::isNotEmptyArray($this->innerControllers, 'Add atleast one innerController first');
     $activeController = $this->getActiveController($request);
     $model = $this->mav->getModel();
     if ($activeController) {
         $controllerName = $activeController->getName();
         $activeMav = $activeController->handleRequest($request);
         $model->set(TextUtils::downFirst($controllerName), $activeMav->getModel());
         unset($this->innerControllers[$controllerName]);
     }
     foreach ($this->innerControllers as $controller) {
         $passedRequest = clone $request;
         $passedRequest->{'set' . $controller->getRequestGetter() . 'Var'}('action', null);
         $subMav = $controller->handleRequest($passedRequest);
         $model->set(TextUtils::downFirst($controller->getName()), $subMav->getModel());
     }
     return isset($activeMav) && $activeMav->viewIsRedirect() ? $activeMav : $this->mav;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:22,代码来源:ControllersCollection.php

示例2: multiSend

 public function multiSend()
 {
     Assert::isNotEmptyArray($this->multiRequests);
     $handles = [];
     $mh = curl_multi_init();
     foreach ($this->multiRequests as $alias => $request) {
         $this->multiResponses[$alias] = new CurlHttpResponse();
         $handles[$alias] = $this->makeHandle($request, $this->multiResponses[$alias]);
         if (isset($this->multiThreadOptions[$alias])) {
             foreach ($this->multiThreadOptions[$alias] as $key => $value) {
                 curl_setopt($handles[$alias], $key, $value);
             }
         }
         curl_multi_add_handle($mh, $handles[$alias]);
     }
     $running = null;
     do {
         curl_multi_exec($mh, $running);
     } while ($running > 0);
     foreach ($this->multiResponses as $alias => $response) {
         $this->makeResponse($handles[$alias], $response);
         curl_multi_remove_handle($mh, $handles[$alias]);
         curl_close($handles[$alias]);
     }
     curl_multi_close($mh);
     return true;
 }
开发者ID:avid,项目名称:hesper,代码行数:27,代码来源:CurlHttpClient.php

示例3: fetchCollections

 public function fetchCollections(array $collections, array $list)
 {
     Assert::isNotEmptyArray($list);
     $ids = ArrayUtils::getIdsArray($list);
     $mainId = DBField::create($this->getIdName(), $this->getTable());
     foreach ($collections as $path => $info) {
         $lazy = $info['lazy'];
         $query = OSQL::select()->get($mainId)->from($this->getTable());
         $proto = reset($list)->proto();
         $this->processPath($proto, $path, $query, $this->getTable());
         if ($criteria = $info['criteria']) {
             $query = $criteria->setDao($this)->fillSelectQuery($query);
         }
         $query->andWhere(Expression::in($mainId, $ids));
         $propertyPath = $info['propertyPath'];
         $property = $propertyPath->getFinalProperty();
         $proto = $propertyPath->getFinalProto();
         $dao = $propertyPath->getFinalDao();
         $selfName = $this->getObjectName();
         $self = new $selfName();
         $getter = 'get' . ucfirst($property->getName());
         Assert::isTrue($property->getRelationId() == MetaRelation::ONE_TO_MANY || $property->getRelationId() == MetaRelation::MANY_TO_MANY);
         $table = $dao->getJoinName($property->getColumnName());
         $id = $this->getIdName();
         $collection = [];
         if ($lazy) {
             if ($property->getRelationId() == MetaRelation::MANY_TO_MANY) {
                 $childId = $self->{$getter}()->getChildIdField();
             } else {
                 $childId = $dao->getIdName();
             }
             $alias = 'cid';
             // childId, collectionId, whatever
             $field = DBField::create($childId, $self->{$getter}()->getHelperTable());
             $query->get($field, $alias);
             if (!$property->isRequired()) {
                 $query->andWhere(Expression::notNull($field));
             }
             try {
                 $rows = $dao->getCustomList($query);
                 foreach ($rows as $row) {
                     if (!empty($row[$alias])) {
                         $collection[$row[$id]][] = $row[$alias];
                     }
                 }
             } catch (ObjectNotFoundException $e) {
                 /*_*/
             }
         } else {
             $prefix = $table . '_';
             foreach ($dao->getFields() as $field) {
                 $query->get(DBField::create($field, $table), $prefix . $field);
             }
             if (!$property->isRequired()) {
                 $query->andWhere(Expression::notNull(DBField::create($dao->getIdName(), $table)));
             }
             try {
                 // otherwise we don't know which object
                 // belongs to which collection
                 $rows = $dao->getCustomList($query);
                 foreach ($rows as $row) {
                     $collection[$row[$id]][] = $dao->makeObject($row, $prefix);
                 }
             } catch (ObjectNotFoundException $e) {
                 /*_*/
             }
         }
         $suffix = ucfirst($property->getName());
         $fillMethod = 'fill' . $suffix;
         $getMethod = 'get' . $suffix;
         Assert::isTrue(method_exists(reset($list), $fillMethod), 'can not find filler');
         Assert::isTrue(method_exists(reset($list), $getMethod), 'can not find getter');
         foreach ($list as $object) {
             if (!empty($collection[$object->getId()])) {
                 $object->{$fillMethod}($collection[$object->getId()], $lazy);
             } else {
                 $object->{$getMethod}()->mergeList([]);
             }
         }
     }
     return $list;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:82,代码来源:ProtoDAO.php

示例4: sort

 public function sort()
 {
     Assert::isGreater(count($this->keys), 0);
     Assert::isNotEmptyArray($this->vector);
     usort($this->vector, [$this, "compare"]);
 }
开发者ID:justthefish,项目名称:hesper,代码行数:6,代码来源:SortHelper.php


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