本文整理汇总了PHP中Thin\Arrays::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::exists方法的具体用法?PHP Arrays::exists怎么用?PHP Arrays::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\Arrays
的用法示例。
在下文中一共展示了Arrays::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get an attribute from the container.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
if (Arrays::exists($key, $this->attributes)) {
return $this->attributes[$key];
}
return value($default);
}
示例2: __construct
/**
* Constructor
*
* @param array $config
*/
public function __construct(array $config = [])
{
// Populate Keyring
Keyring::setAppKey($config['AK']);
// Application Key
Keyring::setAppSecret($config['AS']);
// Application Secret
Keyring::setConsumerKey($config['CK']);
// Consumer Key
// Backward compatibility
if (Arrays::exists('RG', $config)) {
Keyring::setAppUrlRegion($config['RG']);
// Region
} else {
Keyring::setAppUrlRegion("FR");
}
if (Arrays::exists('protocol', $config)) {
Keyring::setAppHost($config['protocol']);
// protocol
} else {
Keyring::setAppHost(static::$zeliftApiProtocol);
}
if (Arrays::exists('host', $config)) {
Keyring::setAppProtocol($config['host']);
// host
} else {
Keyring::setAppProtocol(static::$zeliftApiHost);
}
}
示例3: __get
/**
* Getter
* @param mixed $key
* @return mixed
*/
public function __get($key)
{
if (Arrays::exists($key, $this->data)) {
return $this->data[$key];
} else {
return false;
}
}
示例4: get
/**
* Get an Instantiated ReflectionClass.
*
* @param string $class Optional name of a class
* @return mixed null or a ReflectionClass instance
* @throws Exception if class was not found
*/
public function get($class = null)
{
$class = $this->getClass($class);
if (Arrays::exists($class, $this->reflections)) {
return $this->reflections[$class];
}
throw new Exception("Class not found: {$class}");
}
示例5: remove
public function remove($id)
{
if (!Arrays::exists($id, $this->services)) {
throw new InvalidArgumentException(sprintf('Service "%s" is not defined.', $id));
}
list($prefix, $sid) = $this->getPrefixAndSid($id);
if ($prefix) {
unset($this->prefixed[$prefix][$sid]);
}
unset($this->services[$id]);
}
示例6: __construct
public function __construct(array $model)
{
$this->_model = $model;
if (Arrays::is($model)) {
if (Arrays::isAssoc($model)) {
$this->_settings = isAke($model, 'settings');
if (empty($this->_settings)) {
throw new Exception("Settings do not exist.");
}
if (Arrays::exists('entity', $this->_settings)) {
$this->_entity = $this->_settings['entity'];
} else {
throw new Exception('The model is misconfigured. Entity missing.');
}
if (Arrays::exists('table', $this->_settings)) {
$this->_table = $this->_settings['table'];
} else {
throw new Exception('The model is misconfigured. Table missing.');
}
$configs = container()->getConfig()->getDb();
$config = isAke($configs, $this->_entity);
if (empty($config)) {
throw new Exception("Database connection settings do not exist.");
}
$adapter = $config->getAdapter();
$username = $config->getUsername();
$password = $config->getPassword();
$dbName = $config->getDatabase();
$host = $config->getHost();
$dsn = "{$adapter}:dbname={$dbName};host={$host}";
$this->_keyConnexion = sha1(serialize(array($dsn, $username, $password)));
$dbs = container()->getArConnexions();
if (empty($all)) {
$dbs = array();
}
$db = $dbs[$this->_keyConnexion] = new PDO($dsn, $username, $password);
container()->setArConnexions($dbs);
$this->_relationships = isAke($this->_settings, 'relationships');
$this->_fields = isAke($this->_settings, 'fields');
if (empty($this->_fields)) {
$this->map();
}
} else {
throw new Exception('The model is misconfigured.');
}
} else {
throw new Exception('The model is misconfigured.');
}
}
示例7: search
/**
* Search
*
* @return array
* @param array|string $query
* @throws \ElasticSearch\Exception
*/
public function search($query)
{
if (Arrays::is($query)) {
if (Arrays::exists("query", $query)) {
$dsl = new Stringify($query);
$q = (string) $dsl;
$url = $this->buildUrl(array($this->type, "_search?q=" . $q));
$result = json_decode(redis()->get($url), true);
return $result;
}
throw new \ElasticSearch\Exception("Redis protocol doesn t support the full DSL, only query");
} elseif (is_string($query)) {
/**
* String based search means http query string search
*/
$url = $this->buildUrl(array($this->type, '_search?q=' . $query));
$result = json_decode(redis()->get($url), true);
return $result;
}
}
示例8: configs
public static function configs($entity, $key, $value = null, $cb = null)
{
if (!strlen($entity)) {
throw new Exception("An entity must be provided to use this method.");
}
if (!Arrays::exists($entity, static::$configs)) {
self::$configs[$entity] = array();
}
if (empty($value)) {
if (!strlen($key)) {
throw new Exception("A key must be provided to use this method.");
}
return isAke(self::$configs[$entity], $key, null);
}
if (!strlen($key)) {
throw new Exception("A key must be provided to use this method.");
}
$reverse = strrev($key);
$last = $reverse[0];
if ('s' == $last) {
self::$configs[$entity][$key] = $value;
} else {
if (!Arrays::exists($key . 's', self::$configs[$entity])) {
self::$configs[$entity][$key . 's'] = array();
}
array_push(self::$configs[$entity][$key . 's'], $value);
}
return !is_callable($cb) ? true : $cb();
}
示例9: getDependencies
/**
* Resolve all of the dependencies from the ReflectionParameters.
*
* @param array $parameters
* @param array $primitives
* @return array
*/
protected function getDependencies($parameters, array $primitives = array())
{
$dependencies = array();
foreach ($parameters as $parameter) {
$dependency = $parameter->getClass();
// If the class is null, it means the dependency is a string or some other
// primitive type which we can not resolve since it is not a class and
// we will just bomb out with an error since we have no-where to go.
if (Arrays::exists($parameter->name, $primitives)) {
$dependencies[] = $primitives[$parameter->name];
} elseif (is_null($dependency)) {
$dependencies[] = $this->resolveNonClass($parameter);
} else {
$dependencies[] = $this->resolveClass($parameter);
}
}
return (array) $dependencies;
}
示例10: saveLite
public function saveLite($type)
{
$table = $type . 's';
$fields = Arrays::exists($type, Data::$_fields) ? Data::$_fields[$type] : [];
$settings = Arrays::exists($type, Data::$_settings) ? Data::$_settings[$type] : [];
if (count($fields) && count($settings)) {
$dbType = Arrays::exists('db', $settings) ? $settings['db'] : null;
$checkId = Arrays::exists('checkId', $settings) ? $settings['checkId'] : 'id';
if (!empty($dbType)) {
$data = $this->toArray();
$fields['id'] = [];
$fields['date_create'] = [];
$id = Arrays::exists('id', $data) ? $data['id'] : Data::getKeyLite($type);
$date_create = Arrays::exists('date_create', $data) ? $data['date_create'] : time();
$this->id = $data['id'] = $id;
$this->date_create = $data['date_create'] = $date_create;
$fields = array_keys($fields);
$db = Data::$dbType($type);
$q = "SELECT {$checkId} FROM {$table} WHERE {$checkId} = '" . $data[$checkId] . "'";
$res = $db->query($q);
if (false === $res->fetchArray()) {
$values = [];
foreach ($fields as $field) {
$values[] = "'" . SQLite3::escapeString($data[$field]) . "'";
}
$values = implode(', ', $values);
$insert = "INSERT INTO {$table}\n (" . implode(', ', $fields) . ")\n VALUES ({$values})";
$db->exec($insert);
} else {
$update = "UPDATE {$table} SET ";
foreach ($fields as $field) {
if ($field != $checkId) {
$update .= "{$field} = '" . SQLite3::escapeString($data[$field]) . "', ";
}
}
$update = substr($update, 0, -2);
$update .= " WHERE {$checkId} = '" . $data[$checkId] . "'";
$db->exec($update);
}
}
}
return $this;
}
示例11: option
function option()
{
$options = null !== container()->getThinOptions() ? container()->getThinOptions() : array();
$args = func_get_args();
if (func_num_args() > 0) {
$name = array_shift($args);
if (is_null($name)) {
$options = array();
return $options;
}
if (Arrays::is($name)) {
$options = array_merge($options, $name);
container()->setThinOptions($options);
}
$nargs = count($args);
if ($nargs > 0) {
$value = $nargs > 1 ? $args : Arrays::first($args);
$options[$name] = value($value);
}
return Arrays::exists($name, $options) ? $options[$name] : null;
} else {
container()->setThinOptions(array());
}
return container()->getThinOptions();
}
示例12: upload
public function upload($field)
{
$bucket = new Bucket(SITE_NAME, 'http://zelift.com/bucket');
if (Arrays::exists($field, $_FILES)) {
$fileupload = $_FILES[$field]['tmp_name'];
$fileuploadName = $_FILES[$field]['name'];
if (strlen($fileuploadName)) {
$tab = explode(".", $fileuploadName);
$data = File::read($fileupload);
if (!strlen($data)) {
return null;
}
$ext = strtolower(end($tab));
$res = $bucket->data($data, $ext);
return $res;
}
}
return false;
}
示例13: transformDSLSortToString
/**
* Transform search parameters to string
*
* @return string
* @param mixed $dslSort
*/
protected function transformDSLSortToString($dslSort)
{
$string = "";
if (Arrays::is($dslSort)) {
foreach ($dslSort as $sort) {
if (Arrays::is($sort)) {
$field = key($sort);
$info = Arrays::first($sort);
} else {
$field = $sort;
}
$string .= "&sort=" . $field;
if (isset($info)) {
if (is_string($info) && $info == "desc") {
$string .= ":reverse";
} elseif (Arrays::is($info) && Arrays::exists("reverse", $info) && $info['reverse']) {
$string .= ":reverse";
}
}
}
}
return $string;
}
示例14: row
public static function row($type, array $data, $extends = array())
{
if (Arrays::isAssoc($data)) {
$obj = o(sha1(serialize($data)));
if (count($extends)) {
foreach ($extends as $name => $instance) {
$closure = function ($object) use($name, $instance) {
$idx = $object->is_thin_object;
$objects = Utils::get('thinObjects');
return $instance->{$name}($objects[$idx]);
};
$obj->_closures[$name] = $closure;
}
}
$settings = Arrays::exists($type, static::$_settings) ? static::$_settings[$type] : array();
if (count($settings)) {
$db = Arrays::exists('db', $settings) ? $settings['db'] : null;
if (!empty($db)) {
$methods = array('save', 'delete');
foreach ($methods as $method) {
if (!Arrays::exists($method, $obj->_closures)) {
$closure = function () use($type, $method, $obj, $db) {
$name = $method . Inflector::camelize($db);
return $obj->{$name}($type);
};
$obj->_closures[$method] = $closure;
}
}
}
}
return $obj->populate($data);
}
return null;
}
示例15: render
public function render()
{
if (!count($this->_items)) {
return '<div class="span4"><div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->_config['noResultMessage'] . '</div></div>';
}
$pagination = $this->_config['pagination'];
$fields = $this->_config['fields'];
$addable = $this->_config['addable'];
$viewable = $this->_config['viewable'];
$editable = $this->_config['editable'];
$deletable = $this->_config['deletable'];
$duplicable = $this->_config['duplicable'];
if (\Thin\Arrays::exists('export', $this->_config)) {
$export = $this->_config['export'];
if (count($export)) {
$this->_export = $export;
}
}
$order = !strlen($this->_request->getCrudOrder()) ? $this->_config['defaultOrder'] : $this->_request->getCrudOrder();
$orderDirection = !strlen($this->_request->getCrudOrderDirection()) ? $this->_config['defaultOrderDirection'] : $this->_request->getCrudOrderDirection();
$sorted = true === $this->_config['order'] ? 'tablesorter' : '';
$html = '<table class="table table-striped ' . $sorted . ' table-bordered table-condensed">' . NL;
$html .= '<thead>' . NL;
$html .= '<tr>' . NL;
foreach ($fields as $field => $infosField) {
if (true === $infosField['onList']) {
if (true !== $infosField['sortable']) {
$html .= '<th class="no-sorter">' . \Thin\Html\Helper::display($infosField['label']) . '</th>' . NL;
} else {
if ($field == $order) {
$directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
$js = 'orderGoPage(\'' . $field . '\', \'' . $directionJs . '\');';
$html .= '<th>
<div onclick="' . $js . '" class="text-left field-sorting ' . \Thin\Inflector::lower($orderDirection) . '" rel="' . $field . '">
' . \Thin\Html\Helper::display($infosField['label']) . '
</div>
</th>';
} else {
$js = 'orderGoPage(\'' . $field . '\', \'ASC\');';
$html .= '<th>
<div onclick="' . $js . '" class="text-left field-sorting" rel="' . $field . '">
' . \Thin\Html\Helper::display($infosField['label']) . '
</div>
</th>';
}
}
}
}
$html .= '<th class="no-sorter">Actions</th>' . NL;
$html .= '</tr>' . NL;
$html .= '</thead>' . NL;
$html .= '<tbody>' . NL;
foreach ($this->_items as $item) {
$html .= '<tr>' . NL;
foreach ($fields as $field => $infosField) {
if (true === $infosField['onList']) {
$content = $infosField['content'];
$options = \Thin\Arrays::exists('options', $infosField) ? $infosField['options'] : array();
if (empty($options)) {
$options = array();
}
if (!in_array('nosql', $options)) {
$getter = 'get' . \Thin\Inflector::camelize($field);
$value = $item->{$getter}();
} else {
$value = $content;
}
if (strstr($content, '##self##') || strstr($content, '##em##') || strstr($content, '##field##') || strstr($content, '##id##')) {
$content = repl(array('##self##', '##em##', '##field##', '##id##'), array($value, $this->_em, $field, $item->getId()), $content);
$value = \Thin\Crud::internalFunction($content);
}
if (empty($value)) {
$value = ' ';
}
$html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>' . NL;
}
}
$actions = '';
if (true === $viewable) {
$actions .= '<a href="' . \Thin\Crud::getRoute('view', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="afficher" class="icon-file"></i></a> ';
}
if (true === $editable) {
$actions .= '<a href="' . \Thin\Crud::getRoute('edit', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="éditer" class="icon-edit"></i></a> ';
}
if (true === $duplicable) {
$actions .= '<a href="' . \Thin\Crud::getRoute('duplicate', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="dupliquer" class="icon-plus"></i></a> ';
}
if (true === $deletable) {
$actions .= '<a href="#" onclick="if (confirm(\'Confirmez-vous la suppression de cet élément ?\')) document.location.href = \'' . \Thin\Crud::getRoute('delete', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '\';"><i title="supprimer" class="icon-trash"></i></a> ';
}
$html .= '<td class="col_plus">' . $actions . '</td>' . NL;
$html .= '</tr>' . NL;
}
$html .= '</tbody>' . NL;
$html .= '</table>' . NL;
return $html;
}