public function fire() { $clearAll = true; if ($this->input->getOption('config-only')) { $clearAll = false; Config::clearCache(); $this->info('Config cache cleared.'); } if ($this->input->getOption('meta-only')) { $clearAll = false; Db::clearMetadata(); $this->info('Model metadata cleared.'); } if ($this->input->getOption('locale-only')) { $clearAll = false; I18n::clearCache(); $this->info('Locale cache cleared.'); } if ($this->input->getOption('assets-only')) { $clearAll = false; View::clearAssetsCache(); $this->info('Assets cache cleared.'); } if ($clearAll) { Cache::flush(); Config::clearCache(); $this->info('Cache cleared.'); } Events::fire('cache:after_clear', $this); }
public function createUser(array $credential, $confirmed = null) { /* @var User $user */ $user = new $this->userModel(); if ($email = filter_var($login = $credential['login'], FILTER_VALIDATE_EMAIL)) { $user->setData('email', $email); $confirmed === null and $confirmed = !$this->options['register']['confirm_email']; $confirmed or $user->setData('confirmation_code', Text::token())->setData('confirm_method', 'sendConfirmationEmail'); } elseif (I18n::checkMobile($login)) { $user->setData('mobile', $login); $confirmed === null and $confirmed = !$this->options['register']['confirm_mobile']; $confirmed or $user->setData('confirmation_code', mt_rand(100000, 999999))->setData('confirm_method', 'sendConfirmationSms'); } else { throw new Exception(__($this->options['hints']['invalid_user_credential'])); } $user->setData('password', $this->hasher->hash($credential['password']))->setData('confirmed', $confirmed)->generateDistributedId(); if ($confirmed) { if (!$user->save()) { throw new Exception(__($this->options['hints']['unable_to_save_user']), 0, $user->getStringMessages()); } } else { $this->pushPendingConfirmation($user, $credential); } return $user; }
public function setUp() { $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId(); /* @var Di $di */ $di = $this->di = Di::getDefault(); Events::register($di); DiFix::register($di); Db::register($di); Cache::register($di); Log::register($di); Config::register($di); Counter::register($this->di); Aliases::register($di); I18n::register($di); Cookies::register($di); Session::register($di); Cache::flush(); Config::clearCache(); parent::setUp(); $class = get_class($this); Log::debug("================== Running {$class}::{$this->getName()}() ... =================="); Timer::start(); }
public function testCheckMobile() { $mobile = '13579246801'; $this->assertTrue(I18n::checkMobile($mobile, 'CN'), 'Bad check mobile result'); }
public static function getPageLanguage() { return strtr(static::getParam('page_language', I18n::getCurrentLocale()), ['_' => '-']); }
use Phalcon\Version; use Phwoolcon\Aliases; use Phwoolcon\Cache; use Phwoolcon\Config; use Phwoolcon\Cookies; use Phwoolcon\Db; use Phwoolcon\DiFix; use Phwoolcon\Events; use Phwoolcon\I18n; use Phwoolcon\Log; use Phwoolcon\Queue; use Phwoolcon\Router; use Phwoolcon\Session; use Phwoolcon\Util\Counter; use Phwoolcon\View; $_SERVER['PHWOOLCON_PHALCON_VERSION'] = Version::getId(); Events::register($di); DiFix::register($di); Db::register($di); Cache::register($di); Log::register($di); Config::register($di); Counter::register($di); Aliases::register($di); Router::register($di); I18n::register($di); Cookies::register($di); Session::register($di); View::register($di); Queue::register($di); $loader->registerNamespaces(Config::get('app.autoload.namespaces', []), true);
function price($amount, $currency = 'CNY') { return I18n::formatPrice($amount, $currency); }