Example #1
0
 protected function buildKernel()
 {
     $this->kernel = new \AppKernel($this->environment->getType(), $this->environment->isDebug());
     if ($this->loadClassCache) {
         $this->kernel->loadClassCache();
     }
     if (true === (bool) $this->request->server->get('APP_CACHE', false)) {
         $this->kernel = new \AppCache($this->kernel);
     }
 }
Example #2
0
 private function loadSf2()
 {
     global $kernel;
     //@settings_fields('wp_symfony_settings');
     //@do_settings_fields('wp_symfony_settings');
     $path = get_option('symfony2_path');
     $env = get_option('symfony2_env');
     $url = get_option('symfony2_url');
     if (!$this->isValidSymfonyPath($path)) {
         add_action('admin_footer', array($this, 'symfony2_warning'));
         return;
     }
     if ($kernel == null) {
         $loader = (require_once $path . 'app/bootstrap.php.cache');
         require_once $path . 'app/AppKernel.php';
         $kernel = new AppKernel($env, true);
         $kernel->loadClassCache();
         $kernel->boot();
         $this->kernel = $kernel;
         $this->container = $kernel->getContainer();
         if ($this->container->get('session')->isStarted() == false) {
             $this->container->get('session')->start();
         }
         if ($url != null) {
             $this->overloadUrlContext($url);
         }
     } else {
         $this->kernel = $kernel;
         $this->container = $kernel->getContainer();
     }
     $wp_loader = $this->container->get('wordpress.loader');
     $wp_loader->load();
 }
Example #3
0
 public static function bootKernel()
 {
     $loader = (require_once __DIR__ . '/../../../../app/bootstrap.php.cache');
     Debug::enable();
     require_once __DIR__ . '/../../../../app/AppKernel.php';
     $kernel = new \AppKernel('dev', true);
     $kernel->loadClassCache();
     $kernel->boot();
     return $kernel;
 }
Example #4
0
 /**
  * Create a Symfony application
  */
 public function getApplication()
 {
     if (file_exists('./app/AppKernel.php')) {
         require_once './app/AppKernel.php';
     }
     $this->includeAutoload();
     $app = new \AppKernel($this->appenv, false);
     $app->loadClassCache();
     return $app;
 }
function passDataToApplication($url)
{
    $_SERVER['REQUEST_URI'] = modifyUrl($url);
    $_GET['loggedAt'] = getLoggedAt();
    require_once __DIR__ . '/../app/bootstrap.php.cache';
    require_once __DIR__ . '/../app/AppKernel.php';
    $kernel = new AppKernel('prod', false);
    $kernel->loadClassCache();
    $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
    $kernel->handle($request);
}
 public static function runApplication($env, $debug)
 {
     if (self::$_container) {
         throw new \Exception();
     }
     $kernel = new AppKernel($env, $debug);
     $kernel->loadClassCache();
     $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
     \Dev::Bootstrap($kernel, $request);
     $response = $kernel->handle($request);
     $response->send();
     $kernel->terminate($request, $response);
 }
