public function warmUp($cacheDir) { // we need the directory no matter the proxy cache generation strategy. $proxyCacheDir = $this->container->getParameter('doctrine.orm.proxy_dir'); if (!file_exists($proxyCacheDir)) { if (false === @mkdir($proxyCacheDir, 0777, true)) { throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir))); } } else { if (!is_writable($proxyCacheDir)) { throw new \RuntimeException(sprintf('Doctrine Proxy directory (%s) is not writeable for the current system user.', $proxyCacheDir)); } } // if proxys are autogenerated we don't need to generate them in the cache warmer. if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes') === true) { return; } $entityManagers = $this->container->getParameter('doctrine.orm.entity_managers'); foreach ($entityManagers as $entityManagerName) { $em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName)); /* @var $em Doctrine\ORM\EntityManager */ $classes = $em->getMetadataFactory()->getAllMetadata(); $em->getProxyFactory()->generateProxyClasses($classes); } }
/** * Renders jwplayer * * @param MediaInterface $media * @param array $options * * @return string */ public function renderMedia(MediaInterface $media, array $options = array()) { $defaultOptions = $this->container->getParameter('thrace_media.jwplayer.options'); $configs = array('key' => $defaultOptions['key'], 'html5player' => $defaultOptions['html5player'], 'flashplayer' => $defaultOptions['flashplayer'], 'type' => $media->getType(), 'id' => uniqid('thrace_media', true), 'file' => $this->container->get('router')->generate('thrace_media_render', array('name' => $media->getMediaPath(), 'hash' => $media->getHash()), true)); $configs = array_replace_recursive($configs, $options); return $this->container->get('templating')->render('ThraceMediaBundle:Media:media.html.twig', array('media' => $media, 'configs' => $configs)); }
public function param($key) { if ($this->container->hasParameter($key)) { return $this->container->getParameter($key); } throw new Exception("Brak parametru w parameters.yml o nazwie '" . $key . "'"); }
/** * @param Event $event * @param User $user * * @return Ticket */ public function createTicket($event, $user) { // @todo це ще треба передивитись і поправити $em = $this->container->get('doctrine.orm.default_entity_manager'); // Вытягиваем скидку из конфига $paymentsConfig = $this->container->getParameter('stfalcon_event.config'); $discount = (double) $paymentsConfig['discount']; $ticket = new Ticket(); $ticket->setEvent($event); $ticket->setUser($user); $ticket->setAmountWithoutDiscount($event->getCost()); $paidPayments = $em->getRepository('StfalconEventBundle:Payment')->findPaidPaymentsForUser($user); // если пользователь имеет оплаченные события, // то он получает скидку (если для события разрешена такая скидка) if (count($paidPayments) > 0 && $event->getUseDiscounts()) { $cost = $event->getCost() - $event->getCost() * $discount; $hasDiscount = true; } else { $cost = $event->getCost(); $hasDiscount = false; } $ticket->setAmount($cost); $ticket->setHasDiscount($hasDiscount); $em->persist($ticket); $em->flush(); return $ticket; }
public function dump(AssetInterface $asset) { $writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables')); $ref = new \ReflectionMethod($writer, 'getCombinations'); $ref->setAccessible(true); $name = $asset->getSourcePath(); $type = substr($name, strrpos($name, '.') + 1); switch ($type) { case 'coffee': $asset->ensureFilter($this->container->get('assetic.filter.coffee')); $type = 'js'; break; case 'less': $asset->ensureFilter($this->container->get('assetic.filter.less')); $type = 'css'; break; } $combinations = $ref->invoke($writer, $asset->getVars()); $asset->setValues($combinations[0]); $asset->load(); $content = $asset->getContent(); // because the assetic cssrewrite makes bullshit here, we need to reimplement the filter if ($type === 'css') { $content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath())); } return $content; }
/** * Authentify as system * * @return Auth */ public function authentifyAsSystem() { $this->login = $this->container->getParameter('fidesio_isidore.client.login'); $this->password = $this->container->getParameter('fidesio_isidore.client.password'); $this->authentify($this->login, $this->password); return $this; }
public function warmUp($cacheDir) { // we need the directory no matter the hydrator cache generation strategy. $hydratorCacheDir = $this->container->getParameter('doctrine.odm.mongodb.hydrator_dir'); if (!file_exists($hydratorCacheDir)) { if (false === @mkdir($hydratorCacheDir, 0777, true)) { throw new \RuntimeException(sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir))); } } else { if (!is_writable($hydratorCacheDir)) { throw new \RuntimeException(sprintf('Doctrine Hydrator directory (%s) is not writeable for the current system user.', $hydratorCacheDir)); } } // if hydrators are autogenerated we don't need to generate them in the cache warmer. if ($this->container->getParameter('doctrine.odm.mongodb.auto_generate_hydrator_classes') === true) { return; } $documentManagers = $this->container->getParameter('doctrine.odm.mongodb.document_managers'); foreach ($documentManagers as $documentManagerName) { $dm = $this->container->get(sprintf('doctrine.odm.mongodb.%s_document_manager', $documentManagerName)); /* @var $dm Doctrine\ODM\MongoDB\DocumentManager */ $classes = $dm->getMetadataFactory()->getAllMetadata(); $dm->getHydratorFactory()->generateHydratorClasses($classes); } }
/** * Template Loader * * @return Twig_TemplateInterface[] * * @throws \Exception */ protected function getTemplates() { if (empty($this->templates)) { $this->templates[] = $this->environment->loadTemplate($this->container->getParameter('pedro_teixeira_grid.template')); } return $this->templates; }
public static function createProvider(Container $container) { $annotationsEnabled = $container->getParameter('rezonant.mapper.providers.annotations.enabled'); $configEnabled = $container->getParameter('rezonant.mapper.providers.config.enabled'); $cacheEnabled = $container->getParameter('rezonant.mapper.cache.enabled'); $cacheStrategy = $container->getParameter('rezonant.mapper.cache.strategy'); //$maps = $container->getParameter('rezonant.mapper.maps'); $providers = array(); if ($annotationsEnabled) { $providers[] = $container->get('rezonant.mapper.annotation_map_provider'); } if ($configEnabled) { $configMapProvider = $container->get('rezonant.mapper.config_map_provider'); //$configMapProvider->setMaps($maps); $providers[] = $configMapProvider; } $provider = new MapProviderModerator($providers); if ($cacheEnabled) { if (!class_exists($cacheStrategy, true)) { throw new InvalidConfigurationException("No such strategy class {$cacheStrategy}"); } $provider = new CacheProvider($provider, new $cacheStrategy()); } return $provider; }
/** * Get a secure token for reCAPTCHA so we aren't restricted to a specific domain... * @see https://developers.google.com/recaptcha/docs/secure_token * * @return string */ public function getRecaptchaSecureToken() { $public_key = $this->container->getParameter('recaptcha.public_key'); $private_key = $this->container->getParameter('recaptcha.private_key'); $recaptchaToken = new ReCaptchaToken(array('site_key' => $public_key, 'site_secret' => $private_key)); return $recaptchaToken->secureToken(uniqid('recaptcha')); }
private function postTweet($text) { Codebird::setConsumerKey($this->container->getParameter('twitter_consumer_key'), $this->container->getParameter('twitter_consumer_secret')); $cb = Codebird::getInstance(); $cb->setToken($this->container->getParameter('twitter_access_token'), $this->container->getParameter('twitter_access_token_secret')); $reply = $cb->statuses_update('status=' . $text); return $reply; }
public function render($type = 'search', $entities = null, $fields = null) { if ($this->templateEngine === null) { $this->templateEngine = $this->container->get('templating'); } $template = $this->container->getParameter('enhavo_search.' . $type . '.template'); return $this->templateEngine->render($template, array('type' => $type, 'entities' => $entities, 'fields' => $fields)); }
public function __construct(Container $container, $soapUrl) { $this->talonClientSOAP = $container->get('be_simple_talon.soap_client.talon_soap_client'); $this->setSoapUrl($soapUrl); $this->talonClientSOAP->setWsdl($this->getSoapUrl() . self::WSDL_PATH); $this->talonClientSOAP->setOptions(array("login" => $container->getParameter('http_auth_login'), "password" => $container->getParameter('http_auth_password'), "httpauth" => $container->getParameter('http_auth'), "verifyhost" => $container->getParameter('verifyhost'))); $this->talonClientSOAP->TalonSoapClient(); }
/** * {@inheritDoc} */ protected function setUp() { static::bootKernel(); $this->container = static::$kernel->getContainer(); $this->baseUrl = $this->container->getParameter('mink.base_url'); $this->session = $this->getMink()->getSession(); $this->session->maximizeWindow(); }
/** * Constructor * * @param Container $container */ public function __construct(Container $container) { $this->request = $container->get('request'); $this->kernel = $container->get('kernel'); $this->doctrine = $container->get('doctrine'); $this->sessionData = array(); $this->config = array('sessionDuration' => $container->getParameter('tga_audience.session_duration'), 'disabledRoutes' => $container->getParameter('tga_audience.disabled_routes'), 'environnements' => $container->getParameter('tga_audience.environnements')); }
/** * {@inheritDoc} */ public function getApi() { $api = new MangoPayApi(); $api->Config->ClientId = $this->container->getParameter('houssrad_mango_pay.mangopay_id'); $api->Config->ClientPassword = $this->container->getParameter('houssrad_mango_pay.mangopay_password'); $api->Config->BaseUrl = $this->container->getParameter('houssrad_mango_pay.mangopay_base_url'); $api->Config->TemporaryFolder = sys_get_temp_dir(); return $api; }
/** * @return array * @throws \Exception */ public function getEnabledLocales() { $enabledLocaleCodes = explode('|', $this->container->getParameter('enabled_locales')); $locales = array(); foreach ($enabledLocaleCodes as $code) { $locales[$code] = array('nativeLocale' => $this->getLocaleName($code, $code), 'currentLocale' => $this->getLocaleName($code)); } return $locales; }
public function render($type = 'contact') { if ($this->templateEngine === null) { $this->templateEngine = $this->container->get('templating'); } $formFactory = $this->container->get('form.factory'); $form = $formFactory->create('enhavo_contact_contact'); $template = $this->container->getParameter('enhavo_contact.' . $type . '.template.form'); return $this->templateEngine->render($template, array('form' => $form->createView(), 'type' => $type)); }
/** * @param string $cid * @param string $trnId * @param string $iName * @param int $iPrice * @param int $iQuantity * * @return \Buzz\Message\MessageInterface * * @throws \Exception */ public function sendItem($cid, $trnId, $iName, $iPrice, $iQuantity = 1) { /* * Documentation by params: * * https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=ru */ $params = ['v' => $this->version, 'tid' => $this->container->getParameter('tracking_id'), 'cid' => $cid, 't' => 'item', 'ti' => $trnId, 'in' => $iName, 'ip' => $iPrice, 'iq' => $iQuantity, 'cu' => $this->currencyCode]; return $this->container->get('buzz')->submit($this->url, $params, RequestInterface::METHOD_POST); }
protected function getTypeFromSylius($className) { $resources = $this->container->getParameter('sylius.resources'); foreach ($resources as $type => $resource) { if ($resource['classes']['model'] == $className) { return $type; } } return null; }
public function __construct(\Doctrine\ORM\EntityManager $em, \Symfony\Component\DependencyInjection\Container $sc, \Symfony\Component\Translation\DataCollectorTranslator $tr) { $this->em = $em; $this->conn = $this->em->getConnection(); $this->tr = $tr; $this->ents = $sc->getParameter('arco_voltaico_import.entities'); $this->namespace = $sc->getParameter('arco_voltaico_import.namespace'); $this->bundle = $sc->getParameter('arco_voltaico_import.bundle'); $this->parent = ''; }
/** * Get the current user. * * @return null */ public function getCurrentUser() { $userClass = $this->container->getParameter('victoire_core.user_class'); $token = $this->container->get('security.context')->getToken(); if ($token !== null) { if ($token->getUser() instanceof $userClass) { return $token->getUser(); } } }
/** * Возвращает необходимые данные для формы оплаты * * @param Payment $payment * @param Event $event * @return array */ public function getData(Payment $payment, Event $event) { $config = $this->container->getParameter('stfalcon_event.config'); $description = 'Оплата участия в конференции ' . $event->getName() . '. Плательщик ' . $payment->getUser()->getFullname() . ' (#' . $payment->getUser()->getId() . ')'; $params['ik_co_id'] = $config['interkassa']['shop_id']; $params['ik_am'] = $payment->getAmount(); $params['ik_pm_no'] = $payment->getId(); $params['ik_desc'] = $description; $params['ik_loc'] = 'ru'; return ['ik_co_id' => $config['interkassa']['shop_id'], 'ik_desc' => $description, 'ik_sign' => $this->getSignHash($params)]; }
public function onKernelRequest(GetResponseEvent $event) { if ($event->getRequest()->get('_route') == 'homepage' && !$event->getRequest()->get('_locale')) { $locale = $event->getRequest()->getPreferredLanguage(array('ru', 'en', 'de')); if (!$locale) { $this->container->getParameter('locale'); } $response = new RedirectResponse($this->container->get('router')->generate('homepage', array('_locale' => $locale))); $event->setResponse($response); } }
/** * Constructor * * @param Container $serviceContainer Service container * @param array $redirectConf Config redirect * @param boolean $fullPath Full path or front page * @param string $fragmentPath The fragment route */ public function __construct(Container $serviceContainer, array $redirectConf, $fullPath = true, $fragmentPath = '') { $this->container = $serviceContainer; $this->mobileDetector = $serviceContainer->get('mobile_detect.mobile_detector'); $this->deviceView = $serviceContainer->get('mobile_detect.device_view'); $this->fragmentPath = $fragmentPath; // Configs mobile & tablet $this->redirectConf = $redirectConf; $this->isFullPath = $fullPath; $this->cacheDir = $this->container->getParameter('kernel.cache_dir'); $this->routeCollection = null; }
public function __construct(EntityManager $entityManager, Container $container) { $this->entityManager = $entityManager; foreach ($this->mandatoryFields as $field => $value) { $this->mandatoryFields[$field] = $container->getParameter(sprintf('tlconseil_systempay.%s', $field)); } if ($this->mandatoryFields['ctx_mode'] == "TEST") { $this->key = $container->getParameter('tlconseil_systempay.key_dev'); } else { $this->key = $container->getParameter('tlconseil_systempay.key_prod'); } }
public static function setUpBeforeClass() { self::$client = static::createClient(); self::$container = self::$client->getContainer(); self::$hasDefinitions = self::$container->hasParameter('featureTypes'); self::$definitions = self::$hasDefinitions ? self::$container->getParameter('featureTypes') : array(); if (!self::$hasDefinitions) { self::markTestSkipped("No feature declaration found"); return; } self::$featureType = self::$container->get('features')->get(key(self::$definitions)); self::$fieldName = current(self::$featureType->getFields()); }
/** * Returns the file path to an image file which represents the passed mimetype. * * @param string $mimetype The mimetype * * @return string A path to the mimetype icon */ public function getMimetypeIcon($mimetype) { $file = str_replace('/', '-', $mimetype) . '.svg'; $iconDirectory = $this->container->getParameter('partkeepr.directories.mimetype_icons'); $fileLocator = new FileLocator($iconDirectory); try { $iconFile = $fileLocator->locate($file); } catch (\InvalidArgumentException $e) { $file = 'empty.svg'; $iconFile = $fileLocator->locate($file); } return $iconFile; }
/** * @param Container $container */ public static function create(Container $container) { $proxyTargetDir = $container->getParameter('phpro.annotated_cache.params.proxies_target_dir'); $proxyNamespace = $container->getParameter('phpro.annotated_cache.params.proxies_namespace'); $shouldAutoload = $container->getParameter('phpro.annotated_cache.params.proxies_register_autoloader'); // Make sure to touch the filesystem. $container->get('filesystem')->mkdir($proxyTargetDir); $configuration = new Configuration(); $configuration->setProxiesTargetDir($proxyTargetDir); $configuration->setProxiesNamespace($proxyNamespace); if ($shouldAutoload) { spl_autoload_register($configuration->getProxyAutoloader()); } }
/** * image * * @param string $dir * @param null|integer $width * @param null|integer $height * * @return mixed|string */ public function image($dir, $width = null, $height = null) { $width = $width ?: rand(100, 300); $height = $height ?: rand(100, 300); $imageName = sprintf('%s/%s/%s.png', $this->container->getParameter('dms.storage.path'), $dir, uniqid("image_{$width}x{$height}_")); $image = self::imageLink($width, $height); if (!is_dir(dirname($imageName))) { mkdir(dirname($imageName), 0777, true); } file_put_contents($imageName, file_get_contents($image)); $imageName = str_replace($this->container->getParameter('dms.storage.path'), '', $imageName); $imageName = trim($imageName, '/'); return $imageName; }