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


PHP ArrayUtils::hasStringKeys方法代码示例

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


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

示例1: setOptions

 /**
  * @param AssetsOptions $options
  * @throws \RuntimeException
  */
 public function setOptions($options)
 {
     if (!$options instanceof AssetsOptions && !ArrayUtils::hasStringKeys($options)) {
         throw new \RuntimeException("Options must be an array with string keys");
     }
     if (is_array($options)) {
         $options = new AssetsOptions($options);
     }
     //Set the controller resolver
     $controllerLoader = $this->serviceLocator->get("ControllerLoader");
     $controllerLoader->setInvokableClass("AssetsController", "Assets\\AssetsController");
     //Set the route
     $router = $this->serviceLocator->get('Router');
     $route = new Segment($options->getRoute(), array('asset' => '.*'), array('controller' => 'AssetsController', 'action' => 'index'));
     $router->addRoute("assets", $route);
     $filterManager = $this->serviceLocator->get('AssetsFilterManager');
     foreach ($options->getFilters() as $asset => $filters) {
         foreach ($filters as $filter) {
             if (!$filterManager->has($filter)) {
                 throw new \RuntimeException("Filter {$filter} does not exist");
             }
             if (!isset($this->filters[$asset])) {
                 $this->filters[$asset] = array();
             }
             $this->filters[$asset][] = $filterManager->get($filter);
         }
     }
     foreach ($options->getPaths() as $path) {
         $this->getResolver()->addPath($path);
     }
 }
开发者ID:robertdamoc,项目名称:zf2-module-assets,代码行数:35,代码来源:AssetsManager.php

示例2: createViewModelFromArray

 /**
  * Inspect the result, and cast it to a ViewModel if an assoc array is detected
  *
  * @param  MvcEvent $e
  * @return void
  */
 public function createViewModelFromArray(MvcEvent $e)
 {
     $result = $e->getResult();
     if (!ArrayUtils::hasStringKeys($result, true)) {
         return;
     }
     $model = new ViewModel($result);
     $e->setResult($model);
 }
开发者ID:Flesh192,项目名称:magento,代码行数:15,代码来源:CreateViewModelListener.php

