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


PHP Environment::getInstance方法代码示例

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


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

示例1: __construct

 private function __construct()
 {
     //获取环境参数
     $this->env = Environment::getInstance()->get();
     //HTTP request headers (retains HTTP_ prefix to match $_SERVER)
     $this->headers = Headers::extract($_SERVER);
 }
开发者ID:shampeak,项目名称:ap.so,代码行数:7,代码来源:ConfigManager.php

示例2: run

 /**
  * Initialize app
  */
 public function run()
 {
     if (!isset($this->container['env']) || is_null($this->container['env'])) {
         $this->container['env'] = Environment::getInstance();
     }
     if (!isset($this->container['akismet']) || is_null($this->container['akismet'])) {
         // Initialize Akismet
         $connector = new \Riv\Service\Akismet\Connector\Curl();
         $this->container['akismet'] = new \Riv\Service\Akismet\Akismet($connector);
     }
     if (!isset($this->container['email']) || is_null($this->container['email'])) {
         // Initialize email
         $transport = \Swift_MailTransport::newInstance();
         $this->container['email'] = \Swift_Mailer::newInstance($transport);
     }
     if (!isset($this->container['cache']) || is_null($this->container['cache'])) {
         if (defined('CACHE_FOLDER')) {
             $driver = new \Stash\Driver\FileSystem(array('path' => CACHE_FOLDER));
         } else {
             $driver = new \Stash\Driver\FileSystem();
         }
         $this->container['cache'] = new \Stash\Pool($driver);
     }
     if (!isset($this->container['currentuser']) || is_null($this->container['currentuser'])) {
         $this->container['currentuser'] = new CurrentUser();
     }
     if (!isset($this->container['db']) || !$this->container['db'] instanceof \ezSQL_mysqli) {
         throw new \Exception('No db setup');
     }
     if (!isset($this->container['safesql']) || !$this->container['safesql'] instanceof \SafeSQL_MySQLi) {
         throw new \Exception('No safesql setup');
     }
 }
开发者ID:felixonline,项目名称:core,代码行数:36,代码来源:App.php

示例3: renderPreviewView

 /**
  * @param DC_General $dc
  */
 public function renderPreviewView(EnvironmentInterface $environment)
 {
     /** @var EventDispatcher $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('avisota_message_preview'));
     $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('orm_avisota_message'));
     $input = \Input::getInstance();
     $messageRepository = EntityHelper::getRepository('Avisota\\Contao:Message');
     $messageId = IdSerializer::fromSerialized($input->get('id') ? $input->get('id') : $input->get('pid'));
     $message = $messageRepository->find($messageId->getId());
     if (!$message) {
         $environment = \Environment::getInstance();
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, new RedirectEvent(preg_replace('#&(act=preview|id=[a-f0-9\\-]+)#', '', $environment->request)));
     }
     $modules = new \StringBuilder();
     /** @var \Avisota\Contao\Message\Core\Send\SendModuleInterface $module */
     foreach ($GLOBALS['AVISOTA_SEND_MODULE'] as $className) {
         $class = new \ReflectionClass($className);
         $module = $class->newInstance();
         $modules->append($module->run($message));
     }
     $context = array('message' => $message, 'modules' => $modules);
     $template = new \TwigTemplate('avisota/backend/preview', 'html5');
     return $template->parse($context);
 }
开发者ID:Ainschy,项目名称:contao-message,代码行数:28,代码来源:Preview.php

示例4: authenticateBackendUser

 protected static function authenticateBackendUser()
 {
     $objUser = self::getUser();
     // work around as the TL_PATH constant is set after this routine has been run.
     // if this is not in place, BackendUser::authenticate() will redirect us to
     // http://domain.tldtl_path/contao/index.php
     // if no user is properly logged in (note the missing slash in the middle right after .tld).
     // We also have to fix up the "script" parameter, as this one will otherwise try to redirect from
     // "contao/index.php" to "/contao/index.php" therefore creating an infinite redirect loop.
     $Env = Environment::getInstance();
     // issue #66 - contao/install.php is not working anymore. Thanks to Stefan Lindecke (@lindesbs)
     if (strpos($Env->request, "install.php") !== false) {
         return;
     }
     // Fix issue #397 - the security patch rendered our redirect method non working (websitePath can now be null).
     $path = constant('TL_PATH') ?: $GLOBALS['TL_CONFIG']['websitePath'];
     $Env->base = $Env->url . $path . '/';
     $Env->script = preg_replace('/^' . preg_quote($path, '/') . '\\/?/i', '', $Env->scriptName);
     // Bugfix: If the user is not authenticated, contao will redirect to contao/index.php
     // But in this moment the TL_PATH is not defined, so the $this->Environment->request
     // generate a url without replacing the basepath(TL_PATH) with an empty string.
     if (!defined(TL_PATH)) {
         define('TL_PATH', $path);
     }
     // TODO: double, triple and quadro check that this is really safe context here.
     $objUser->authenticate();
     // restore initial settings.
     $Env->base = null;
     $Env->script = null;
 }
