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


PHP Validators::isNumericInt方法代码示例

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

示例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;
 }
开发者ID:trejjam,项目名称:authorization,代码行数:30,代码来源:Manager.php

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

示例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);
         }
     }
 }
开发者ID:trejjam,项目名称:utils,代码行数:22,代码来源:AItem.php

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

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

示例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;
 }
开发者ID:rostenkowski,项目名称:nette,代码行数:15,代码来源:Validator.php

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

示例9: validateInteger

 /**
  * Is a control's value decimal number?
  * @return bool
  * @internal
  */
 public static function validateInteger(TextBase $control)
 {
     return Validators::isNumericInt($control->getValue());
 }
开发者ID:ppwalks33,项目名称:cleansure,代码行数:9,代码来源:TextBase.php

示例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;
 }
开发者ID:lucien144,项目名称:Restful,代码行数:15,代码来源:Field.php

示例11: registerCookiesValidators

 protected function registerCookiesValidators()
 {
     $this->cookies->registerValidator('sys_shift_pattern_id', function ($id) {
         return \Nette\Utils\Validators::isNumericInt($id);
     });
 }
开发者ID:dansilovsky,项目名称:calendar,代码行数:6,代码来源:HomePresenter.php

示例12: isNumber

 public static function isNumber($number)
 {
     return Validators::isNumericInt($number) && $number >= 0;
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:4,代码来源:NumberUtils.php

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

示例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
开发者ID:JanTvrdik,项目名称:NetteExtras,代码行数:4,代码来源:loader.php

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


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