當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。