开发者ID:amenk,项目名称:MetaModels-core,代码行数:30,代码来源:MetaModelBackend.php

示例5: load

    public function load(AbstractMetaModel $environment_metamodel, array $filters = NULL) {
        LogHelper::log_notice(t('Loading Environment Meta Model from settings.php ...'));

        $datasourceCount = 0;

        $configurationDataSources = Environment::getInstance()->getConfigurationSection('Data Sources');
        if (isset($configurationDataSources)) {
            foreach ($configurationDataSources as $namespace => $sourceDataSources) {
                foreach ($sourceDataSources as $datasourceName => $sourceDataSource) {
                    $datasourceName = NameSpaceHelper::resolveNameSpace($namespace, $datasourceName);

                    $datasource = new DataSourceMetaData();
                    $datasource->name = $datasourceName;
                    $datasource->initializeFrom($sourceDataSource);
                    // it is possible that configuration contains 'readonly' property. We need to honor it
                    // ... and only when it is not set we mark the data source as read only
                    if (!isset($datasource->readonly)) {
                        $datasource->readonly = TRUE;
                    }

                    $environment_metamodel->registerDataSource($datasource);

                    $datasourceCount++;
                }
            }
        }

        LogHelper::log_info(t('Processed @datasourceCount data sources', array('@datasourceCount' => $datasourceCount)));
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:29,代码来源:SettingsPHP_EnvironmentMetaModelLoader.php

示例6: constx

 public function constx($value)
 {
     $symbol = "__?__";
     $this->symbolManager->setSymbol($symbol);
     Environment::getInstance()->attach($symbol, $value);
     return $this;
 }
开发者ID:ntwalibas,项目名称:contracts,代码行数:7,代码来源:Predicates.php

示例7: intializeObjectStack

 /**
  * Initialize object stack.
  *
  * @return void
  */
 public static function intializeObjectStack()
 {
     \Config::getInstance();
     \Environment::getInstance();
     \Input::getInstance();
     static::getUser();
     \Database::getInstance();
 }
开发者ID:contao-bootstrap,项目名称:core,代码行数:13,代码来源:Contao.php

示例8: createPublicEmptyRecipient

 public function createPublicEmptyRecipient(CreatePublicEmptyRecipientEvent $event)
 {
     if ($event->getRecipient()) {
         return;
     }
     $environment = \Environment::getInstance();
     $event->setRecipient(new MutableRecipient('noreply@' . $environment->host));
 }
开发者ID:Ainschy,项目名称:contao-core,代码行数:8,代码来源:EventSubscriber.php

示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->handlerConfigurations = module_invoke_all('dc_cache');
     // preparing default value for cache entry expiration time
     $cacheConfigurationSection = Environment::getInstance()->getConfigurationSection('Cache');
     if (isset($cacheConfigurationSection['Entry Expiration']['Default'])) {
         AbstractCacheHandler::$DEFAULT__ENTRY_EXPIRATION = $cacheConfigurationSection['Entry Expiration']['Default'];
     }
 }
开发者ID:ecs-hk,项目名称:Checkbook,代码行数:10,代码来源:DefaultCacheFactory.php

