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


PHP Application::getVersion方法代码示例

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


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

示例1: dashboardnews

 /**
  * News. Film at 11.
  *
  * @param \Silex\Application $app
  * @param Request            $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function dashboardnews(Silex\Application $app, Request $request)
 {
     $source = 'http://news.bolt.cm/';
     $news = $app['cache']->fetch('dashboardnews');
     // Two hours.
     $hostname = $request->getHost();
     $body = '';
     // If not cached, get fresh news.
     if ($news === false) {
         $app['logger.system']->info('Fetching from remote server: ' . $source, array('event' => 'news'));
         $driver = $app['db']->getDatabasePlatform()->getName();
         $url = sprintf('%s?v=%s&p=%s&db=%s&name=%s', $source, rawurlencode($app->getVersion()), phpversion(), $driver, base64_encode($hostname));
         // Options valid if using a proxy
         if ($app['config']->get('general/httpProxy')) {
             $curlOptions = array('CURLOPT_PROXY' => $app['config']->get('general/httpProxy/host'), 'CURLOPT_PROXYTYPE' => 'CURLPROXY_HTTP', 'CURLOPT_PROXYUSERPWD' => $app['config']->get('general/httpProxy/user') . ':' . $app['config']->get('general/httpProxy/password'));
         }
         // Standard option(s)
         $curlOptions['CURLOPT_CONNECTTIMEOUT'] = 5;
         try {
             if ($app['deprecated.php']) {
                 $fetchedNewsData = $app['guzzle.client']->get($url, null, $curlOptions)->send()->getBody(true);
             } else {
                 $fetchedNewsData = $app['guzzle.client']->get($url, array(), $curlOptions)->getBody(true);
             }
             $fetchedNewsItems = json_decode($fetchedNewsData);
             if ($fetchedNewsItems) {
                 $news = array();
                 // Iterate over the items, pick the first news-item that applies and the first alert we need to show
                 $version = $app->getVersion();
                 foreach ($fetchedNewsItems as $item) {
                     $type = $item->type === 'alert' ? 'alert' : 'information';
                     if (!isset($news[$type]) && (empty($item->target_version) || version_compare($item->target_version, $version, '>'))) {
                         $news[$type] = $item;
                     }
                 }
                 $app['cache']->save('dashboardnews', $news, 7200);
             } else {
                 $app['logger.system']->error('Invalid JSON feed returned', array('event' => 'news'));
             }
         } catch (RequestException $e) {
             $app['logger.system']->critical('Error occurred during newsfeed fetch', array('event' => 'exception', 'exception' => $e));
             $body .= "<p>Unable to connect to {$source}</p>";
         } catch (V3RequestException $e) {
             /** @deprecated remove with the end of PHP 5.3 support */
             $app['logger.system']->critical('Error occurred during newsfeed fetch', array('event' => 'exception', 'exception' => $e));
             $body .= "<p>Unable to connect to {$source}</p>";
         }
     } else {
         $app['logger.system']->info('Using cached data', array('event' => 'news'));
     }
     // Combine the body. One 'alert' and one 'info' max. Regular info-items can be disabled, but Alerts can't.
     if (!empty($news['alert'])) {
         $body .= $app['render']->render('components/panel-news.twig', array('news' => $news['alert']))->getContent();
     }
     if (!empty($news['information']) && !$app['config']->get('general/backend/news/disable')) {
         $body .= $app['render']->render('components/panel-news.twig', array('news' => $news['information']))->getContent();
     }
     return new Response($body, Response::HTTP_OK, array('Cache-Control' => 's-maxage=3600, public'));
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:67,代码来源:Async.php

示例2: register

 public function register(Application $app)
 {
     $app['nut'] = $app->share(function ($app) {
         $console = new NutApplication();
         $console->setName('Bolt console tool - Nut');
         if ($app instanceof \Bolt\Application) {
             $console->setVersion($app->getVersion());
         }
         $console->addCommands($app['nut.commands']);
         return $console;
     });
     $app['nut.commands'] = $app->share(function ($app) {
         return [new Nut\CronRunner($app), new Nut\CacheClear($app), new Nut\Info($app), new Nut\LogTrim($app), new Nut\LogClear($app), new Nut\DatabaseCheck($app), new Nut\DatabaseExport($app), new Nut\DatabaseImport($app), new Nut\DatabasePrefill($app), new Nut\DatabaseRepair($app), new Nut\TestRunner($app), new Nut\ConfigGet($app), new Nut\ConfigSet($app), new Nut\Extensions($app), new Nut\ExtensionsEnable($app), new Nut\ExtensionsDisable($app), new Nut\UserAdd($app), new Nut\UserResetPassword($app), new Nut\UserRoleAdd($app), new Nut\UserRoleRemove($app)];
     });
     $app['nut.commands.add'] = $app->protect(function (Command $command) use($app) {
         $app['nut.commands'] = $app->share($app->extend('nut.commands', function ($commands) use($command) {
             $commands[] = $command;
             return $commands;
         }));
     });
     // Maintain backwards compatibility
     $app['console'] = $app->share(function ($app) {
         return $app['nut'];
     });
 }
