本文整理汇总了PHP中ArrayIterator::offsetExists方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::offsetExists方法的具体用法?PHP ArrayIterator::offsetExists怎么用?PHP ArrayIterator::offsetExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayIterator
的用法示例。
在下文中一共展示了ArrayIterator::offsetExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
*
* @param <type> $table
* @param ArrayIterator $params
* @return ArrayObject
*/
public function search($table, ArrayIterator $params)
{
$this->searchParams = $params;
$this->join();
if ($table == "analysis") {
$this->statements->remove("type_event");
}
$statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
$statement .= $this->join();
$i = 0;
$this->searchParams->rewind();
if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
$statement .= " WHERE ";
}
while ($this->searchParams->valid()) {
if ($this->statements->containsKey($this->searchParams->key())) {
if ($i++ > 0) {
$statement .= " AND ";
}
$clause = $this->statements->get($this->searchParams->key());
$statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
}
$this->searchParams->next();
}
return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
}
示例2: getParam
public function getParam($name, $default = null)
{
$value = $default;
if ($this->params->offsetExists($name)) {
$value = $this->params->offsetGet($name);
}
return $value;
}
示例3: getLocation
/**
* @param $locId
* @return LocationHelper
* @throws \Exception
*/
public function getLocation($locId)
{
if ($this->locations->offsetExists($locId)) {
return $this->locations->offsetGet($locId);
} else {
return $this->locHelper->factory($locId);
}
}
示例4: verifyAccess
public function verifyAccess($name, $resource, $page)
{
if (!$this->resources->offsetExists($resource)) {
return false;
}
if (!$this->pages->offsetExists($page)) {
return false;
}
return true;
}
示例5: offsetExists
/**
* \WP_Widget::update_callback(): $old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();
* \WP_Widget::display_callback(): if ( array_key_exists( $this->number, $instance ) ) {
* \WP_Widget::get_settings(): if ( !empty($settings) && !array_key_exists('_multiwidget', $settings) ) {
*
* @param int|string $key Array key.
* @return bool
*/
public function offsetExists($key)
{
if ('_multiwidget' === $key) {
return true;
}
return parent::offsetExists($key);
}
示例6: offsetGet
public function offsetGet($offset)
{
$name = $this->_normalizeHeaderName($offset);
if (!parent::offsetExists($name)) {
throw new Bringit_Exception("Header '{$name}' not in ");
}
return parent::offsetGet($name);
}
示例7: reflect
/**
* Reflect the handle class
*
* @param string $class
* @return Collection\Method
* @throws Exception\InvalidArgument
*/
public function reflect($class)
{
if (class_exists($class) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $class), 1);
}
// Check if we've already reflected this class
if (static::$reflections->offsetExists($class)) {
return static::$reflections->offsetGet($class);
}
// Create reflection
$reflectionClass = new \ReflectionClass($class);
$reflectionMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
// Method container
$methods = new Collection\Method();
// Loop through the class methods (Only public);
foreach ($reflectionMethods as $reflectionMethod) {
// Create method information entity
$method = new Entity\Method();
$method->setName($reflectionMethod->getName());
// Get method parameters
$reflectionParams = $reflectionMethod->getParameters();
// Evaluate the method params
foreach ($reflectionParams as $reflectionParam) {
// Create parameter information entity
$parameter = new Entity\Parameter();
$parameter->setIndex($reflectionParam->getPosition());
$parameter->setName($reflectionParam->getName());
$parameter->setRequired($reflectionParam->isDefaultValueAvailable() === false);
// Only set default value when param is optional
if ($parameter->getRequired() === false) {
$parameter->setDefault($reflectionParam->getDefaultValue());
}
// Add the parameter to the container
$method->addParameter($parameter);
}
// Add the method to the method container
$methods->offsetSet(strtolower($method->getName()), $method);
}
// Cache reflection in the runtime
self::$reflections->offsetSet($class, $methods);
// Return the methods
return $methods;
}
示例8: getPostedFile
private function getPostedFile($key)
{
if (!$this->specsIterator->offsetExists($key)) {
return null;
}
$spec = $this->specsIterator[$key];
if (is_array($spec)) {
$this->specsIterator[$key] = new \Barberry\PostedFile($this->readTempFile($spec['tmp_name']), $spec['name']);
}
return $this->specsIterator[$key];
}
示例9: check
/**
* Check input against the Rules configured for this Validator.
*
* @param array|object|Persistent $input The input data to check.
* @param bool $all If true, all rules will be checked even if the field
* does not exist in the input data.
*
* @return bool True if all Rules pass, false otherwise.
*/
public function check($input, $all = false)
{
$data = new \ArrayIterator($input);
foreach ($this->ruleSet as $field => $rules) {
if ($all || $data->offsetExists($field)) {
$fieldValue = $data->offsetExists($field) ? $data->offsetGet($field) : null;
foreach (explode('|', $rules) as $ruleDef) {
$ruleExploded = explode(':', $ruleDef, 2);
$rule = $ruleExploded[0];
$ruleArgs = isset($ruleExploded[1]) ? explode(',', $ruleExploded[1]) : [];
try {
Rules::$rule($field, $fieldValue, $ruleArgs);
} catch (ValidationFailedException $failure) {
$this->addFailure($field, $failure->getMessage(), $failure->getCode());
$this->failed = true;
}
}
}
}
$this->checked = true;
return $this->failed === false;
}
示例10: _getRealOffset
/**
* Determines the actual array offset given the input offset.
*
* @param string $offset Input offset.
*
* @return string Real offset or null.
*/
protected function _getRealOffset($offset)
{
/* Optimize: check for base $offset in array first. */
if (parent::offsetExists($offset)) {
return $offset;
}
foreach (array_keys($this->getArrayCopy()) as $key) {
if (strcasecmp($key, $offset) === 0) {
return $key;
}
}
return null;
}
示例11: getHandler
/**
* Get the handler based on the namespace
*
* @param string $namespace
* @return object
* @throws Exception\ArgumentException
*/
protected function getHandler($namespace)
{
// Chack if namespace has been registered
if ($this->handlers->offsetExists($namespace) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $namespace), 1);
}
// Create instance when needed
if ($this->handlerInstances->offsetExists($namespace) === false) {
$handler = $this->handlers->offsetGet($namespace);
$this->handlerInstances->offsetSet($namespace, new $handler());
}
// Return instance
return $this->handlerInstances->offsetGet($namespace);
}
示例12: checkMimeTypes
/**
* Verifica o mime type do arquivo
* @return boolean
*/
public function checkMimeTypes()
{
$fileExtension = $this->getFileExtension();
$fileMimeType = $this->getMimeTypeFile();
$oIMines = $this->getMimeTypes()->getIterator();
$oIExtension = $this->getExtension()->getIterator();
$valid = new \ArrayIterator();
while ($oIExtension->valid()) {
$current = $oIExtension->current();
if ($oIMines->offsetExists($current)) {
$valid->offsetSet($current, $oIMines->offsetGet($current));
}
$oIExtension->next();
}
if ($valid->offsetExists($fileExtension)) {
$item = $valid->offsetGet($fileExtension);
if (is_array($item)) {
if (in_array($fileMimeType, $item)) {
return true;
} else {
$this->setMessageError("error_mime_type");
return false;
}
} else {
if ($fileMimeType == $item) {
return true;
} else {
$this->setMessageError("error_mime_type");
return false;
}
}
} else {
$this->setMessageError("error_mime_type");
return false;
}
}
示例13: existIndex
/**
* Check if the index exist into container
*
* @param int $index
* @return boolean
*/
public function existIndex($index)
{
return parent::offsetExists($index);
}
示例14: offsetUnset
public function offsetUnset($name)
{
if (!is_array($name)) {
return parent::offsetUnset($name);
} else {
$key = array_shift($name);
if (sizeof($name) == 0) {
return parent::offsetUnset($key);
} else {
if (parent::offsetExists($key)) {
$object = parent::offsetGet($key);
if (is_a($object, 'MutliDimArray')) {
$object->offsetUnset($name);
if ($object->sizeof() == 0) {
parent::offsetUnset($key);
}
} else {
parent::offsetUnset($key);
}
}
}
}
}
示例15: offsetExists
/**
* Check whether an offset exists.
*
* @param mixed $offset
* @return boolean
*/
public function offsetExists($offset)
{
return $this->iterator->offsetExists($offset);
}