取得前端控制器实例，只允许实例化一次

@return \wf\app\Application
340101
public static function app()
    {
        if (!self::$instance){
            \wf\app\Benchmark::start();
            self::$instance = new static();
            self::$instance->initRuntime();
            \wf\app\Benchmark::mark('appInstanceAft');
        }

        return self::$instance;
    }
496582
public function getApplication()
    {
        if (file_exists('bootstrap/autoload.php')) {
            require_once 'bootstrap/autoload.php';
        } elseif (file_exists('vendor/autoload.php')) {
            require_once 'vendor/autoload.php';
        }

        // Laravel 5 / Lumen
        $isLaravel = true;
        if (file_exists('bootstrap/app.php')) {
            $this->app = require_once 'bootstrap/app.php';
            if (substr($this->app->version(), 0, 5) === 'Lumen') {
                $isLaravel = false;
            }
        }

        // Laravel 4
        if (file_exists('bootstrap/start.php')) {
            $this->app = require_once 'bootstrap/start.php';
            $this->app->boot();

            return $this->app;
        }

        if (!$this->app) {
            throw new \RuntimeException('Laravel bootstrap file not found');
        }

        $kernel = $this->app->make($isLaravel ? 'Illuminate\Contracts\Http\Kernel' : 'Laravel\Lumen\Application');

        $this->app->afterResolving('auth', function ($auth) {
            $auth->extend('session', function ($app, $name, $config) {
                $provider = $app['auth']->createUserProvider($config['provider']);
                $guard = new \PHPPM\Laravel\SessionGuard($name, $provider, $app['session.store'], null, $app);
                if (method_exists($guard, 'setCookieJar')) {
                    $guard->setCookieJar($this->app['cookie']);
                }
                if (method_exists($guard, 'setDispatcher')) {
                    $guard->setDispatcher($this->app['events']);
                }
                if (method_exists($guard, 'setRequest')) {
                    $guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
                }

                return $guard;
            });
        });

        $app = $this->app;
        $this->app->extend('session.store', function () use ($app) {
            $manager = $app['session'];
            return $manager->driver();
        });

        return $kernel;
    }
720533
protected function getFreshApplication()
    {
        if (method_exists($this->laravel, 'bootstrapPath')) {
            $app = require $this->laravel->bootstrapPath().'/app.php';
        } else {
            $app = require $this->laravel->basePath().'/bootstrap/app.php';
        }

        $app->make(Kernel::class)->bootstrap();

        return $app;
    }
319728
public static function ws()
    {
        if (!isset(self::core()->soap)) {
            //====================================================================//
            // WEBSERVICE INITIALISATION
            //====================================================================//
            // Initialize SOAP WebServices Class
            self::core()->soap = new Webservice();

            //====================================================================//
            // Initialize WebService Configuration Array
            self::core()->soap->setup();

            //====================================================================//
            //  Load Translation File
            self::translator()->load('ws');
        }

        return self::core()->soap;
    }
