• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Nette\Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: dataFormatTemplateFiles

	public function dataFormatTemplateFiles()
	{
		$context = \Nette\Environment::getContext();
		return array(
			array('Nella\Foo\Bar::render', array(
				$context->params['appDir'] . "/Foo/Bar.latte",
				$context->params['appDir'] . "/templates/Foo/Bar.latte",
				__DIR__ . "/Foo/Bar.latte",
				__DIR__ . "/templates/Foo/Bar.latte",
				NELLA_FRAMEWORK_DIR . "/Foo/Bar.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo/Bar.latte",
			)),
			array('Nella\Foo\Bar::renderBaz', array(
				$context->params['appDir'] . "/Foo/Bar.baz.latte",
				$context->params['appDir'] . "/templates/Foo/Bar.baz.latte",
				__DIR__ . "/Foo/Bar.baz.latte",
				__DIR__ . "/templates/Foo/Bar.baz.latte",
				NELLA_FRAMEWORK_DIR . "/Foo/Bar.baz.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo/Bar.baz.latte",
			)),
			array('Nella\Foo::renderBarBaz', array(
				$context->params['appDir'] . "/Foo.barBaz.latte",
				$context->params['appDir'] . "/templates/Foo.barBaz.latte",
				__DIR__ . "/Foo.barBaz.latte",
				__DIR__ . "/templates/Foo.barBaz.latte",
				NELLA_FRAMEWORK_DIR . "/Foo.barBaz.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo.barBaz.latte",
			)),
		);
	}
开发者ID:norbe,项目名称:framework,代码行数:30,代码来源:ControlTest.php


示例2: getCache

 /**
  * @return Cache
  */
 protected static function getCache()
 {
     if (self::$cache === NULL) {
         self::$cache = \Nette\Environment::getService('webloader.cache');
     }
     return self::$cache;
 }
开发者ID:lohini,项目名称:webloader,代码行数:10,代码来源:PreFileFilter.php


示例3: match

 /**
  * @param Nette\Web\IHttpRequest $httpRequest
  * @return Nette\Application\PresenterRequest|NULL
  */
 public function match(\Nette\Http\IRequest $httpRequest)
 {
     /** @var $appRequest \Nette\Application\Request */
     $appRequest = parent::match($httpRequest);
     // doplněno: pokud match vrátí NULL, musíme také vrátit NULL
     if (!$appRequest) {
         return $appRequest;
     }
     // musím si přeložit host, kvůli localhostu to není dané
     if (strpos($httpRequest->url->host, '.localhost') !== false && !\Nette\Environment::isProduction()) {
         // jsme na localhostu
         $host = substr($httpRequest->url->host, 0, strripos($httpRequest->url->host, '.localhost'));
         // musíme si doménu osamostatnit od .localhost
         $host = str_replace('_', '.', $host);
         // na lokálu mám místo teček podtržení
     } else {
         // jsme na produkci
         $host = $httpRequest->url->host;
     }
     // zkusím zda je soubor již v cache
     if (is_file(WEB_DIR . '/' . $host . '/cache' . $httpRequest->url->path)) {
         return new Nette\Application\Request('Frontend', 'POST', array('action' => 'cache', 'file' => WEB_DIR . '/' . $host . '/cache' . $httpRequest->url->path));
     }
     /*
     if ($params = $this->doFilterParams($this->getRequestParams($appRequest), $appRequest, self::WAY_IN)) {
     	return $this->setRequestParams($appRequest, $params);
     }
     */
     // $pages = $this->context->createPages();
     $data = array('action' => 'default');
     return new Nette\Application\Request('Frontend', 'POST', $data);
 }
开发者ID:pemasat,项目名称:nixla,代码行数:36,代码来源:DynamicRoute.php


