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(); } }
/** * Constructor of the poll control model layer. * * @param mixed $id Id of the current poll. */ public function __construct($id) { $this->id = $id; $this->connection = new DibiConnection(Environment::getConfig('database')); $sess = Environment::getSession(self::SESSION_NAMESPACE); $sess->poll[$id] = FALSE; }
public function getConfig() { if (!$this->config) { $this->config = Environment::getConfig(); } return $this->config; }
/** * 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 = []; } }
public function processArguments($args, IContext $context) { return array_map(function ($arg) use($context) { if (!is_string($arg)) { return $arg; } elseif (String::startsWith($arg, "%")) { return $context->getService(substr($arg, 1)); } elseif (String::startsWith($arg, "\$\$")) { return Environment::getConfig(substr($arg, 2)); } elseif (String::startsWith($arg, "\$")) { return Environment::getVariable(substr($arg, 1)); } else { return $arg; } }, $args); }
public function renderDefault() { $this->template->ambigousClasses = array(); $this->template->notInsertedUseSts = array(); $this->template->notFoundClasses = array(); $this->template->fileParseTimes = array(); $this->template->unusedUseSts = array(); $this->template->useStAdded = array(); $this->template->possibleCb = array(); $config = Environment::getConfig("autoUse"); $autoUse = new AutoUseWorker(); $autoUse->onOutput[] = array($this, "setTemplateVariables"); $autoUse->setSource($config->sourceDir); $autoUse->addLibrary((array)$config->libDirs); $autoUse->addIgnoredDirs((array)$config->ignoredDirs); $autoUse->run(); }
/** * @author Petr Vales * @version 4.11.2010 */ public function handlePois() { $location = $this->request->post['location']; $service = new LocationService(); $coords = $service->getCoordinates($location); $service = new PoiService($this->entityManager); try { $key = Environment::getConfig('api')->gowallaKey; $pois = $service->getPois($coords['latitude'], $coords['longitude'], new PoiGowallaMapper($key)); } catch (InvalidStateException $e) { $this->terminate(new JsonResponse(array('status' => 'FAIL'))); } $jsonResponse = array(); foreach ($pois as $poi) { $jsonResponse['pois'][] = array('name' => $poi->name, 'types' => $poi->types, 'address' => $poi->address, 'latitude' => $poi->latitude, 'longitude' => $poi->longitude, 'url' => $poi->url, 'icon' => $poi->imageUrl); } $jsonResponse['status'] = 'OK'; $jsonResponse['latitude'] = $coords['latitude']; $jsonResponse['longitude'] = $coords['longitude']; $this->terminate(new JsonResponse($jsonResponse)); }
static function init() { // TODO: remove this magic $config = Environment::getConfig('MultipleFileUploader', array('databasePath' => dirname(__FILE__) . '/database.sqlite3', 'uploadsTempDir' => '')); foreach ($config as $key => $val) { self::${$key} = $val; } }
* @package MyApplication */ use Nette\Debug; use Nette\Environment; use Nette\Application\Route; // Step 1: Load Nette Framework // this allows load Nette Framework classes automatically so that // you don't have to litter your code with 'require' statements require LIBS_DIR . '/Nette/loader.php'; // Step 2: Configure environment // 2a) enable Nette\Debug for better exception and error visualisation Debug::$strictMode = TRUE; Debug::enable(); // 2b) load configuration from config.ini file Environment::loadConfig(); $config = Environment::getConfig(); // Step 3: Configure application // 3a) get and setup a front controller $application = Environment::getApplication(); $application->errorPresenter = 'Error'; //$application->catchExceptions = TRUE; /** * Database connection */ Dibi::connect($config->database); // Step 4: Setup application router $router = $application->getRouter(); $router[] = new Route('index.php', 'Homepage:default', Route::ONE_WAY); $router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default'); // Step 5: Run the application! $application->run();
protected function beforeRender() { $this->template->mapsKey = Environment::getConfig('api')->googleMaps; }
static function init() { // TODO: remove this magic $config = Environment::getConfig("MultipleFileUploader", array("databasePath" => dirname(__FILE__) . "/database.sdb", "uploadsTempDir" => "")); foreach ($config as $key => $val) { self::${$key} = $val; } }
* * @copyright Copyright (c) 2009 Filip Procházka * @package Vdsc */ require_once dirname(__FILE__) . '/Nette/loader.php'; require_once dirname(__FILE__) . '/Curl/Request.php'; use Curl\Request; use Curl\CurlException; use Nette\Environment; use Nette\Debug; // register wrapper safe for file manipulation Nette\SafeStream::register(); Debug::enable(); Debug::$strictMode = True; Environment::loadConfig(realpath('./config.ini')); $config = Environment::getConfig('curl'); $config['downloadFolder'] = realpath("download"); $config['cookieFile'] = $config['downloadFolder'] . '/cookies.tmp'; function proxy(&$test) { // $test->addProxy('192.168.1.160', 3128); } if (TRUE) { // test 1: get $test = new Request("http://curl.kdyby.org/prevodnik.asm.zdrojak", $config); // $test = new Curl("http://iskladka.cz/iCopy/downloadBalancer.php?file=1222561395_obava_bojov+cz.avi&ticket=pc1660-1265493063.25"); echo "<hr>test 1: get ... init ok<hr>", "<h2>Setup:</h2>"; proxy($test); // for debbuging at school dump($test); $response = $test->get();
public static function initialize() { dibi::connect(Environment::getConfig('database')); }
<?php use Nette\Debug; use Nette\Environment; use Nette\Application\Route; use Ormion\Ormion; require LIBS_DIR . '/Nette/loader.php'; Debug::enable(); Environment::loadConfig(); $application = Environment::getApplication(); Ormion::connect(Environment::getConfig("database")); $router = $application->getRouter(); $router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Homepage', 'action' => 'default', 'id' => NULL)); if (Environment::getName() !== "console") { $application->run(); }
// 2a) enable Nette\Debug for better exception and error visualisation Debug::$strictMode = TRUE; Debug::enable(); // 2b) load configuration from config.ini file Environment::loadConfig(); // Step 3: Configure application // 3a) get and setup a front controller $application = Environment::getApplication(); $application->errorPresenter = 'Error'; //$application->catchExceptions = TRUE; // Step 4: Setup application router $router = $application->getRouter(); $router[] = new Route('index.php', array('presenter' => 'Homepage', 'action' => 'default'), Route::ONE_WAY); $router[] = new Route('<presenter>/<id [0-9]+>', array('action' => 'show')); $router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Homepage', 'action' => 'default', 'id' => NULL)); // Doctrine configuration $arrayCache = new ArrayCache(); $doctrineConfig = new Configuration(); $doctrineConfig->setMetadataCacheImpl($arrayCache); $doctrineConfig->setQueryCacheImpl($arrayCache); $doctrineConfig->setMetadataDriverImpl($doctrineConfig->newDefaultAnnotationDriver(array(APP_DIR . '/models'))); $doctrineConfig->setProxyNamespace('DoctrineProxy'); $doctrineConfig->setProxyDir(TEMP_DIR . '/cache'); //$doctrineConfig->setSQLLogger(Doctrine2Panel::getAndRegister()); $entityManager = EntityManager::create(Environment::getConfig('database')->toArray(), $doctrineConfig); $application->getContext()->addService('Doctrine\\ORM\\EntityManager', $entityManager); // Step 5: Run the application! // Don't run while running PHPUnit tests if (!Environment::isConsole()) { $application->run(); }