示例3: fromArray

 /**
  * Convert an array to an instance of a model class
  *
  * @param array $array
  * @return ZfcBase\Model\ModelAbstract
  */
 public static function fromArray($array)
 {
     if (!ArrayUtils::hasStringKeys($array)) {
         throw new InvalidArgumentException('ModelAbstract::fromArray() expects associative array.');
     }
     $model = new static();
     $model->exchangeArray($array);
     return $model;
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:15,代码来源:ModelAbstract.php

示例4: testEmptyArrayReturnsFalse

 public function testEmptyArrayReturnsFalse()
 {
     $test = array();
     $this->assertFalse(ArrayUtils::hasStringKeys($test, false));
     $this->assertFalse(ArrayUtils::hasIntegerKeys($test, false));
     $this->assertFalse(ArrayUtils::hasNumericKeys($test, false));
     $this->assertFalse(ArrayUtils::isList($test, false));
     $this->assertFalse(ArrayUtils::isHashTable($test, false));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:9,代码来源:ArrayUtilsTest.php

示例5: complete

 /**
  * Complete the dispatch
  *
  * @param  mixed $return
  * @param  MvcEvent $event
  * @return mixed
  */
 protected function complete($return, MvcEvent $event)
 {
     if (!is_object($return)) {
         if (ArrayUtils::hasStringKeys($return)) {
             $return = new ArrayObject($return, ArrayObject::ARRAY_AS_PROPS);
         }
     }
     $event->setResult($return);
     return $return;
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:17,代码来源:DispatchListener.php

示例6: hasHeaderRow

 /**
  * Determines if table will has a header row.
  *
  * A header row can be set explicitly using setHeaderRow() or by passing an
  * associative array for the table rows.
  *
  * @return bool
  */
 public function hasHeaderRow()
 {
     // If no header row is provided, see if we can get headers from row keys.
     if (!isset($this->headerRow)) {
         return count($this->rows) ? ArrayUtils::hasStringKeys($this->rows[0]) : false;
     }
     return true;
 }
开发者ID:andrearruda,项目名称:CaoHtmlTable,代码行数:16,代码来源:Table.php

示例7: dispatch

 /**
  * Dispatch the matched route
  *
  * @param  MvcEvent $e
  * @return mixed
  */
 public function dispatch(MvcEvent $e)
 {
     $locator = $this->getLocator();
     if (!$locator) {
         throw new Exception\MissingLocatorException('Cannot dispatch without a locator');
     }
     $routeMatch = $e->getRouteMatch();
     $controllerName = $routeMatch->getParam('controller', 'not-found');
     $events = $this->events();
     try {
         $controller = $locator->get($controllerName);
     } catch (ClassNotFoundException $exception) {
         $error = clone $e;
         $error->setError(static::ERROR_CONTROLLER_NOT_FOUND)->setController($controllerName)->setParam('exception', $exception);
         $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $error);
         if (count($results)) {
             $return = $results->last();
         } else {
             $return = $error->getParams();
         }
         goto complete;
     }
     if ($controller instanceof LocatorAware) {
         $controller->setLocator($locator);
     }
     if (!$controller instanceof Dispatchable) {
         $error = clone $e;
         $error->setError(static::ERROR_CONTROLLER_INVALID)->setController($controllerName)->setControllerClass(get_class($controller));
         $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $error);
         if (count($results)) {
             $return = $results->last();
         } else {
             $return = $error->getParams();
         }
         goto complete;
     }
     $request = $e->getRequest();
     $response = $this->getResponse();
     if ($controller instanceof InjectApplicationEvent) {
         $controller->setEvent($e);
     }
     try {
         $return = $controller->dispatch($request, $response);
     } catch (\Exception $ex) {
         $error = clone $e;
         $error->setError(static::ERROR_EXCEPTION)->setController($controllerName)->setControllerClass(get_class($controller))->setParam('exception', $ex);
         $results = $events->trigger(MvcEvent::EVENT_DISPATCH_ERROR, $error);
         if (count($results)) {
             $return = $results->last();
         } else {
             $return = $error->getParams();
         }
     }
     complete:
     if (!is_object($return)) {
         if (ArrayUtils::hasStringKeys($return)) {
             $return = new ArrayObject($return, ArrayObject::ARRAY_AS_PROPS);
         }
     }
     $e->setResult($return);
     return $return;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:68,代码来源:Application.php

示例8: canonizeActionResult

 /**
  * Inspect the result, and cast it to a ViewModel
  *
  * @param  MvcEvent $e
  * @return void
  */
 public function canonizeActionResult(MvcEvent $e)
 {
     $result = $e->getResult();
     if ($result instanceof Response) {
         return;
     }
     // MVC controller
     $controller = $e->getTarget();
     // Controller view
     $controllerVew = $controller->plugin('view');
     // Collect captured contents
     if ($this->obStarted) {
         $content = ob_get_clean();
         if ($content) {
             if (null === $result && !$controllerVew->hasViewModel()) {
                 $result = $content;
             } elseif (Pi::service()->hasService('log')) {
                 Pi::service('log')->info('Captured content: ' . $content);
             }
         }
     }
     // Skip scalar result
     if (!$this->type && is_scalar($result) && !is_bool($result)) {
         if ($controllerVew->hasViewModel()) {
             $viewModel = $controllerVew->getViewModel();
         } else {
             $viewModel = new ViewModel();
         }
         $viewModel->setTemplate('__NULL__');
         $viewModel->setVariable($viewModel->captureTo(), $result);
         $e->setResult($viewModel);
         return;
     }
     // ViewModel generated by controller
     $viewModel = null;
     // Cast controller ViewModel
     if ($controllerVew->hasViewModel()) {
         $viewModel = $controllerVew->getViewModel();
         $template = $viewModel->getTemplate();
         // Controller ViewModel is as the main model if if if is specified
         // with template, MvcEvent result is converted to variables of
         // the ViewModel
         if ($viewModel instanceof ViewModel && !$viewModel instanceof JsonModel && !$viewModel instanceof FeedModel && $template && '__NULL__' != $template) {
             $variables = array();
             $options = array();
             if ($result instanceof ViewModel) {
                 $variables = $result->getVariables();
                 $options = $result->getOptions();
             } elseif ($result instanceof FeedDataModel) {
                 $variables = (array) $result;
                 $options = array('feed_type' => $result->getType());
             } elseif (ArrayUtils::hasStringKeys($result, true)) {
                 $variables = array_merge_recursive($variables, $result);
             }
             $viewModel->setVariables($variables);
             $viewModel->setOptions($options);
             $e->setResult($viewModel);
             return;
         }
     }
     // Set type to json if no template is specified
     if (!$this->type && null !== $result) {
         $skip = false;
         if ($result instanceof ViewModel && $result->getTemplate() && $result->getTemplate() != '__NULL__' || $result instanceof JsonModel || $result instanceof FeedModel) {
             $skip = true;
         }
         if (!$skip) {
             $this->type = 'json';
             Pi::service('log')->mute();
         }
     }
     // Cast controller view model to result ViewModel
     switch ($this->type) {
         // For Feed
         case 'feed':
             if ($result instanceof FeedModel) {
                 $model = $result;
             } else {
                 $variables = array();
                 //$options = array();
                 if ($result instanceof ViewModel) {
                     $variables = $result->getVariables();
                     $options = $result->getOptions();
                 } elseif ($result instanceof FeedDataModel) {
                     $variables = (array) $result;
                     $options = array('feed_type' => $result->getType());
                 } else {
                     if ($viewModel) {
                         $variables = $viewModel->getVariables();
                         //$options = $viewModel->getOptions();
                     }
                     if (ArrayUtils::hasStringKeys($result, true)) {
                         $variables = array_merge_recursive((array) $variables, (array) $result);
                     }
//.........这里部分代码省略.........
开发者ID:Andyyang1981,项目名称:pi,代码行数:101,代码来源:ViewStrategyListener.php


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