/**
  * Add fields for attribute values selection in our own way (since the product on has its default PSE, it has
  * no attributes as far as Thelia is concerned, but we want it to have all of its template's attributes).
  *
  * @param TheliaFormEvent $event
  */
 public function cartFormAfterBuild(TheliaFormEvent $event)
 {
     $sessionLocale = null;
     $session = $this->request->getSession();
     if ($session !== null) {
         $sessionLang = $session->getLang();
         if ($sessionLang !== null) {
             $sessionLocale = $sessionLang->getLocale();
         }
     }
     $product = ProductQuery::create()->findPk($this->request->getProductId());
     if ($product === null || $product->getTemplate() === null) {
         return;
     }
     $productAttributes = AttributeQuery::create()->filterByTemplate($product->getTemplate())->find();
     /** @var Attribute $productAttribute */
     foreach ($productAttributes as $productAttribute) {
         $attributeValues = AttributeAvQuery::create()->findByAttributeId($productAttribute->getId());
         $choices = [];
         /** @var AttributeAv $attributeValue */
         foreach ($attributeValues as $attributeValue) {
             if ($sessionLocale !== null) {
                 $attributeValue->setLocale($sessionLocale);
             }
             $choices[$attributeValue->getId()] = $attributeValue->getTitle();
         }
         $event->getForm()->getFormBuilder()->add(static::LEGACY_PRODUCT_ATTRIBUTE_FIELD_PREFIX . $productAttribute->getId(), 'choice', ['choices' => $choices, 'required' => true]);
     }
 }
예제 #2
0
파일: Module.php 프로젝트: alex63530/thelia
 /**
  * Process theliaModule template inclusion function
  *
  * This function accepts two parameters:
  *
  * - location : this is the location in the admin template. Example: folder-edit'. The function will search for
  *   AdminIncludes/<location>.html file, and fetch it as a Smarty template.
  * - countvar : this is the name of a template variable where the number of found modules includes will be assigned.
  *
  * @param array                     $params
  * @param \Smarty_Internal_Template $template
  * @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty
  *
  * @return string
  */
 public function theliaModule($params, \Smarty_Internal_Template $template)
 {
     $content = null;
     $count = 0;
     if (false !== ($location = $this->getParam($params, 'location', false))) {
         if ($this->debug === true && $this->request->get('SHOW_INCLUDE')) {
             echo sprintf('<div style="background-color: #C82D26; color: #fff; border-color: #000000; border: solid;">%s</div>', $location);
         }
         $moduleLimit = $this->getParam($params, 'module', null);
         $modules = ModuleQuery::getActivated();
         /** @var \Thelia\Model\Module $module */
         foreach ($modules as $module) {
             if (null !== $moduleLimit && $moduleLimit != $module->getCode()) {
                 continue;
             }
             $file = $module->getAbsoluteAdminIncludesPath() . DS . $location . '.html';
             if (file_exists($file)) {
                 $output = trim(file_get_contents($file));
                 if (!empty($output)) {
                     $content .= $output;
                     $count++;
                 }
             }
         }
     }
     if (false !== ($countvarname = $this->getParam($params, 'countvar', false))) {
         $template->assign($countvarname, $count);
     }
     if (!empty($content)) {
         return $template->fetch(sprintf("string:%s", $content));
     }
     return "";
 }