示例4: renderShow

 public function renderShow($id)
 {
     $service = new TripService($this->entityManager);
     $trip = $service->find($id);
     $this->template->trip = $trip;
     try {
         $eventService = new EventService();
         $config = Environment::getConfig('api');
         $events = $eventService->getEvents($trip->arrival, new DateTime(), new EventfulMapper($config->eventfulUser, $config->eventfulPassword, $config->eventfulKey));
         $this->template->events = $events;
     } catch (InvalidStateException $e) {
         $this->template->events = array();
     }
     $articleService = new ArticleService($this->entityManager);
     $this->template->article = $articleService->buildArticle($trip->arrival, new ArticleWikipediaMapper());
     try {
         $airportMapper = new AirportTravelMathMapper();
         $airportService = new AirportService();
         $locationService = new LocationService();
         $coordinates = $locationService->getCoordinates($trip->getDeparture());
         $from = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $coordinates = $locationService->getCoordinates($trip->getArrival());
         $to = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $flightMapper = new FlightKayakMapper();
         $flightService = new FlightService($this->entityManager);
         $depart_date = new DateTime('now');
         $return_date = new DateTime('+1 week');
         $this->template->flights = $flightService->buildFlights($flightMapper, $from, $to, $depart_date, $return_date, '1', 'e', 'n');
     } catch (FlightException $e) {
         $this->template->flightsError = "Connection with search system <a href='http://kayak.com'>Kayak</a> failed.";
     } catch (AirportException $e) {
         $this->template->flightsError = $e->getMessage();
     }
 }
开发者ID:jff15,项目名称:travelbot,代码行数:34,代码来源:TripPresenter.php


示例5: handleUploads

 /**
  * Handles uploaded files
  * forwards it to model
  */
 public function handleUploads()
 {
     // Iterujeme nad přijatými soubory
     foreach (\Nette\Environment::getHttpRequest()->getFiles() as $name => $controlValue) {
         // MFU vždy posílá soubory v této struktuře:
         //
         // array(
         //	"token" => "blablabla",
         //	"files" => array(
         //		0 => HttpUploadedFile(...),
         //		...
         //	)
         // )
         $isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($_POST[$name]["token"]));
         if ($isFormMFU) {
             $token = $_POST[$name]["token"];
             foreach ($controlValue["files"] as $file) {
                 self::processFile($token, $file);
             }
         }
         // soubory, které se netýkají MFU nezpracujeme -> zpracuje si je standardním způsobem formulář
     }
     return true;
     // Skip all next
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:29,代码来源:MFUUIHTML4SingleUpload.php


示例6: setLocale

 public function setLocale($lang)
 {
     switch ($lang) {
         case 'en':
             setlocale(LC_ALL, 'en_EN.UTF8', 'en_EN.UTF-8', 'en_EN	');
             break;
         case 'cs':
         default:
             setlocale(LC_ALL, 'cs_CZ.UTF8', 'cs_CZ.UTF-8', 'cs_CZ');
     }
     $this->lang = $lang;
     $cache = Environment::getCache();
     $cacheName = 'getText-' . $this->lang;
     if (isset($cache[$cacheName])) {
         $this->dictionary = unserialize($cache[$cacheName]);
     } else {
         $dict = new Model\Dictionary('utils/translate');
         try {
             $this->dictionary = $dict->getPairs($this->lang);
             $cache->save($cacheName, serialize((array) $this->dictionary), array('expire' => time() + 60 * 30, 'refresh' => TRUE, 'tags' => array('dictionary')));
         } catch (DibiException $e) {
             echo $e;
         }
     }
 }
开发者ID:soundake,项目名称:pd,代码行数:25,代码来源:Translate.php


示例7: renderBlueScreen

 /**
  * Renders blue screen.
  * @param  \Exception
  * @return void
  */
 public static function renderBlueScreen(\Exception $exception)
 {
     if (class_exists('Nette\\Environment', FALSE)) {
         $application = Environment::getContext()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getContext()->getService('Nette\\Application\\Application') : NULL;
     }
     require __DIR__ . '/templates/bluescreen.phtml';
 }
开发者ID:JanTvrdik,项目名称:nette,代码行数:12,代码来源:DebugHelpers.php


示例8: log_write

