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


PHP Application::get方法代码示例

本文整理汇总了PHP中Pagekit\Application::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::get方法的具体用法?PHP Application::get怎么用?PHP Application::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: activateAction

 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     $message = '';
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'status' => User::STATUS_BLOCKED, 'login IS NULL'])->first())) {
         return AuthController::messageView(['message' => __('Invalid key.'), 'success' => false]);
     }
     if ($admin = $this->module->config('registration') == 'approval' and !$user->get('verified')) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         $message = __('Your email has been verified. Once an administrator approves your account, you will be notified by email.');
     } else {
         $user->set('verified', true);
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         if ($admin) {
             $message = __('The user\'s account has been activated and the user has been notified about it.');
         } else {
             $message = __('Your account has been activated.');
         }
     }
     $user->save();
     App::message()->success($message);
     return App::redirect('@user/login');
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:28,代码来源:RegistrationController.php

示例2: confirmAction

 /**
  * @Request({"user", "key"})
  */
 public function confirmAction($username = "", $activation = "")
 {
     if (empty($username) || empty($activation) || !($user = User::where(compact('username', 'activation'))->first())) {
         return $this->messageView(__('Invalid key.'), $success = false);
     }
     if ($user->isBlocked()) {
         return $this->messageView(__('Your account has not been activated or is blocked.'), $success = false);
     }
     $error = '';
     if ('POST' === App::request()->getMethod()) {
         try {
             if (!App::csrf()->validate()) {
                 throw new Exception(__('Invalid token. Please try again.'));
             }
             $password = App::request()->request->get('password');
             if (empty($password)) {
                 throw new Exception(__('Enter password.'));
             }
             if ($password != trim($password)) {
                 throw new Exception(__('Invalid password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
             $user->activation = null;
             $user->save();
             App::message()->success(__('Your password has been reset.'));
             return App::redirect('@user/login');
         } catch (Exception $e) {
             $error = $e->getMessage();
         }
     }
     return ['$view' => ['title' => __('Reset Confirm'), 'name' => 'system/user/reset-confirm.php'], 'username' => $username, 'activation' => $activation, 'error' => $error];
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例3: saveAction

 /**
  * @Request({"user": "array"}, csrf=true)
  */
 public function saveAction($data)
 {
     $user = App::user();
     if (!$user->isAuthenticated()) {
         App::abort(404);
     }
     try {
         $user = User::find($user->id);
         if ($password = @$data['password_new']) {
             if (!App::auth()->getUserProvider()->validateCredentials($user, ['password' => @$data['password_old']])) {
                 throw new Exception(__('Invalid Password.'));
             }
             if (trim($password) != $password || strlen($password) < 3) {
                 throw new Exception(__('Invalid Password.'));
             }
             $user->password = App::get('auth.password')->hash($password);
         }
         if (@$data['email'] != $user->email) {
             $user->set('verified', false);
         }
         $user->name = @$data['name'];
         $user->email = @$data['email'];
         $user->validate();
         $user->save();
         return ['message' => 'success'];
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:32,代码来源:ProfileController.php

示例4: downloadAction

 /**
  * @Request({"url": "string"}, csrf=true)
  */
 public function downloadAction($url)
 {
     $file = tempnam(App::get('path.temp'), 'update_');
     App::session()->set('system.update', $file);
     if (!file_put_contents($file, @fopen($url, 'r'))) {
         App::abort(500, 'Download failed or Path not writable.');
     }
     return [];
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:12,代码来源:UpdateController.php

示例5: __construct

 /**
  * Constructor.
  *
  * @param mixed $output
  */
 public function __construct($output = null)
 {
     $this->output = $output ?: new StreamOutput(fopen('php://output', 'w'));
     $config = array_flip(['path.temp', 'path.cache', 'path.vendor', 'path.artifact', 'path.packages', 'system.api']);
     array_walk($config, function (&$value, $key) {
         $value = App::get($key);
     });
     $this->composer = new Composer($config, $output);
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:14,代码来源:PackageManager.php

示例6: registerFieldType

 /**
  * Register a field type.
  * @param array $package
  */
 protected function registerFieldType($package)
 {
     $loader = App::get('autoloader');
     if (isset($package['autoload'])) {
         foreach ($package['autoload'] as $namespace => $path) {
             $loader->addPsr4($namespace, $this->resolvePath($package, $path));
         }
     }
     $this->fieldTypes[$package['id']] = new $package['class']($package);
 }
开发者ID:Bixie,项目名称:pagekit-framework,代码行数:14,代码来源:FrameworkModule.php

示例7: getDirectories

 /**
  * Gets a list of files and directories and their writable status.
  *
  * @return string[]
  */
 protected function getDirectories()
 {
     // -TODO-
     $directories = [App::get('path.storage'), App::get('path.temp'), App::get('config.file')];
     $result = [];
     foreach ($directories as $directory) {
         $result[$this->getRelativePath($directory)] = is_writable($directory);
         if (is_dir($directory)) {
             foreach (App::finder()->in($directory)->directories()->depth(0) as $dir) {
                 $result[$this->getRelativePath($dir->getPathname())] = is_writable($dir->getPathname());
             }
         }
     }
     return $result;
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:20,代码来源:InfoHelper.php

示例8: saveAction

 /**
  * @Request({"config": "array", "options": "array"}, csrf=true)
  */
 public function saveAction($values = [], $options = [])
 {
     $config = new Config();
     $config->merge(include $file = App::get('config.file'));
     foreach ($values as $module => $value) {
         $config->set($module, $value);
     }
     file_put_contents($file, $config->dump());
     foreach ($options as $module => $value) {
         $this->configAction($module, $value);
     }
     if (function_exists('opcache_invalidate')) {
         opcache_invalidate($file);
     }
     return ['message' => 'success'];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:19,代码来源:SettingsController.php

示例9: downloadAction

 /**
  * @Request({"url": "string", "shasum": "string"}, csrf=true)
  */
 public function downloadAction($url, $shasum)
 {
     try {
         $file = tempnam(App::get('path.temp'), 'update_');
         App::session()->set('system.update', $file);
         $client = new Client();
         $data = $client->get($url)->getBody();
         if (sha1($data) !== $shasum) {
             throw new \RuntimeException('Package checksum verification failed.');
         }
         if (!file_put_contents($file, $data)) {
             throw new \RuntimeException('Path is not writable.');
         }
         return [];
     } catch (\Exception $e) {
         if ($e instanceof TransferException) {
             $error = 'Package download failed.';
         } else {
             $error = $e->getMessage();
         }
         App::abort(500, $error);
     }
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:26,代码来源:UpdateController.php

示例10: activateAction

 /**
  * @Request({"user", "key"})
  */
 public function activateAction($username, $activation)
 {
     if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'login IS NULL'])->first())) {
         App::abort(400, __('Invalid key.'));
     }
     $verifying = false;
     if ($this->module->config('require_verification') && !$user->get('verified')) {
         $user->set('verified', true);
         $verifying = true;
     }
     if ($this->module->config('registration') === 'approval' && $user->status === User::STATUS_BLOCKED && $verifying) {
         $user->activation = App::get('auth.random')->generateString(32);
         $this->sendApproveMail($user);
         $message = __('Your email has been verified. Once an administrator approves your account, you will be notified by email.');
     } else {
         $user->status = User::STATUS_ACTIVE;
         $user->activation = '';
         $this->sendWelcomeEmail($user);
         $message = $verifying ? __('Your account has been activated.') : __('The user\'s account has been activated and the user has been notified about it.');
     }
     $user->save();
     App::message()->success($message);
     return App::redirect('@user/login');
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:27,代码来源:RegistrationController.php

示例11: onUserChange

 /**
  * Updates the user in the corresponding session.
  */
 public function onUserChange()
 {
     App::config('system/user')->set('auth.refresh_token', App::get('auth.random')->generateString(16));
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:7,代码来源:UserListener.php

示例12: indexAction

 /**
  * @Route("/", methods="GET")
  */
 public function indexAction()
 {
     return ['$view' => ['title' => __('Dashboard'), 'name' => 'system/dashboard:views/index.php'], '$data' => ['widgets' => array_values($this->dashboard->getWidgets()), 'api' => App::get('system.api'), 'version' => App::version(), 'channel' => 'stable']];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:7,代码来源:DashboardController.php

示例13: onSystemInit

 /**
  * Initialize system.
  */
 public function onSystemInit()
 {
     App::auth()->setUserProvider(new UserProvider(App::get('auth.password')));
     App::auth()->refresh(App::module('system/user')->config('auth.refresh_token'));
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:8,代码来源:AuthorizationListener.php

示例14: installAction

 /**
  * @Request({"config": "array", "option": "array", "user": "array"})
  */
 public function installAction($config = [], $option = [], $user = [])
 {
     $status = $this->checkAction($config);
     $message = $status['message'];
     $status = $status['status'];
     try {
         if ('no-connection' == $status) {
             App::abort(400, __('No database connection.'));
         }
         if ('tables-exist' == $status) {
             App::abort(400, $message);
         }
         $scripts = new PackageScripts(App::path() . '/app/system/scripts.php');
         $scripts->install();
         App::db()->insert('@system_user', ['name' => $user['username'], 'username' => $user['username'], 'password' => App::get('auth.password')->hash($user['password']), 'status' => 1, 'email' => $user['email'], 'registered' => date('Y-m-d H:i:s'), 'roles' => '2,3']);
         $option['system']['version'] = App::version();
         $option['system']['extensions'] = ['blog'];
         $option['system']['site']['theme'] = 'theme-one';
         foreach ($option as $name => $values) {
             App::config()->set($name, App::config($name)->merge($values));
         }
         if ($this->packages) {
             $installer = new PackageManager(new NullOutput());
             $installer->install($this->packages);
         }
         if (file_exists(__DIR__ . '/../../install.php')) {
             require_once __DIR__ . '/../../install.php';
         }
         if (!$this->config) {
             $configuration = new Config();
             $configuration->set('application.debug', false);
             foreach ($config as $key => $value) {
                 $configuration->set($key, $value);
             }
             $configuration->set('system.secret', App::get('auth.random')->generateString(64));
             if (!file_put_contents($this->configFile, $configuration->dump())) {
                 $status = 'write-failed';
                 App::abort(400, __('Can\'t write config.'));
             }
         }
         App::module('system/cache')->clearCache();
         $status = 'success';
     } catch (DBALException $e) {
         $status = 'db-sql-failed';
         $message = __('Database error: %error%', ['%error%' => $e->getMessage()]);
     } catch (\Exception $e) {
         $message = $e->getMessage();
     }
     return ['status' => $status, 'message' => $message];
 }
开发者ID:sdaoudi,项目名称:rimbo,代码行数:53,代码来源:InstallerController.php

示例15: clearCache

 /**
  * @param array $options
  */
 public static function clearCache($options = [])
 {
     if (@$options['temp']) {
         App::file()->delete(App::get('path.cache') . '/portfolio');
     }
 }
开发者ID:4nxiety,项目名称:pagekit-portfolio,代码行数:9,代码来源:PortfolioImageHelper.php


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