Example #7
0
 /**
  * 每个testXXX执行之前,都会执行此函数,净化数据库。
  * 
  * NOTE: 如果数据库已创建,那么执行清表操作,不重建。
  */
 private function setServiceKernel()
 {
     $kernel = new \AppKernel('test', false);
     $kernel->loadClassCache();
     $kernel->boot();
     Request::enableHttpMethodParameterOverride();
     $request = Request::createFromGlobals();
     $serviceKernel = ServiceKernel::create($kernel->getEnvironment(), $kernel->isDebug());
     $serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
     $serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
     $currentUser = new CurrentUser();
     $currentUser->fromArray(array('id' => 1, 'nickname' => 'admin', 'email' => '*****@*****.**', 'password' => 'admin', 'currentIp' => '127.0.0.1', 'roles' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN', 'ROLE_TEACHER')));
     $serviceKernel->setCurrentUser($currentUser);
     $this->serviceKernel = $serviceKernel;
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     if (!file_exists($this->configuration->get('bootstrap'))) {
         throw new MigraineException($this->configuration->get('bootstrap') . ' file not found');
     }
     if (!file_exists($this->configuration->get('kernel'))) {
         throw new MigraineException($this->configuration->get('kernel') . ' file not found');
     }
     require_once $this->configuration->get('bootstrap');
     require_once $this->configuration->get('kernel');
     $kernel = new \AppKernel($this->configuration->get('env'), $this->configuration->get('debug'));
     $kernel->loadClassCache();
     $kernel->boot();
     $class = get_class($kernel);
     $this->version = $class::VERSION;
     $this->container = $kernel->getContainer();
 }
Example #9
0
 public function initialize(\Boris\Boris $boris, $dir)
 {
     parent::initialize($boris, $dir);
     if (is_file("{$dir}/app/bootstrap.php.cache")) {
         require "{$dir}/app/bootstrap.php.cache";
     } else {
         require "{$dir}/app/autoload.php";
     }
     require_once "{$dir}/app/AppKernel.php";
     $kernel = new \AppKernel('dev', true);
     $kernel->loadClassCache();
     $kernel->boot();
     $boris->onStart(function ($worker, $vars) use($kernel) {
         $worker->setLocal('kernel', $kernel);
         $worker->setLocal('container', $kernel->getContainer());
     });
 }
Example #10
0
 public function authenticate(MOXMAN_Auth_User $user)
 {
     $config = MOXMAN::getConfig();
     // Load environment and session logic
     if (!$this->isSessionLoaded) {
         $kernel = new AppKernel($config->get("SymfonyAuthenticator.environment", "prod"), false);
         $kernel->loadClassCache();
         $request = Request::createFromGlobals();
         $kernel->handle($request);
         $this->isSessionLoaded = true;
     }
     // Get all session data
     $session = new Session();
     $session = $session->all();
     // Check logged in key
     $loggedInKey = $config->get("SymfonyAuthenticator.logged_in_key", "isLoggedIn");
     $sessionValue = isset($session[$loggedInKey]) ? $session[$loggedInKey] : false;
     if (!$sessionValue || $sessionValue === "false") {
         return false;
     }
     // Extend config with session prefixed sessions
     $sessionConfig = array();
     $configPrefix = $config->get("SymfonyAuthenticator.config_prefix", "moxiemanager");
     if ($configPrefix) {
         foreach ($session as $key => $value) {
             if (strpos($key, $configPrefix) === 0) {
                 $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value;
             }
         }
     }
     // Extend the config with the session config
     $config->extend($sessionConfig);
     // Replace ${user} with all config items
     $key = $config->get("SessionAuthenticator.user_key", "user");
     if ($key && isset($session[$key])) {
         $config->replaceVariable("user", $session[$key]);
         $user->setName($session[$key]);
     }
     return true;
 }
Example #11
0
 public function registerSymfonyKernel()
 {
     $kernel = self::$kernel;
     $this[self::SYMFONY_KERNEL] = $this->share(function () use($kernel) {
         if ($kernel) {
             return $kernel;
         }
         /**
          * @todo add support for setting environment dynamically
          * Since this container does not use much environment dependent
          * variables it doesn't really matter for now.
          */
         $environment = getenv('SYMFONY_ENV');
         if (!$environment) {
             $environment = 'prod';
         }
         $kernel = new AppKernel($environment, true);
         $kernel->loadClassCache();
         $kernel->boot();
         Request::createFromGlobals();
         return $kernel;
     });
 }
Example #12
0
 /**
  * This is the same as invoke(), but it does *not* include exception
  * handling.
  *
  * @param array $args
  *   The parts of the URL which identify the intended CiviCRM page
  *   (e.g. array('civicrm', 'event', 'register')).
  * @return string
  *   HTML. For non-HTML content, invoke() may call print() and exit().
  */
 public static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return NULL;
     }
     // CRM-15901: Turn off PHP errors display for all ajax calls
     if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
         ini_set('display_errors', 0);
     }
     if (!defined('CIVICRM_SYMFONY_PATH')) {
         // Traditional Civi invocation path
         self::hackMenuRebuild($args);
         // may exit
         self::init($args);
         self::hackStandalone($args);
         $item = self::getItem($args);
         return self::runItem($item);
     } else {
         // Symfony-based invocation path
         require_once CIVICRM_SYMFONY_PATH . '/app/bootstrap.php.cache';
         require_once CIVICRM_SYMFONY_PATH . '/app/AppKernel.php';
         $kernel = new AppKernel('dev', TRUE);
         $kernel->loadClassCache();
         $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals());
         if (preg_match(':^text/html:', $response->headers->get('Content-Type'))) {
             // let the CMS handle the trappings
             return $response->getContent();
         } else {
             $response->send();
             exit;
         }
     }
 }
Example #13
0
<?php