1163266
public static function loadWfInOne()
    {
        if (static::$isWfInOneLoaded) {
            return true;
        }

        $inOneFile = ROOT_DIR . '/data/temp/wf_main_in_one.php';

        if (is_file($inOneFile) && date('Y-m-d', filemtime($inOneFile)) == date('Y-m-d')) {
            static::$isWfInOneLoaded = include_once $inOneFile;
            return static::$isWfInOneLoaded;
        }

        if (!is_writeable(dirname($inOneFile))) {
            return false;
        }

        // 待合并预加载的类
        $libClasses = [
            // app
            '\\wf\\app\\ApplicationAbstrct',
            '\\wf\\app\\Benchmark',
            '\\wf\\app\\Config',
            '\\wf\\app\\Hook',
            '\\wf\\app\\HookInterface',
            '\\wf\\app\\I18n',
            '\\wf\\app\\Object',
            '\\wf\\app\\ServiceLocator',
            '\\wf\\app\\Session',
            '\\wf\\app\\Version',

            // mvc
            '\\wf\\app\\web\\Application',
            '\\wf\\app\\web\\Controller',
            '\\wf\\app\\web\\Dispatcher',
            '\\wf\\app\\web\\Message',
            '\\wf\\app\\web\\Output',
            '\\wf\\app\\web\\Request',
            '\\wf\\app\\web\\Response',
            '\\wf\\route\\RouteAbstract',
            '\\wf\\route\\adapter\\Simple',
            '\\wf\\model\\Model',
            '\\wf\\model\\Error',
            '\\wf\\template\\EngineInterface',
            '\\wf\\template\\adapter\\Wind',

            // cache
            '\\wf\\cache\\CacheInterface',
            '\\wf\\cache\\CacheAbstract',
            '\\wf\\cache\\adapter\\File',
            '\\wf\\cache\\adapter\\Memcache',
            '\\wf\\cache\\adapter\\Memcached',
            '\\wf\\cache\\adapter\\Redis',

            // db
            '\\wf\\db\\DBInterface',
            '\\wf\\db\\DBAbstract',
            '\\wf\\db\\Finder',
            '\\wf\\db\\QueryBuilder',
            '\\wf\\db\\adapter\\MySQLi',
            '\\wf\\db\\adapter\\PDOMySQL',

            // logger
            '\\wf\\logger\\LoggerInterface',
            '\\wf\\logger\\LoggerAbstract',
            '\\wf\\logger\\adapter\\File',
        ];

        $liteContent = "<?php\n";

        foreach ($libClasses as $class) {
            $file = static::getClassFile($class);
            if (!$file) {
                continue;
            }

            // 类文件源码内容
            $clsCode = file_get_contents($file);
            $clsCode = clearSourceToken($clsCode, [T_COMMENT, T_DOC_COMMENT, T_INCLUDE_ONCE, T_REQUIRE_ONCE]); // 清空注释、require_once、include_once
            $clsCode = substr(trim($clsCode), 5); // 去掉文件开头的 <?php
            $clsCode = trim($clsCode);

            // 去掉php结束符 ？>
            if (substr($clsCode, -2) == '?>'){
                $clsCode = substr($clsCode, 0, -2);
            }

            // 处理namespace
            if(strpos($clsCode,'namespace ') === 0) {
                $clsCode = preg_replace('/namespace\s+(.*?);/','namespace \\1{', $clsCode, 1);
            } else {
                $clsCode = 'namespace {' . $clsCode;
            }
            $clsCode .= '}';

            //$liteContent .= "\n# {$class}\n". $clsCode;
            $liteContent .= $clsCode;
        }

        // 处理空行、空格
        $sourceLineArr = explode("\n", $liteContent);
        foreach ($sourceLineArr as $lineNumber => $lineText) {
            // 去掉前后空格
            $lineText = trim($lineText);

            // 去掉空行
            if (strlen($lineText) == 0) {
                unset($sourceLineArr[$lineNumber]);
                continue;
            }

            // 多个连续空格保留一个
            $lineText = preg_replace("/\s+/", ' ', $lineText);
            $sourceLineArr[$lineNumber] = $lineText;
        }
        $liteContent = implode("\n", $sourceLineArr);

        if(file_put_contents($inOneFile, $liteContent)) {
            static::$isWfInOneLoaded = include_once $inOneFile;
            return static::$isWfInOneLoaded;
        }

        return false;
    }
549083
public static function getApplication()
    {
        restore_error_handler();
        restore_exception_handler();

        $application = new Application('Strata Console Application', '0.1.0');

        $registrar = new ProjectCommandRegistrar($application);
        $registrar->assign();

        $registrar = new MiddlewareCommandRegistrar($application);
        $registrar->assign();

        $registrar = new StrataCommandRegistrar($application);
        $registrar->assign();

        return $application;
    }
847004
public function run()
    {
        $hostInfo = Yii::$app->getRequest()->getHostInfo();
        $controller = $this->controller;
        if (($serviceUrl = $this->serviceUrl) === null) {
            $serviceUrl = $hostInfo . Url::toRoute([$this->getUniqueId(), $this->serviceVar => 1]);
        }
        if (($wsdlUrl = $this->wsdlUrl) === null) {
            $wsdlUrl = $hostInfo . Url::toRoute([$this->getUniqueId()]);
        }
        if (($provider = $this->provider) === null) {
            $provider = $controller;
        }
        $this->_service = $this->createWebService($provider, $wsdlUrl, $serviceUrl);

        if (is_array($this->classMap)) {
            $this->_service->classMap = $this->classMap;
        }
        foreach ($this->serviceOptions as $name => $value) {
            $this->_service->$name = $value;
        }
        if (isset($_GET[$this->serviceVar])) {
            $this->_service->run();
        } else {
            return $this->_service->renderWsdl();
        }
    }