예제 #3
0
 protected function setUp()
 {
     $this->controller = $controller = $this->getMock("Thelia\\Controller\\BaseController", ["getParser", "render", "renderRaw"]);
     /**
      * Reset static :: $formDefinition on controllers
      */
     $this->definitionReflection = $reflection = (new \ReflectionObject($this->controller))->getProperty('formDefinition');
     $reflection->setAccessible(true);
     $this->formDefinition = $reflection->getValue();
     $reflection->setValue(null);
     /**
      * Add the test type to the factory and
      * the form to the container
      */
     $factory = new FormFactoryBuilder();
     $factory->addExtension(new CoreExtension());
     $factory->addType(new TestType());
     /**
      * Construct the container
      */
     $container = new Container();
     $container->set("thelia.form_factory_builder", $factory);
     $container->set("thelia.translator", new Translator($container));
     $container->setParameter("thelia.parser.forms", array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->controller->setContainer($container);
 }
예제 #4
0
 /**
  * Save the attribute combinations for the order from our cart item attribute combinations.
  *
  * @param OrderEvent $event
  *
  * @throws PropelException
  */
 public function createOrderProductAttributeCombinations(OrderEvent $event)
 {
     $legacyCartItemAttributeCombinations = LegacyCartItemAttributeCombinationQuery::create()->findByCartItemId($event->getCartItemId());
     // works with Thelia 2.2
     if (method_exists($event, 'getId')) {
         $orderProductId = $event->getId();
     } else {
         // Thelia 2.1 however does not provides the order product id in the event
         // Since the order contains potentially identical (for Thelia) cart items that are only differentiated
         // by the cart item attribute combinations that we are storing ourselves, we cannot use information
         // such as PSE id to cross reference the cart item we are given to the order product that was created from
         // it (as far as I can tell).
         // So we will ASSUME that the order product with the higher id is the one created from this cart item.
         // This is PROBABLY TRUE on a basic Thelia install with no modules messing with the cart and orders in a way
         // that create additional order products, BUT NOT IN GENERAL !
         // This also assumes that ids are generated incrementally, which is NOT GUARANTEED (but true for MySQL
         // with default settings).
         // The creation date was previously used but is even less reliable.
         // FIXME: THIS IS NOT A SANE WAY TO DO THIS
         $orderProductId = OrderProductQuery::create()->orderById(Criteria::DESC)->findOne()->getId();
     }
     $lang = $this->request->getSession()->getLang();
     /** @var LegacyCartItemAttributeCombination $legacyCartItemAttributeCombination */
     foreach ($legacyCartItemAttributeCombinations as $legacyCartItemAttributeCombination) {
         /** @var Attribute $attribute */
         $attribute = I18n::forceI18nRetrieving($lang->getLocale(), 'Attribute', $legacyCartItemAttributeCombination->getAttributeId());
         /** @var AttributeAv $attributeAv */
         $attributeAv = I18n::forceI18nRetrieving($lang->getLocale(), 'AttributeAv', $legacyCartItemAttributeCombination->getAttributeAvId());
         (new OrderProductAttributeCombination())->setOrderProductId($orderProductId)->setAttributeTitle($attribute->getTitle())->setAttributeChapo($attribute->getChapo())->setAttributeDescription($attribute->getDescription())->setAttributePostscriptum($attribute->getPostscriptum())->setAttributeAvTitle($attributeAv->getTitle())->setAttributeAvChapo($attributeAv->getChapo())->setAttributeAvDescription($attributeAv->getDescription())->setAttributeAvPostscriptum($attributeAv->getPostscriptum())->save();
     }
 }
예제 #5
0
 public function __construct(Request $request)
 {
     if ($request->getSession() != null) {
         $this->locale = $request->getSession()->getLang()->getLocale();
     } else {
         $this->locale = Lang::getDefaultLanguage()->getLocale();
     }
 }
 protected function getGetResponseEvent()
 {
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     /** @var HttpKernelInterface $kernelMock */
     $kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')->disableOriginalConstructor()->getMock();
     return new GetResponseEvent($kernelMock, $request, HttpKernelInterface::MASTER_REQUEST);
 }
 protected function init()
 {
     $container = $this->getContainer();
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     /** @var RequestStack $requestStack */
     $requestStack = $container->get('request_stack');
     $requestStack->push($request);
 }
예제 #8
0
 public function setUp()
 {
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->mailerFactory = $this->getMockBuilder("Thelia\\Mailer\\MailerFactory")->disableOriginalConstructor()->getMock();
     $translator = new Translator(new Container());
     $this->tokenProvider = new TokenProvider($request, $translator, 'test');
 }
예제 #9
0
 public function getContainer()
 {
     $container = new ContainerBuilder();
     $container->set("event_dispatcher", $this->getDispatcher());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
예제 #10
0
 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $container->set("event_dispatcher", $this->getDispatcher());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
예제 #11
0
 public function setUp()
 {
     parent::setUp();
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->requestStack = new RequestStack();
     $this->requestStack->push($request);
 }
예제 #12
0
파일: AdminLog.php 프로젝트: badelas/thelia
 /**
  * A simple helper to insert an entry in the admin log
  *
  * @param $resource
  * @param $action
  * @param $message
  * @param Request       $request
  * @param UserInterface $adminUser
  * @param bool          $withRequestContent
  */
 public static function append($resource, $action, $message, Request $request, UserInterface $adminUser = null, $withRequestContent = true)
 {
     $log = new AdminLog();
     $log->setAdminLogin($adminUser !== null ? $adminUser->getUsername() : '<no login>')->setAdminFirstname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getFirstname() : '<no first name>')->setAdminLastname($adminUser !== null && $adminUser instanceof Admin ? $adminUser->getLastname() : '<no last name>')->setResource($resource)->setAction($action)->setMessage($message)->setRequest($request->toString($withRequestContent));
     try {
         $log->save();
     } catch (\Exception $ex) {
         Tlog::getInstance()->err("Failed to insert new entry in AdminLog: {ex}", array('ex' => $ex));
     }
 }
예제 #13
0
 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
     $container->set("event_dispatcher", $dispatcher);
     $fileManager = new FileManager(["document.product" => "Thelia\\Model\\ProductDocument", "image.product" => "Thelia\\Model\\ProductImage", "document.category" => "Thelia\\Model\\CategoryDocument", "image.category" => "Thelia\\Model\\CategoryImage", "document.content" => "Thelia\\Model\\ContentDocument", "image.content" => "Thelia\\Model\\ContentImage", "document.folder" => "Thelia\\Model\\FolderDocument", "image.folder" => "Thelia\\Model\\FolderImage", "document.brand" => "Thelia\\Model\\BrandDocument", "image.brand" => "Thelia\\Model\\BrandImage"]);
     $container->set("thelia.file_manager", $this->getFileManager());
     $request = new Request();
     $request->setSession($this->session);
     $container->set("request", $request);
     return $container;
 }