开发者ID:jkaan,项目名称:timOnlineBolt,代码行数:25,代码来源:NutServiceProvider.php

示例3: before

 /**
  * Middleware function to check whether a user is logged on.
  *
  * @param Request     $request   The Symfony Request
  * @param Application $app       The application/container
  * @param string      $roleRoute An overriding value for the route name in permission checks
  *
  * @return null|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function before(Request $request, Application $app, $roleRoute = null)
 {
     // Start the 'stopwatch' for the profiler.
     $app['stopwatch']->start('bolt.backend.before');
     $route = $request->get('_route');
     // Handle the case where the route doesn't equal the role.
     if ($roleRoute === null) {
         $roleRoute = $route;
     }
     // Sanity checks for doubles in in contenttypes. This has to be done
     // here, because the 'translator' classes need to be initialised.
     $app['config']->checkConfig();
     // If we had to reload the config earlier on because we detected a
     // version change, display a notice.
     if ($app['config']->notify_update) {
         $notice = Trans::__("Detected Bolt version change to <b>%VERSION%</b>, and the cache has been cleared. Please <a href=\"%URI%\">check the database</a>, if you haven't done so already.", ['%VERSION%' => $app->getVersion(), '%URI%' => $app['resources']->getUrl('bolt') . 'dbcheck']);
         $app['logger.system']->notice(strip_tags($notice), ['event' => 'config']);
         $app['logger.flash']->warning($notice);
     }
     // Check for first user set up
     $response = $this->checkFirstUser($app, $route);
     if ($response !== true) {
         return $response;
     }
     // If we're resetting passwords, we have nothing more to check
     if ($route === 'resetpassword' || $route === 'login' || $route === 'postLogin' || $route === 'logout') {
         return null;
     }
     // Confirm the user is enabled or bounce them
     if (($sessionUser = $this->getUser()) && !$sessionUser->getEnabled()) {
         $app['logger.flash']->error(Trans::__('Your account is disabled. Sorry about that.'));
         return $this->redirectToRoute('logout');
     }
     // Check if there's at least one 'root' user, and otherwise promote the current user.
     $this->users()->checkForRoot();
     // Most of the 'check if user is allowed' happens here: match the current route to the 'allowed' settings.
     $authCookie = $request->cookies->get($this->app['token.authentication.name']);
     if ($authCookie === null || !$this->accessControl()->isValidSession($authCookie)) {
         $app['logger.flash']->info(Trans::__('Please log on.'));
         return $this->redirectToRoute('login');
     }
     if (!$this->isAllowed($roleRoute)) {
         $app['logger.flash']->error(Trans::__('You do not have the right privileges to view that page.'));
         return $this->redirectToRoute('dashboard');
     }
     // Stop the 'stopwatch' for the profiler.
     $app['stopwatch']->stop('bolt.backend.before');
     return null;
 }
开发者ID:Boorj,项目名称:bolt,代码行数:58,代码来源:BackendBase.php

示例4: dashboardnews

 /**
  * News.
  */
 public function dashboardnews(Silex\Application $app)
 {
     $news = $app['cache']->fetch('dashboardnews');
     // Two hours.
     $name = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
     // If not cached, get fresh news..
     if ($news == false) {
         $app['log']->add("News: fetch from remote server..", 1);
         $driver = $app['config']->get('general/database/driver', 'sqlite');
         $url = sprintf('http://news.bolt.cm/?v=%s&p=%s&db=%s&name=%s', rawurlencode($app->getVersion()), phpversion(), $driver, base64_encode($name));
         $curlOptions = array('CURLOPT_CONNECTTIMEOUT' => 5);
         // If there's a proxy ...
         if ($app['config']->get('general/httpProxy')) {
             $curlOptions['CURLOPT_PROXY'] = $app['config']->get('general/httpProxy/host');
             $curlOptions['CURLOPT_PROXYTYPE'] = 'CURLPROXY_HTTP';
             $curlOptions['CURLOPT_PROXYUSERPWD'] = $app['config']->get('general/httpProxy/user') . ':' . $app['config']->get('general/httpProxy/password');
         }
         $guzzleclient = new \Guzzle\Http\Client($url, array('curl.options' => $curlOptions));
         try {
             $newsData = $guzzleclient->get("/")->send()->getBody(true);
             $news = json_decode($newsData);
             if ($news) {
                 // For now, just use the most current item.
                 $news = current($news);
                 $app['cache']->save('dashboardnews', $news, 7200);
             } else {
                 $app['log']->add("News: got invalid JSON feed", 1);
             }
         } catch (RequestException $re) {
             $app['log']->add("News: got exception: " . $re->getMessage(), 1);
         }
     } else {
         $app['log']->add("News: get from cache..", 1);
     }
     $body = $app['render']->render('dashboard-news.twig', array('news' => $news));
     return new Response($body, 200, array('Cache-Control' => 's-maxage=3600, public'));
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:40,代码来源:Async.php

示例5: before

 /**
  * Middleware function to check whether a user is logged on.
  *
  * @param Request     $request The Symfony Request
  * @param Application $app     The application/container
  *
  * @return null|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public static function before(Request $request, Application $app)
 {
     // Start the 'stopwatch' for the profiler.
     $app['stopwatch']->start('bolt.backend.before');
     $route = $request->get('_route');
     $app['debugbar'] = true;
     // Sanity checks for doubles in in contenttypes.
     // unfortunately this has to be done here, because the 'translator' classes need to be initialised.
     $app['config']->checkConfig();
     // If we had to reload the config earlier on because we detected a version change, display a notice.
     if ($app['config']->notify_update) {
         $notice = Trans::__("Detected Bolt version change to <b>%VERSION%</b>, and the cache has been cleared. Please <a href=\"%URI%\">check the database</a>, if you haven't done so already.", array('%VERSION%' => $app->getVersion(), '%URI%' => $app['resources']->getUrl('bolt') . 'dbcheck'));
         $app['logger.system']->notice(strip_tags($notice), array('event' => 'config'));
         $app['session']->getFlashBag()->add('info', $notice);
     }
     // Check the database users table exists
     $tableExists = $app['integritychecker']->checkUserTableIntegrity();
     // Test if we have a valid users in our table
     $hasUsers = false;
     if ($tableExists) {
         $hasUsers = $app['users']->hasUsers();
     }
     // If the users table is present, but there are no users, and we're on /bolt/userfirst,
     // we let the user stay, because they need to set up the first user.
     if ($tableExists && !$hasUsers && $route == 'userfirst') {
         return null;
     }
     // If there are no users in the users table, or the table doesn't exist. Repair
     // the DB, and let's add a new user.
     if (!$tableExists || !$hasUsers) {
         $app['integritychecker']->repairTables();
         $app['session']->getFlashBag()->add('info', Trans::__('There are no users in the database. Please create the first user.'));
         return Lib::redirect('userfirst');
     }
     // Confirm the user is enabled or bounce them
     if ($app['users']->getCurrentUser() && !$app['users']->isEnabled() && $route !== 'userfirst' && $route !== 'login' && $route !== 'postLogin' && $route !== 'logout') {
         $app['session']->getFlashBag()->add('error', Trans::__('Your account is disabled. Sorry about that.'));
         return Lib::redirect('logout');
     }
     // Check if there's at least one 'root' user, and otherwise promote the current user.
     $app['users']->checkForRoot();
     // Most of the 'check if user is allowed' happens here: match the current route to the 'allowed' settings.
     if (!$app['users']->isValidSession() && !$app['users']->isAllowed($route)) {
         $app['session']->getFlashBag()->add('info', Trans::__('Please log on.'));
         return Lib::redirect('login');
     } elseif (!$app['users']->isAllowed($route)) {
         $app['session']->getFlashBag()->add('error', Trans::__('You do not have the right privileges to view that page.'));
         return Lib::redirect('dashboard');
     }
     // Stop the 'stopwatch' for the profiler.
     $app['stopwatch']->stop('bolt.backend.before');
     return null;
 }
开发者ID:realitygaps,项目名称:site-v20,代码行数:61,代码来源:Backend.php


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