use Symfony\Component\HttpFoundation\Request;
$loader = (require __DIR__ . '/../autoload.php');
require_once __DIR__ . '/kernel.php';
$app = new AppKernel('prod', false);
$app->loadClassCache();
$app->handle(Request::createFromGlobals())->send();
Example #14
0
<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache('classes', '.php.cache');
$kernel = new AppCache($kernel);
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Example #15
0
<?php

//multisite
define('MULTISITE', 'awesome_SSM');
require_once __DIR__ . '/multisite.php';
//multisite.end
use Symfony\Component\HttpFoundation\Request;
/**
 * @var Composer\Autoload\ClassLoader
 */
$loader = (require __DIR__ . '/../app/autoload.php');
include_once __DIR__ . '/../var/bootstrap.php.cache';
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
/*
$apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
*/
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache(MULTISITE_DOMAIN);
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
 protected static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return;
     }
     // CRM-15901: Turn off PHP errors display for all ajax calls
     if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
         ini_set('display_errors', 0);
     }
     if (!defined('CIVICRM_SYMFONY_PATH')) {
         try {
             // Traditional Civi invocation path
             self::hackMenuRebuild($args);
             // may exit
             self::init($args);
             self::hackStandalone($args);
             $item = self::getItem($args);
             return self::runItem($item);
         } catch (CRM_Core_EXCEPTION $e) {
             $params = $e->getErrorData();
             $message = $e->getMessage();
             if (isset($params['legacy_status_bounce'])) {
                 //@todo remove this- see comments on
                 //https://github.com/eileenmcnaughton/civicrm-core/commit/ae686b09e2c987091612bb25ba0a58e520a203e7
                 CRM_Core_Error::statusBounce($params['message']);
             } else {
                 $session = CRM_Core_Session::singleton();
                 $session->setStatus($message, CRM_Utils_Array::value('message_title', $params), CRM_Utils_Array::value('message_type', $params, 'error'));
                 // @todo remove this code - legacy redirect path is an interim measure for moving redirects out of BAO
                 // to somewhere slightly more acceptable. they should not be part of the exception class & should
                 // be managed @ the form level - if you find a form that is triggering this piece of code
                 // you should log a ticket for it to be removed with details about the form you were on.
                 if (!empty($params['legacy_redirect_path'])) {
                     if (CRM_Utils_System::isDevelopment()) {
                         // here we could set a message telling devs to log it per above
                     }
                     CRM_Utils_System::redirect($params['legacy_redirect_path'], $params['legacy_redirect_query']);
                 }
             }
         } catch (Exception $e) {
             // Recall: CRM_Core_Config is initialized before calling CRM_Core_Invoke
             $config = CRM_Core_Config::singleton();
             return CRM_Core_Error::handleUnhandledException($e);
             /*
                     if ($config->backtrace) {
                       return CRM_Core_Error::formatHtmlException($e);
                     } else {
                      // TODO
                     }*/
         }
     } else {
         // Symfony-based invocation path
         require_once CIVICRM_SYMFONY_PATH . '/app/bootstrap.php.cache';
         require_once CIVICRM_SYMFONY_PATH . '/app/AppKernel.php';
         $kernel = new AppKernel('dev', true);
         $kernel->loadClassCache();
         $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals());
         // $response->send();
         return $response->getContent();
     }
 }
 /**
  * Boot kernel
  *
  * @param string $env
  *
  * @return AppKernel
  */
 protected function bootKernel($env)
 {
     $kernel = new AppKernel($env, $env === 'dev');
     $kernel->loadClassCache();
     $kernel->boot();
     return $kernel;
 }
 private function getModuleDataUpdater()
 {
     static $moduleDataUpdater;
     global $kernel;
     if (null === $moduleDataUpdater) {
         if (is_null($kernel)) {
             require_once _PS_ROOT_DIR_ . '/app/AppKernel.php';
             $kernel = new AppKernel(_PS_MODE_DEV_ ? 'dev' : 'prod', _PS_MODE_DEV_);
             $kernel->loadClassCache();
             $kernel->boot();
         }
         $moduleDataUpdater = $kernel->getContainer()->get('prestashop.core.module.updater');
     }
     return $moduleDataUpdater;
 }
Example #19
0
<?php

use Symfony\Component\HttpFoundation\Request;
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
 /**
  * Load kernel
  *
  * @param string $env
  */
 protected function bootKernel($env = 'dev')
 {
     $kernel = new AppKernel($env, $env === 'dev');
     $kernel->loadClassCache();
     $kernel->boot();
     $this->container = $kernel->getContainer();
 }