예제 #14
0
 public function getContainer()
 {
     $container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
     $container->set("thelia.translator", new Translator(new Container()));
     $dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
     $container->set("event_dispatcher", $dispatcher);
     $request = new Request();
     $request->setSession($this->getSession());
     $container->set("request", $request);
     $container->set("thelia.securitycontext", new SecurityContext($request));
     $this->buildContainer($container);
     return $container;
 }
 public function verifyCreditUsage(OrderEvent $event)
 {
     $session = $this->request->getSession();
     if ($session->get('creditAccount.used') == 1) {
         $customer = $event->getOrder()->getCustomer();
         $amount = $session->get('creditAccount.amount');
         $creditEvent = new CreditAccountEvent($customer, $amount * -1, $event->getOrder()->getId());
         $creditEvent->setWhoDidIt(Translator::getInstance()->trans('Customer', [], CreditAccount::DOMAIN))->setOrderId($event->getOrder()->getId());
         $event->getDispatcher()->dispatch(CreditAccount::CREDIT_ACCOUNT_ADD_AMOUNT, $creditEvent);
         $session->set('creditAccount.used', 0);
         $session->set('creditAccount.amount', 0);
     }
 }
예제 #16
0
 /**
  * @param Request $request
  * @param $orderId
  * @return Response
  * @throws \Exception
  */
 public function notifyAction(Request $request, $orderId)
 {
     $token = $request->get('token');
     /** @var PaylineManager $payline */
     $payline = $this->getContainer()->get('payline.manager');
     if ($payline->getWebPaymentDetails($token)) {
         $this->confirmPayment($orderId);
         $this->cleanExpiredLog();
         return new Response();
     }
     $this->cancelPayment($orderId);
     $this->cleanExpiredLog();
     return new Response();
 }