示例10: execute

 protected function execute(Message $message, \BackendUser $user)
 {
     global $container;
     /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $input = \Input::getInstance();
     $user = $input->get('recipient_user');
     /** @var \Doctrine\DBAL\Connection $connection */
     $connection = $container['doctrine.connection.default'];
     $queryBuilder = $connection->createQueryBuilder();
     /** @var \Doctrine\DBAL\Statement $statement */
     $statement = $queryBuilder->select('u.*')->from('tl_user', 'u')->where('id=:id')->setParameter(':id', $user)->execute();
     $userData = $statement->fetch();
     if (!$userData) {
         $_SESSION['AVISOTA_SEND_PREVIEW_TO_USER_EMPTY'] = true;
         header('Location: ' . $url);
         exit;
     }
     $idSerializer = new IdSerializer();
     $idSerializer->setDataProviderName('orm_avisota_message');
     $idSerializer->setId($message->getId());
     $pidSerializer = new IdSerializer();
     $pidSerializer->setDataProviderName('orm_avisota_message_category');
     $pidSerializer->setId($message->getCategory()->getId());
     $environment = Environment::getInstance();
     $url = sprintf('%scontao/main.php?do=avisota_newsletter&table=orm_avisota_message&act=preview&id=%s&pid=%s', $environment->base, $idSerializer->getSerialized(), $pidSerializer->getSerialized());
     if ($message->getCategory()->getViewOnlinePage()) {
         $event = new LoadLanguageFileEvent('avisota_message');
         $eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event);
         $viewOnlineLink = sprintf($GLOBALS['TL_LANG']['avisota_message']['viewOnline'], $url);
     } else {
         $viewOnlineLink = false;
     }
     $event = new \Avisota\Contao\Core\Event\CreateFakeRecipientEvent($message);
     $eventDispatcher->dispatch(\Avisota\Contao\Core\CoreEvents::CREATE_FAKE_RECIPIENT, $event);
     $recipient = $event->getRecipient();
     $recipient->setEmail($userData['email']);
     $additionalData = array('view_online_link' => $viewOnlineLink);
     /** @var \Avisota\Contao\Message\Core\Renderer\MessageRendererInterface $renderer */
     $renderer = $container['avisota.message.renderer'];
     $messageTemplate = $renderer->renderMessage($message);
     $messageMail = $messageTemplate->render($recipient, $additionalData);
     /** @var \Avisota\Transport\TransportInterface $transport */
     $transport = $GLOBALS['container']['avisota.transport.' . $message->getQueue()->getTransport()->getId()];
     $transport->send($messageMail);
     $event = new \ContaoCommunityAlliance\Contao\Bindings\Events\System\LoadLanguageFileEvent('avisota_message_preview');
     $eventDispatcher->dispatch(\ContaoCommunityAlliance\Contao\Bindings\ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event);
     $_SESSION['TL_CONFIRM'][] = sprintf($GLOBALS['TL_LANG']['avisota_message_preview']['previewSend'], $recipient->getEmail());
     header('Location: ' . $url);
     exit;
 }
开发者ID:Ainschy,项目名称:contao-message,代码行数:51,代码来源:send_preview_to_user.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     Configure::write('debug', 0);
     $this->Environment = Environment::getInstance();
     $envs = array(array('name' => 'staging', 'params' => array('SERVER_NAME' => 'example.tld'), 'config' => array('debug' => 2, 'Session.name' => 'staging-session', 'security' => 'low'), 'callable' => null), array('name' => 'production', 'params' => array('SERVER_NAME' => 'production.tld', 'SERVER_ADDR' => '8.8.8.8'), 'config' => array('debug' => 1, 'Session.name' => 'production-session'), 'callable' => null), array('name' => 'preproduction', 'params' => array('SERVER_NAME' => array('preproduction.tld', 'preprod.local')), 'config' => array('debug' => 1, 'Session.name' => 'preproduction-session'), 'callable' => function () {
         Configure::write('Environment.callback', true);
     }), array('name' => 'dev1', 'params' => false, 'config' => array(), 'callable' => null), array('name' => 'dev2', 'params' => array('is_bool' => 'Hello, World!'), 'config' => array(), 'callable' => array()));
     foreach ($envs as $env) {
         Environment::configure($env['name'], $env['params'], $env['config'], $env['callable']);
     }
     Configure::read('Environment.setup', false);
     $_SERVER['CAKE_ENV'] = null;
 }
开发者ID:superstarrajini,项目名称:cakepackages,代码行数:14,代码来源:EnvironmentTest.php

示例12: initializeContaoObjectStack

 /**
  * This initializes the Contao Singleton object stack as it must be,
  * when using singletons within the config.php file of an Extension.
  *
  * @return void
  */
 protected static function initializeContaoObjectStack()
 {
     // all of these getInstance calls are neccessary to keep the instance stack intact
     // and therefore prevent an Exception in unknown on line 0.
     // Hopefully this will get fixed with Contao Reloaded or Contao 3.
     Config::getInstance();
     Environment::getInstance();
     Input::getInstance();
     // request token became available in 2.11
     if (version_compare(TL_VERSION, '2.11', '>=')) {
         RequestToken::getInstance();
     }
     self::getUser();
     Database::getInstance();
 }
开发者ID:amenk,项目名称:MetaModels-core,代码行数:21,代码来源:MetaModelFactory.php