784177
public function exe()
    {

        if ($this->oosql_fromFlag) {
            $this->from();
        }
        if (null != $this->oosql_join) {
            $this->sql($this->oosql_join);
        }
        if (null != $this->oosql_where) {
            $this->sql($this->oosql_where);
        }
        if (null != $this->oosql_in) {
            $this->sql($this->oosql_in);
        }
        if (null != $this->oosql_between) {
            $this->sql($this->oosql_between);
        }
        if (null != $this->oosql_limit) {
            $this->sql(' ' . $this->oosql_limit);
        }
        if (null != $this->oosql_group) {
            $this->sql(' ' . $this->oosql_group);
        }
        if (null != $this->oosql_order) {
            $this->sql(' ' . $this->oosql_order);
        }


        if (count($this->oosql_conValues) !== 0) {

            $return = $this->prep($this->oosql_conValues);
            $this->oosql_conValues = array();
            if ($return === false) {
                $msg = 'Execution failed! ' . $this->sql();
                throw new \Exception($msg, 9811, null);
            }

        } else {

            $this->oosql_stmt = $this->query($this->sql());

        }

        if ($this->oosql_insert) {

            $identity = $this->getEntityObject()->identity();

            if ($identity !== false) {
                if ($this->oosql_driver == 'pgsql') {
                    $identity = $this->oosql_table . '_' . $identity . '_seq';
                }
                $lastID = $this->lastInsertId($identity);

                return $lastID;
            }

        }

        return $this->oosql_stmt;
    }
1067706
public function obj()
    {
        if ($this->obj === null) {
            $formGroup = $this->formGroup();
            if ($formGroup instanceof self) {
                $prop = $formGroup->storageProperty();
                $val  = $formGroup->obj()->propertyValue($prop->ident());

                $this->obj = $prop->structureVal($val, [ 'default_data' => true ]);
                if ($this->obj === null) {
                    $this->obj = clone $prop->structureProto();
                }
            } elseif ($this->form() instanceof ObjectContainerInterface) {
                $this->obj = $this->form()->obj();
            }

            if ($this->obj === null) {
                throw new RuntimeException(sprintf(
                    'The [%1$s] widget has no data model.',
                    static::CLASS
                ));
            }
        }

        return $this->obj;
    }
570147
public function getWorkflowObject()
    {
        if ($this->wfID > 0) {
            $wf = Workflow::getByID($this->wfID);
        } else {
            $wf = new EmptyWorkflow();
        }

        return $wf;
    }
860664
public function getApp(): App
    {
        if (!is_null($this->getTemplateEngine()->getApp())) {
            return $this->getTemplateEngine()->getApp();
        } else {
            throw new RuntimeException('Template engine is not initialized with application');
        }
    }
521279
public function getApplication()
    {
        //load drupals autoload.php, so their classes are available
        if (file_exists('./vendor/autoload.php')) {
            $autoloader = require './vendor/autoload.php';
        } else {
            $autoloader = require '../vendor/autoload.php';
        }

        $sitePath = 'sites/default';

        Settings::initialize('./', $sitePath, $autoloader);

        $app = new DrupalKernel($this->appenv, $autoloader);
        $app->setSitePath($sitePath);

        return $app;
    }
520903
public function getSrv()
    {
        if ($this->srv) {
            return $this->srv;
        }

        $this->srv = new \wf\app\ServiceLocator();

        // 框架组件从配置文件注入服务定位器
        $srvCfgs = cfg('srv');
        if (!$srvCfgs) {
            return $this->srv;
        }

        foreach ($srvCfgs as $srvKey => $srvArgs) {
            if (isset($srvArgs['class'])) {
                $isShare = !isset($srvArgs['srvShare']) || $srvArgs['srvShare'] ? true : false;
                $this->srv->set($srvKey, $srvArgs['class'], [$srvArgs], $isShare);
            } else {
                foreach ($srvArgs as $subKey => $subSrvArgs) {
                    if (empty($subSrvArgs['class'])) {
                        continue;
                    }
                    $isShare = !isset($subSrvArgs['srvShare']) || $subSrvArgs['srvShare'] ? true : false;
                    $this->srv->set("{$srvKey}.{$subKey}", $subSrvArgs['class'], [$subSrvArgs], $isShare);
                }
            }
        }

        return $this->srv;
    }
650629
public function getPrevious()
    {
        $start = clone $this->begin;
        $start->sub(static::getDateInterval());

        return new static($start, $this->factory);
    }
1304555
protected function application()
    {
        // Initialize the Silex Application
        $applicationInitializer = new ApplicationInitializer;

        $app = $applicationInitializer->initialize();

        // Set the default services
        $defaultServices = new \Synapse\Application\Services;
        $defaultServices->register($app);

        // Set the application-specific services
        $appServices = new \Application\Services;
        $appServices->register($app);

        return $app;
    }
1359091
public function get()
	{
		$builder = $this->createBuilder();
		if( !$this->prepare($builder) )
		{
			return $this->complete([]);
		}

		return $this->complete(
			$builder->getConnection()->select(
				$builder->toSql(), $builder->getBindings(), ! $builder->useWritePdo, $this->fetchObject()
			)
		);
	}
226095
public static function getFacadeRoot() {
        $accessor = static::getFacadeAccessor();
        $instance = Application::getInstance()->make($accessor);
        if ($instance == null) {
            throw new Exception('Facade get null for: '.$accessor);
        }
        return $instance;
    }