예제 #17
0
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (!$request instanceof \Thelia\Core\HttpFoundation\Request) {
         $request = TheliaRequest::create($request->getUri(), $request->getMethod(), $request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getContent());
     }
     return parent::handle($request, $type, $catch);
 }
 /**
  * @param string $uri
  * @param Request $request
  * @return Request
  */
 protected function createSubRequest($uri, Request $request)
 {
     $cookies = $request->cookies->all();
     $server = $request->server->all();
     // Override the arguments to emulate a sub-request.
     // Sub-request object will point to localhost as client ip and real client ip
     // will be included into trusted header for client ip
     try {
         if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
             $currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
             $server['HTTP_' . $trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor . ', ' : '') . $request->getClientIp();
         }
     } catch (\InvalidArgumentException $e) {
         // Do nothing
     }
     $server['REMOTE_ADDR'] = '127.0.0.1';
     $subRequest = TheliaRequest::create($uri, 'get', array(), $cookies, array(), $server);
     if ($request->headers->has('Surrogate-Capability')) {
         $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
     }
     if ($session = $request->getSession()) {
         $subRequest->setSession($session);
     }
     return $subRequest;
 }
예제 #19
0
 private function checkApiAccess(Request $request)
 {
     $key = $request->headers->get('authorization');
     if (null !== $key) {
         $key = substr($key, 6);
     }
     $apiAccount = ApiQuery::create()->findOneByApiKey($key);
     if (null === $apiAccount) {
         throw new UnauthorizedHttpException('Token');
     }
     $secureKey = pack('H*', $apiAccount->getSecureKey());
     $sign = hash_hmac('sha1', $request->getContent(), $secureKey);
     if ($sign != $request->query->get('sign')) {
         throw new PreconditionFailedHttpException('wrong body request signature');
     }
     return $apiAccount;
 }
 public function getContainer()
 {
     $container = new ContainerBuilder();
     $container->set("thelia.translator", new Translator(new Container()));
     $dispatcher = $this->getMockEventDispatcher();
     $container->set("event_dispatcher", $dispatcher);
     $request = new Request();
     $request->setSession($this->getSession());
     $container->set("request", $request);
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $container->set("request_stack", $requestStack);
     new Translator($container);
     $container->set("thelia.securitycontext", new SecurityContext($requestStack));
     $this->buildContainer($container);
     return $container;
 }
예제 #21
0
 public function setUp()
 {
     $this->request = new Request();
     $this->session = new Session(new MockArraySessionStorage());
     $this->request->setSession($this->session);
     $translator = new Translator($this->getMock('\\Symfony\\Component\\DependencyInjection\\ContainerInterface'));
     $this->cartAction = new \Thelia\Action\Cart($this->request, new TokenProvider($this->request, $translator, 'baba au rhum'));
     $this->dispatcherNull = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', array(), array(), '', true, true, true, false);
     $this->dispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($type, $event) {
         $event->setDispatcher($this->dispatcher);
         if ($type == TheliaEvents::CART_RESTORE_CURRENT) {
             $this->cartAction->restoreCurrentCart($event);
         } elseif ($type == TheliaEvents::CART_CREATE_NEW) {
             $this->cartAction->createEmptyCart($event);
         }
     }));
 }
예제 #22
0
 /**
  * get the session
  *
  * @return Session
  */
 protected function getSession()
 {
     if (null === $this->session) {
         if (null !== $this->getRequest()) {
             $this->session = $this->request->getSession();
         }
     }
     return $this->session;
 }