示例13: addLinksToTemplate

 public function addLinksToTemplate(\FrontendTemplate $objTemplate, \stdClass $objConfig, $intParent)
 {
     $objTemplate->LinksToUs = array();
     $objEnvironment = \Environment::getInstance();
     $folder = \FilesModel::findByPk($objConfig->bannerFolder);
     $bannerFolder = TL_ROOT . "/" . $folder->path;
     $handle = opendir($bannerFolder);
     while ($file = readdir($handle)) {
         $filelist[] = $file;
     }
     asort($filelist);
     $count = 0;
     if ($objConfig->template == '') {
         $objConfig->template = 'links2us_banner';
     }
     $objEntry = new \FrontendTemplate($objConfig->template);
     while (list($a, $file) = each($filelist)) {
         if (exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_GIF || exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_JPEG || exif_imagetype($bannerFolder . "/" . $file) == IMAGETYPE_PNG) {
             if ($objConfig->bannerSize) {
                 $dimension = getimagesize($bannerFolder . "/" . $file);
                 $dimensionXL = $GLOBALS['TL_LANG']['MSC']['size'] . $dimension[0] . "x" . $dimension[1];
                 $bannerInfo = $dimensionXL;
             }
             if ($objConfig->bannerByte) {
                 $filesize = filesize($bannerFolder . "/" . $file);
                 $filesize = number_format($filesize / 1024, 2);
                 $filesizeXL = $GLOBALS['TL_LANG']['MSC']['bytes'] . $filesize . "kb";
                 $bannerInfo = $filesizeXL;
             }
             if ($objConfig->bannerSize && $objConfig->bannerByte) {
                 $bannerInfo = $dimensionXL . " ( " . $filesize . "kb ) ";
             }
             $objEntry->bannerSRC = $objEnvironment->base . $folder->path . "/" . $file;
             $objEntry->bCount = $count;
             $objEntry->toClipboard = $objConfig->toClipboard;
             $objEntry->bannerInfo = $bannerInfo;
             $arrLinkBanners[] = $objEntry->parse();
             ++$count;
         }
     }
     $objTemplate->backLink = $objConfig->backLink;
     $objTemplate->LinkBanners = $arrLinkBanners;
     $objTemplate->color = ' ' . $objConfig->modColor;
     $objTemplate->TeaserText = $objConfig->TeaserText;
     $objTemplate->displayTextLink = $objConfig->displayTextLink;
     $objTemplate->CopytoClip = $objConfig->toClipboard;
     $objTemplate->backInfo = '<p class="backlink">Links2Us by <a href="http://jedo-style.de">jedo Style</a></p>';
 }
开发者ID:jedostyle,项目名称:contao-links2us,代码行数:48,代码来源:LinksToUs.php

示例14: initialize

 /**
  * Initialize the composer environment.
  */
 public static function initialize()
 {
     if (version_compare(PHP_VERSION, COMPOSER_MIN_PHPVERSION, '<')) {
         return;
     }
     if (TL_MODE == 'BE') {
         $GLOBALS['TL_HOOKS']['loadLanguageFile']['composer'] = array('ContaoCommunityAlliance\\Contao\\Composer\\Client', 'disableOldClientHook');
         $input = \Input::getInstance();
         if ($input->get('do') == 'repository_manager') {
             $environment = \Environment::getInstance();
             header('Location: ' . $environment->base . 'contao/main.php?do=composer');
             exit;
         }
     }
     static::registerVendorClassLoader();
 }
开发者ID:tim-bec,项目名称:composer-client,代码行数:19,代码来源:Runtime.php

示例15: __construct

 private function __construct($entrance)
 {
     //创建config
     $this->AppDefaultConfig = $this->AppDefaultConfig();
     //入口配置
     $this->ent = $entrance;
     //获取环境参数
     $this->env = Environment::getInstance()->get();
     //HTTP request headers (retains HTTP_ prefix to match $_SERVER)
     $this->headers = Headers::extract($_SERVER);
     //获取app 配置
     $file = $this->ent['CONF_FILE'] = $this->ent['CONF_FILE'] ?: 'Conf.php';
     $this->app = G($this->ent['APP_PATH'] . $file);
     //所有配置的模块列表
     $modulelist = $this->ent['modulelist'] ?: $this->app['modulelist'];
     $modulelist = is_array($modulelist) ? $modulelist : [];
     $this->modulelist = array_keys($modulelist);
 }
开发者ID:shampeak,项目名称:_m.so,代码行数:18,代码来源:ConfigManager.php


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