function log_write($data, FileDownload $file, IDownloader $downloader)
{
    $cache = Environment::getCache("FileDownloader/log");
    $log = array();
    $tid = (string) $file->getTransferId();
    if (!isset($cache["registry"])) {
        $cache["registry"] = array();
    }
    $reg = $cache["registry"];
    $reg[$tid] = true;
    $cache["registry"] = $reg;
    if (isset($cache[$tid])) {
        $log = $cache[$tid];
    }
    Debugger::fireLog("Data: " . $data . "; " . $downloader->end);
    $data = $data . ": " . Helpers::bytes($file->transferredBytes) . " <->; ";
    if ($downloader instanceof AdvancedDownloader and $downloader->isInitialized()) {
        $data .= "position: " . Helpers::bytes($downloader->position) . "; ";
        //$data .= "length: ".Helpers::bytes($downloader->length)."; ";
        $data .= "http-range: " . Helpers::bytes($downloader->start) . "-" . Helpers::bytes($downloader->end) . "; ";
        $data .= "progress (con: " . round($file->transferredBytes / $downloader->end * 100) . "% X ";
        $data .= "file: " . round($downloader->position / $file->sourceFileSize * 100) . "%)";
    }
    $log[] = $data;
    $cache[$tid] = $log;
}
开发者ID:jkuchar,项目名称:FileDownloader-example,代码行数:26,代码来源:example_library.php


示例9: createTemplate

 /**
  * @return Nette\Templates\ITemplate
  */
 protected function createTemplate()
 {
     $template = new Nette\Templates\FileTemplate();
     $presenter = $this->getPresenter(FALSE);
     $template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');
     // default parameters
     $template->control = $this;
     $template->presenter = $presenter;
     $template->user = Nette\Environment::getUser();
     $template->baseUri = Nette\Environment::getVariable('baseUri', NULL);
     $template->basePath = rtrim($template->baseUri, '/');
     // flash message
     if ($presenter !== NULL && $presenter->hasFlashSession()) {
         $id = $this->getParamId('flash');
         $template->flashes = $presenter->getFlashSession()->{$id};
     }
     if (!isset($template->flashes) || !is_array($template->flashes)) {
         $template->flashes = array();
     }
     // default helpers
     $template->registerHelper('escape', 'Nette\\Templates\\TemplateHelpers::escapeHtml');
     $template->registerHelper('escapeUrl', 'rawurlencode');
     $template->registerHelper('stripTags', 'strip_tags');
     $template->registerHelper('nl2br', 'nl2br');
     $template->registerHelper('substr', 'iconv_substr');
     $template->registerHelper('repeat', 'str_repeat');
     $template->registerHelper('replaceRE', 'Nette\\String::replace');
     $template->registerHelper('implode', 'implode');
     $template->registerHelper('number', 'number_format');
     $template->registerHelperLoader('Nette\\Templates\\TemplateHelpers::loader');
     return $template;
 }
开发者ID:JPalounek,项目名称:IconStore,代码行数:35,代码来源:Control.php


示例10: getConfig

 public function getConfig()
 {
     if (!$this->config) {
         $this->config = Environment::getConfig();
     }
     return $this->config;
 }
开发者ID:GymvodNette,项目名称:cv2-authentizace,代码行数:7,代码来源:BasePresenter.php