예제 #23
0
파일: Lang.php 프로젝트: margery/thelia
 public function delete(LangDeleteEvent $event)
 {
     if (null !== ($lang = LangQuery::create()->findPk($event->getLangId()))) {
         if ($lang->getByDefault()) {
             throw new \RuntimeException(Translator::getInstance()->trans('It is not allowed to delete the default language'));
         }
         $lang->setDispatcher($event->getDispatcher())->delete();
         $session = $this->request->getSession();
         // If we've just deleted the current admin edition language, set it to the default one.
         if ($lang->getId() == $session->getAdminEditionLang()->getId()) {
             $session->setAdminEditionLang(LangModel::getDefaultLanguage());
         }
         // If we've just deleted the current admin language, set it to the default one.
         if ($lang->getId() == $session->getLang()->getId()) {
             $session->setLang(LangModel::getDefaultLanguage());
         }
         $event->setLang($lang);
     }
 }
예제 #24
0
 /**
  * For init an Request, if your command has need an Request
  * @param Lang|null $lang
  * @since 2.3
  */
 protected function initRequest(Lang $lang = null)
 {
     $container = $this->getContainer();
     $request = Request::create($this->getBaseUrl($lang));
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request_stack", new RequestStack());
     $container->get('request_stack')->push($request);
     $requestContext = new RequestContext();
     $requestContext->fromRequest($request);
     $url = $container->get('thelia.url.manager');
     $url->setRequestContext($requestContext);
 }
예제 #25
0
 public function setUp()
 {
     $this->container = new ContainerBuilder();
     $this->container->setParameter("thelia.parser.loops", ["tested-loop" => $this->getTestedClassName()]);
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $requestStack = new RequestStack();
     $request->setSession($session);
     /*$stubEventdispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcher')
                 ->disableOriginalConstructor()
                 ->getMock();
     
             $stubSecurityContext = $this->getMockBuilder('\Thelia\Core\Security\SecurityContext')
                 ->disableOriginalConstructor()
                 ->getMock();*/
     /*$stubAdapter->expects($this->any())
       ->method('getTranslator')
       ->will($this->returnValue($stubTranslator));*/
     /*$this->request = new Request();
             $this->request->setSession(new Session(new MockArraySessionStorage()));
     
             $this->dispatcher = new EventDispatcher();
     
             $this->securityContext = new SecurityContext($this->request);*/
     $stubRouterAdmin = $this->getMockBuilder('\\Symfony\\Component\\Routing\\Router')->disableOriginalConstructor()->setMethods(array('getContext'))->getMock();
     $stubRequestContext = $this->getMockBuilder('\\Symfony\\Component\\Routing\\RequestContext')->disableOriginalConstructor()->setMethods(array('getHost'))->getMock();
     $stubRequestContext->expects($this->any())->method('getHost')->will($this->returnValue('localhost'));
     $stubRouterAdmin->expects($this->any())->method('getContext')->will($this->returnValue($stubRequestContext));
     $requestStack->push($request);
     $this->container->set('request', $request);
     $this->container->set('request_stack', $requestStack);
     $this->container->set('event_dispatcher', new EventDispatcher());
     $this->container->set('thelia.translator', new Translator($this->container));
     $this->container->set('thelia.securityContext', new SecurityContext($requestStack));
     $this->container->set('router.admin', $stubRouterAdmin);
     $this->container->set('thelia.url.manager', new URL($this->container));
     $this->container->set('thelia.taxEngine', new TaxEngine($requestStack));
     $this->instance = $this->getTestedInstance();
     $this->instance->initializeArgs($this->getMandatoryArguments());
 }
