本文整理汇总了PHP中Nette\Utils\Validators::isNumericInt方法的典型用法代码示例。如果您正苦于以下问题:PHP Validators::isNumericInt方法的具体用法?PHP Validators::isNumericInt怎么用?PHP Validators::isNumericInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Validators
的用法示例。
在下文中一共展示了Validators::isNumericInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupTemplating
/**
* @param \Nette\DI\ContainerBuilder $container
* @param array $config
*/
private function setupTemplating(ContainerBuilder $container, array $config)
{
$def = $container->addDefinition($this->prefix('templateFilesFormatter'))->setClass('Lohini\\Templating\\TemplateFilesFormatter')->addSetup('$skin', [$config['skin']]);
foreach ($config['dirs'] as $dir => $priority) {
$def->addSetup('addDir', Validators::isNumericInt($dir) ? [$priority] : [$container->expand($dir), $priority]);
}
}
示例2: getItem
/**
* @param int|Nette\Database\Table\IRow $id
* @return \stdClass
*/
public function getItem($id)
{
if (isset($id->{static::ROW})) {
$row = $id->{static::ROW};
} else {
if ($id instanceof Nette\Database\Table\IRow) {
$row = $id;
} else {
if (isset($this->userCache[$id])) {
return $this->userCache[$id];
}
$row = $this->getTable()->where([$this->getTableCell('id') => $id])->fetch();
if (!$row) {
throw new Trejjam\Authorization\User\ManagerException("User id '{$id}' not found", Trejjam\Authorization\User\ManagerException::ID_NOT_FOUND);
}
}
}
$out = (object) [static::ROW => $row];
foreach ($this->tables['users']['items'] as $k => $v) {
if (Nette\Utils\Validators::isNumericInt($k)) {
$k = $v;
}
$out->{$k} = $row->{$v};
}
return $this->userCache[$out->id] = $out;
}
示例3: appendSort
static function appendSort(Nette\Database\Table\Selection &$query, $sort = NULL)
{
if (!is_null($sort)) {
foreach ($sort as $k => $v) {
if (Nette\Utils\Validators::isNumericInt($k)) {
$query->order($v);
} else {
$query->order($k . ' ' . strtoupper($v));
}
}
}
return $query;
}
示例4: updateProperties
/**
* @param array|\stdClass|Nette\Database\Table\IRow $properties
* @param array|NULL $persistProperties
*
* @internal
*/
public function updateProperties($properties, array $persistProperties = NULL)
{
$this->properties = $properties;
if (!is_null($persistProperties)) {
foreach ($persistProperties as $k => $v) {
$keyName = Nette\Utils\Validators::isNumericInt($k) ? $v : $k;
$this->{$keyName} = is_callable($v) ? $v($properties) : $v;
}
} else {
$this->id = !is_object($properties) && isset($properties['id']) ? $properties['id'] : (isset($properties->id) ? $properties->id : NULL);
$this->parentId = !is_object($properties) && isset($properties['parent_id']) ? $properties['parent_id'] : (isset($properties->parent_id) ? $properties->parent_id : NULL);
if (is_null($this->parentId)) {
$this->parentId = !is_object($properties) && isset($properties['parentId']) ? $properties['parentId'] : (isset($properties->parentId) ? $properties->parentId : NULL);
}
}
}
示例5: setAction
public function setAction($user, $action, $identityHash = NULL)
{
if (!in_array($action, [static::ACTION_NONE, static::ACTION_RELOAD, static::ACTION_LOGOUT, static::ACTION_DESTROYED])) {
throw new Trejjam\Authorization\User\IdentityHashException("Action '{$action}' is not enabled.", Trejjam\Authorization\User\IdentityHashException::ACTION_NOT_ENABLED);
}
$where = [$this->tables['identityHash']['userId'] => Nette\Utils\Validators::isNumericInt($user) ? $user : $user->id];
if (!is_null($identityHash)) {
$where[$this->tables['identityHash']['hash']] = $identityHash;
}
switch ($action) {
case static::ACTION_RELOAD:
$where[$this->tables['identityHash']['action']] = static::ACTION_NONE;
break;
}
$this->getTable()->where($where)->update([$this->tables['identityHash']['action'] => $action]);
}
示例6: getType
/**
* @param int $userId
* @param int $requestId
* @param string $hash
* @param bool $invalidateHash
* @return bool|string
*/
public function getType($userId, $requestId, $hash, $invalidateHash = TRUE)
{
if (!isset($userId->{static::ROW}) && !Nette\Utils\Validators::isNumericInt($userId) || !Nette\Utils\Validators::isNumericInt($requestId) || empty($hash)) {
throw new Trejjam\Authorization\User\RequestException('Invalid input parameters', Trejjam\Authorization\User\RequestException::INVALID_INPUT);
}
if ($row = $this->getTable()->where([$this->tables['userRequest']['userId'] => isset($userId->{static::ROW}) ? $userId->id : $userId, $this->tables['userRequest']['id'] => $requestId])->fetch()) {
if (!Nette\Security\Passwords::verify($hash, $row->{$this->tables['userRequest']['hash']['name']})) {
throw new Trejjam\Authorization\User\RequestException('Hash is corrupted', Trejjam\Authorization\User\RequestException::CORRUPTED_HASH);
}
if ($row->{$this->tables['userRequest']['used']['name']} == $this->tables['userRequest']['used']['positive']) {
throw new Trejjam\Authorization\User\RequestException('Hash was used', Trejjam\Authorization\User\RequestException::USED_HASH);
}
if (!is_null($row->{$this->tables['userRequest']['timeout']['name']}) && $row->{$this->tables['userRequest']['timeout']['name']} < $this->getSqlTime()) {
throw new Trejjam\Authorization\User\RequestException('Hash timeout', Trejjam\Authorization\User\RequestException::HASH_TIMEOUT);
}
if ($invalidateHash) {
$row->update([$this->tables['userRequest']['used']['name'] => $this->tables['userRequest']['used']['positive']]);
}
return $row->{$this->tables['userRequest']['type']['name']};
}
throw new Trejjam\Authorization\User\RequestException("Permission denied to requestId '{$requestId}' for user '{$userId}'", Trejjam\Authorization\User\RequestException::PERMISSION_DENIED);
}
示例7: validateInteger
/**
* Is a control's value decimal number?
* @return bool
*/
public static function validateInteger(IControl $control)
{
if (Validators::isNumericInt($value = $control->getValue())) {
if (!is_float($tmp = $value * 1)) {
// bigint leave as string
$control->setValue($tmp);
}
return TRUE;
}
return FALSE;
}
示例8: removeUserRole
/**
* @param int $userId
* @param string $roleName
*/
public function removeUserRole($user, $roleName)
{
$role = $this->getRoleByName($roleName);
if (!is_null($role)) {
$roleArr = [$this->tables["userRoles"]["userId"] => Nette\Utils\Validators::isNumericInt($user) ? $user : $user->id, $this->tables["userRoles"]["roleId"] => $role->getId()];
$this->database->table($this->tables["userRoles"]["table"])->where($roleArr)->delete();
}
}
示例9: validateInteger
/**
* Is a control's value decimal number?
* @return bool
* @internal
*/
public static function validateInteger(TextBase $control)
{
return Validators::isNumericInt($control->getValue());
}
示例10: parseNumericValue
/**
* Convert string -> int, string -> float because of textual x-www-form-data
* @param mixed $value
* @return mixed
*/
protected function parseNumericValue($value)
{
if (Validators::isNumericInt($value)) {
return (int) $value;
}
if (Validators::isNumeric($value)) {
return (double) $value;
}
return $value;
}
示例11: registerCookiesValidators
protected function registerCookiesValidators()
{
$this->cookies->registerValidator('sys_shift_pattern_id', function ($id) {
return \Nette\Utils\Validators::isNumericInt($id);
});
}
示例12: isNumber
public static function isNumber($number)
{
return Validators::isNumericInt($number) && $number >= 0;
}
示例13: loadState
function loadState(array $params)
{
parent::loadState($params);
if (count($this->sort) == 0) {
foreach ($this->defaultSort as $k => $v) {
if (!isset($this->sort[$k])) {
$this->sort[$k] = $v;
}
}
}
foreach ($this->sort as $k => $v) {
if (!in_array($k, $this->enabledSort) && !isset($this->defaultSort[$k])) {
unset($this->sort[$k]);
continue;
}
if (!in_array($v, array_keys($this->enableValues))) {
unset($this->sort[$k]);
continue;
}
}
foreach ($this->defaultFilter as $k => $v) {
if (!isset($this->filter[$k])) {
$this->filter[$k] = $v;
}
}
foreach ($this->filter as $k => $v) {
if (!in_array($k, $this->enableFilter)) {
unset($this->filter[$k]);
continue;
}
}
if (!is_null($this->countCallback)) {
$this->count = call_user_func($this->countCallback, $this->getDbFilter());
} else {
throw new \LogicException('Missing count callback');
}
$this->limit = Nette\Utils\Validators::isNumericInt($this->limit) ? $this->limit : static::DEFAULT_LIMIT;
$this->page = Nette\Utils\Validators::isNumericInt($this->page) && $this->page <= ceil($this->count / $this->limit) && $this->page > 0 ? $this->page : 1;
$this->cleanSortKeys = $this->defaultSort;
foreach ($this->enabledSort as $k => $v) {
if (isset($this->cleanSortKeys[$k])) {
unset($this->cleanSortKeys[$k]);
}
}
}
示例14:
validatePattern(TextBase$control,$pattern){return(bool)Strings::match($control->getValue(),"\x01^($pattern)$\x01u");}static
function
validateInteger(TextBase$control){return
Validators::isNumericInt($control->getValue());}static
示例15: buildAuthorizatorList
/**
* @param \Nette\DI\ContainerBuilder $builder
*/
private function buildAuthorizatorList(ContainerBuilder $builder)
{
$services = [];
foreach ($builder->findByTag($this->prefix(self::AUTHORIZATOR_TAG)) as $name => $priority) {
if (!Validators::isNumericInt($priority)) {
throw new \Nette\InvalidArgumentException(sprintf('Authorizator priority for service %s has to be integer, %s given.', $name, gettype($priority)));
}
$services[(int) $priority][] = $name;
}
krsort($services);
return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($services)), FALSE);
}