本文整理汇总了PHP中Ouzo\Utilities\Arrays::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::toArray方法的具体用法?PHP Arrays::toArray怎么用?PHP Arrays::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ouzo\Utilities\Arrays
的用法示例。
在下文中一共展示了Arrays::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callFunction
public static function callFunction($functionName, $parameters)
{
$db = self::getInstance();
$bindParams = Arrays::toArray($parameters);
$paramsQueryString = implode(',', array_pad(array(), sizeof($bindParams), '?'));
return Arrays::first($db->query("SELECT {$functionName}({$paramsQueryString})", $parameters)->fetch());
}
示例2: __construct
public function __construct($httpCode, $errors, $headers = array())
{
$this->_httpCode = $httpCode;
$this->_errors = Arrays::toArray($errors);
$this->_headers = $headers;
$firstError = Arrays::first($this->_errors);
parent::__construct($firstError->getMessage(), $firstError->getCode());
}
示例3: showSuccess
function showSuccess(array $notices = array())
{
if (Session::has('messages') || $notices) {
$sessionMessages = Arrays::filterNotBlank(Arrays::toArray(Session::get('messages')));
$notices = array_merge($sessionMessages, $notices);
$noticeView = new View('success_alert');
$noticeView->notices = $notices;
return $noticeView->render();
}
return null;
}
示例4: getKeyAndValueArguments
private function getKeyAndValueArguments($args)
{
if (count($args) == 1 && is_array($args[0])) {
$args = $args[0];
}
if (count($args) < 2) {
throw new InvalidArgumentException('Method needs at least two arguments: key and value');
}
$value = array_pop($args);
$keys = Arrays::toArray($args);
return array($keys, $value);
}
示例5: selectTag
function selectTag($name, array $items = array(), $value, array $attributes = array(), $promptOption = null)
{
$value = Arrays::toArray($value);
$attr = _prepareAttributes($attributes, array('name' => $name));
$optionsString = '';
if ($promptOption) {
$items = array(null => $promptOption) + $items;
}
foreach ($items as $optionValue => $optionName) {
$optionsString .= optionTag($optionValue, $optionName, $value);
}
return '<select ' . $attr . '>' . $optionsString . '</select>';
}
示例6: associateRelationsWithAliases
/**
* @param Relation[] $relations
* @param string|string[]|null $aliases
* @return RelationWithAlias[]
*/
public static function associateRelationsWithAliases(array $relations, $aliases)
{
$aliases = Arrays::toArray($aliases);
if (count($relations) < count($aliases)) {
throw new InvalidArgumentException("More aliases than relations in join");
}
$relationWithAliases = array();
foreach ($relations as $index => $relation) {
$alias = Arrays::getValue($aliases, $index, Arrays::getValue($aliases, $relation->getName()));
$relationWithAliases[] = new RelationWithAlias($relation, $alias);
}
return $relationWithAliases;
}
示例7: revertProperty
public function revertProperty($keys)
{
$keys = Arrays::toArray($keys);
$config =& $this->_config;
$overriddenConfig =& $this->_overriddenConfig;
$overriddenKey = null;
foreach ($keys as $key) {
if (!array_key_exists($key, $overriddenConfig)) {
throw new InvalidArgumentException('Cannot revert. No configuration override for: ' . Objects::toString($keys));
}
$config =& $config[$key];
if (is_array($overriddenConfig[$key])) {
$overriddenConfig =& $overriddenConfig[$key];
} else {
$overriddenKey = $key;
}
}
$config = $overriddenConfig[$overriddenKey];
}
示例8: addRoute
private static function addRoute($method, $uri, $action, $requireAction = true, $options = array(), $isResource = false)
{
$methods = Arrays::toArray($method);
if (self::$isDebug && $requireAction && self::$validate && self::existRouteRule($methods, $uri)) {
$methods = implode(', ', $methods);
throw new InvalidArgumentException('Route rule for method ' . $methods . ' and URI "' . $uri . '" already exists');
}
$elements = explode('#', $action);
$controller = Arrays::first($elements);
$actionToRule = Arrays::getValue($elements, 1);
$routeRule = new RouteRule($method, $uri, $controller, $actionToRule, $requireAction, $options, $isResource);
if ($routeRule->hasRequiredAction()) {
throw new InvalidArgumentException('Route rule ' . $uri . ' required action');
}
self::$routes[] = $routeRule;
foreach ($methods as $method) {
self::$routeKeys[$method . $uri] = true;
}
}
示例9: select
/**
* @param $columns
* @param int $type
* @return ModelQueryBuilder
*/
public function select($columns, $type = PDO::FETCH_NUM)
{
$this->_selectModel = false;
$this->_query->selectColumns = Arrays::toArray($columns);
$this->_query->selectType = $type;
return $this;
}
示例10: types
/**
* @return $this
*/
private function types()
{
$ns = $this->builder->getNs();
$typesElement = $this->createElement('types');
$schemaElement = $this->createElementWithAttributes('xsd:schema', ['targetNamespace' => $ns, 'xmlns' => $ns]);
foreach ($this->builder->getMethods() as $method) {
$typesForParameters = $this->XMLStyle->generateTypes($this->DOMDocument, $method->getParameters(), $this->XMLSoapVersion);
$typesForReturn = $this->XMLStyle->generateTypes($this->DOMDocument, Arrays::toArray($method->getReturn()), $this->XMLSoapVersion);
$types = array_merge($typesForParameters, $typesForReturn);
foreach ($types as $type) {
$schemaElement->appendChild($type);
}
}
$typesElement->appendChild($schemaElement);
$this->definitionsRootNode->appendChild($typesElement);
return $this;
}
示例11: wrapAsNotices
private function wrapAsNotices($messages, $url)
{
$array = Arrays::toArray($messages);
return Arrays::map($array, function ($msg) use($url) {
return new Notice($msg, $url);
});
}
示例12: findBySql
/** Executes a native sql and returns an array of model objects created by passing every result row to the model constructor.
* @param $nativeSql - database specific sql
* @param array $params - bind parameters
* @return Model[]
*/
public static function findBySql($nativeSql, $params = array())
{
$meta = static::metaInstance();
$results = $meta->_modelDefinition->db->query($nativeSql, Arrays::toArray($params))->fetchAll();
return Arrays::map($results, function ($row) use($meta) {
return $meta->newInstance($row);
});
}
示例13: toArrayShouldReturnArrayWithOneElementForEmptyString
/**
* @test
*/
public function toArrayShouldReturnArrayWithOneElementForEmptyString()
{
// when
$result = Arrays::toArray('');
// then
$this->assertEquals(array(''), $result);
}
示例14: __construct
public function __construct($sql, $parameters = array())
{
$this->sql = $sql;
$this->values = $parameters === NULL ? array(null) : Arrays::toArray($parameters);
}
示例15: getControllerNamespace
public static function getControllerNamespace()
{
$controllerPath = Config::getValue('namespace', 'controller');
return $controllerPath ? Arrays::toArray($controllerPath) : array("\\Application\\Controller\\");
}