예제 #26
0
 public function setUp()
 {
     $this->backup_mail_template = ConfigQuery::read('active-mail-template', 'default');
     ConfigQuery::write('active-mail-template', 'test');
     @mkdir(TemplateHelper::getInstance()->getActiveMailTemplate()->getAbsolutePath(), 0777, true);
     $container = new ContainerBuilder();
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $dispatcher = $this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface");
     $request->setSession($session);
     /*
              *  public function __construct(
                 Request $request, EventDispatcherInterface $dispatcher, ParserContext $parserContext,
                 $env = "prod", $debug = false)
     */
     $container->set("event_dispatcher", $dispatcher);
     $container->set('request', $request);
     $this->parser = new SmartyParser($request, $dispatcher, new ParserContext($request), 'dev', true);
     $this->parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveMailTemplate());
     $container->set('thelia.parser', $this->parser);
     $this->container = $container;
 }
예제 #27
0
 public function setUp()
 {
     $session = new Session(new MockArraySessionStorage());
     $request = new Request();
     $request->setSession($session);
     $this->container = new ContainerBuilder();
     $this->container->set("event_dispatcher", $this->getMockEventDispatcher());
     $this->container->set('request', $request);
     $this->requestStack = new RequestStack();
     $this->requestStack->push($request);
     $this->container->set('request_stack', $this->requestStack);
     $this->securityContext = new SecurityContext($this->requestStack);
     $this->orderEvent = new OrderEvent(new OrderModel());
     $mailerFactory = new MailerFactory($this->getMockEventDispatcher(), $this->getMockParserInterface());
     $this->orderAction = new Order($this->requestStack, $mailerFactory, $this->securityContext);
     /* load customer */
     $this->customer = $this->loadCustomer();
     if (null === $this->customer) {
         return;
     }
     /* fill cart */
     $this->cart = $this->fillCart();
 }
예제 #28
0
 protected function setUp()
 {
     /**
      * Add the test type to the factory and
      * the form to the container
      */
     $factory = new FormFactoryBuilder();
     $factory->addExtension(new CoreExtension());
     $factory->addType(new TestType());
     /**
      * Construct the container
      */
     $container = new Container();
     $container->set("thelia.form_factory_builder", $factory);
     $container->set("thelia.translator", new Translator($container));
     $container->setParameter("thelia.parser.forms", $definition = array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->factory = new TheliaFormFactory($request, $container, $definition);
 }
예제 #29
0
 public function setUp()
 {
     $session = new Session();
     new Translator(new Container());
     $this->request = $this->getMock("\\Thelia\\Core\\HttpFoundation\\Request");
     $this->request->expects($this->any())->method("getClientIp")->willReturn("127.0.0.1");
     $this->request->expects($this->any())->method("getSession")->willReturn($session);
     /**
      * Get an example form. We
      */
     $this->form = $this->getMock("\\Thelia\\Form\\FirewallForm", ["buildForm", "getName"], [$this->request]);
     $this->form->expects($this->any())->method('getName')->will($this->returnValue("test_form_firewall"));
     /**
      * Be sure that the firewall is active
      */
     ConfigQuery::write("form_firewall_active", 1);
     ConfigQuery::write("form_firewall_time_to_wait", 60);
     ConfigQuery::write("form_firewall_attempts", 6);
     /**
      * Empty the firewall blacklist between each test
      */
     FormFirewallQuery::create()->find()->delete();
 }
예제 #30
0
 /**
  * Remove obsolete form error information.
  */
 protected function cleanOutdatedFormErrorInformation()
 {
     $formErrorInformation = $this->request->getSession()->getFormErrorInformation();
     if (!empty($formErrorInformation)) {
         $now = time();
         // Cleanup obsolete form information, and try to find the form data
         foreach ($formErrorInformation as $name => $formData) {
             if ($now - $formData['timestamp'] > self::FORM_ERROR_LIFETIME_SECONDS) {
                 unset($formErrorInformation[$name]);
             }
         }
         $this->request->getSession()->setFormErrorInformation($formErrorInformation);
     }
     return $this;
 }