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


PHP Arrays::exists方法代码示例

本文整理汇总了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);
 }
开发者ID:schpill,项目名称:thin,代码行数:14,代码来源:Fluent.php

示例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);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:34,代码来源:Api.php

示例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;
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:13,代码来源:HTTPException.php

示例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}");
 }
开发者ID:schpill,项目名称:thin,代码行数:15,代码来源:Reflection.php

示例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]);
 }
开发者ID:schpill,项目名称:thin,代码行数:11,代码来源:Service.php

示例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.');
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:49,代码来源:Activerecord.php

示例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;
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:27,代码来源:Redis.php

示例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();
 }
开发者ID:schpill,项目名称:thin,代码行数:29,代码来源:Mongonode.php

示例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;
 }
开发者ID:schpill,项目名称:thin,代码行数:25,代码来源:Eventable.php

示例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;
 }
开发者ID:schpill,项目名称:thin,代码行数:43,代码来源:Object.php

示例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();
 }
开发者ID:noikiy,项目名称:inovi,代码行数:25,代码来源:Helper.php

示例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;
 }
开发者ID:schpill,项目名称:standalone,代码行数:19,代码来源:form.php

示例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;
 }
开发者ID:schpill,项目名称:standalone,代码行数:29,代码来源:Stringify.php

示例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;
 }
开发者ID:schpill,项目名称:thin,代码行数:34,代码来源:Data.php

示例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 = '&nbsp;';
                 }
                 $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>&nbsp;&nbsp;&nbsp;';
         }
         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>&nbsp;&nbsp;&nbsp;';
         }
         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>&nbsp;&nbsp;&nbsp;';
         }
         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>&nbsp;&nbsp;&nbsp;';
         }
         $html .= '<td class="col_plus">' . $actions . '</td>' . NL;
         $html .= '</tr>' . NL;
     }
     $html .= '</tbody>' . NL;
     $html .= '</table>' . NL;
     return $html;
 }
开发者ID:schpill,项目名称:thin,代码行数:97,代码来源:Listing.php


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