示例11: handleUpload

 public function handleUpload()
 {
     $files = \Nette\Environment::getHttpRequest()->getFile("user_file");
     foreach ($files as $file) {
         call_user_func($this->handler, $file);
     }
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:7,代码来源:UploadControl.php


示例12: getContext

 /**
  * @return \Nette\DI\Container
  */
 protected function getContext()
 {
     static $context;
     if (!$context) {
         $context = \Nette\Environment::getContext();
     }
     return $context;
 }
开发者ID:nella,项目名称:testing,代码行数:11,代码来源:TestCase.php


示例13: getStorageDir

	/**
	 * @internal
	 * @return string
	 */
	protected function getStorageDir()
	{
		if ($this instanceof FileEntity) {
			return \Nette\Environment::getContext()->expand(FileService::STORAGE_DIR);
		} else {
			return \Nette\Environment::getContext()->expand(ImageService::STORAGE_DIR);
		}
	}
开发者ID:norbe,项目名称:framework,代码行数:12,代码来源:BaseFileEntity.php


示例14: validateEntity

 private function validateEntity($entity)
 {
     $errors = Environment::getService("validator")->validate($entity);
     if (count($errors) > 0) {
         foreach ($errors as $violation) {
             throw new \Neuron\Model\ValidationException($violation->getMessage(), $violation->getPropertyPath());
         }
     }
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:9,代码来源:ValidationSubscriber.php


示例15: createTemplate

 /**
  * @return Template
  */
 protected function createTemplate($file = null)
 {
     $template = new Template($file);
     $template->baseUrl = \Nette\Environment::getHttpRequest()->url->baseUrl;
     $template->basePath = rtrim($template->baseUrl, '/');
     $template->interface = $this;
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     return $template;
 }
开发者ID:jurasm2,项目名称:multiplefileupload,代码行数:12,代码来源:AbstractInterface.php


示例16: __construct

 /** 
  * Constructor
  * 
  * @note Maybe get User by DI
  */
 public function __construct()
 {
     if (class_exists('\\Nette\\Environment')) {
         $this->userId = \Nette\Environment::getUser()->id;
         $this->avaibleTables = \Nette\Environment::getConfig('store');
     } else {
         $this->userId = 0;
         $this->avaibleTables = [];
     }
 }
开发者ID:kravcik,项目名称:core,代码行数:15,代码来源:StoreManager.php


示例17: createTemplate

 protected function createTemplate($class = NULL)
 {
     $template = parent::createTemplate($class);
     $template->registerHelperLoader('Helpers::loader');
     $this->translator = \Nette\Environment::getContext()->translator;
     $template->setTranslator($this->translator);
     $template->registerHelper('convert', callback(\Nette\Environment::getContext()->currencyHelper, 'convert'));
     $template->currentLang = $this->translator->getLangTo();
     return $template;
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:10,代码来源:BaseControl.php


示例18: loginFormSubmitted

 public function loginFormSubmitted($form)
 {
     try {
         $user = Environment::getUser();
         $user->login($form['username']->getValue(), $form['password']->getValue());
         $this->getApplication()->restoreRequest($this->backlink);
         $this->redirect('Dashboard:');
     } catch (AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:11,代码来源:AuthPresenter.php


示例19: getFilters

 public function getFilters()
 {
     $stored = \Nette\Environment::getSession($this->getParent()->getName());
     $res = null;
     //      dump($stored->filter);
     //      foreach ($stored->filter as $key => $value) {
     //         dump($key);
     //         if($key != 'like' and $key !='boolean')
     //            $res[] = '['.eregi_replace('__','.',$key).'] LIKE "%'.$value.'%"';
     //      }
     return $res;
 }
开发者ID:soundake,项目名称:pd,代码行数:12,代码来源:FilterControl.php


示例20: formatLayoutTemplateFiles

 public function formatLayoutTemplateFiles($presenter, $layout)
 {
     $appDir = Environment::getVariable('appDir');
     $path = '/' . str_replace(':', 'Module/', $presenter);
     $pathP = substr_replace($path, '/templates', strrpos($path, '/'), 0);
     $list = array("{$appDir}{$pathP}/@{$layout}.phtml", "{$appDir}{$pathP}.@{$layout}.phtml", NEURON_DIR . "{$pathP}/@{$layout}.phtml", NEURON_DIR . "{$pathP}.@{$layout}.phtml");
     while (($path = substr($path, 0, strrpos($path, '/'))) !== FALSE) {
         $list[] = "{$appDir}{$path}/templates/@{$layout}.phtml";
         $list[] = NEURON_DIR . "{$path}/templates/@{$layout}.phtml";
     }
     return $list;
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:12,代码来源:BasePresenter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Nette\Object类代码示例发布时间:2022-05-23
下一篇:
PHP Nette\Debug类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap