예제 #1
0
파일: SetupStep.php 프로젝트: csbill/csbill
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $request = $context->getRequest();
     $form = $this->getForm($context->getRequest());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         if (0 === $this->getUserCount()) {
             $this->createAdminUser($data);
         }
         $this->saveCurrentVersion();
         $this->saveConfig($data);
         return $this->complete();
     }
     return $this->render('CSBillInstallBundle:Flow:setup.html.twig', ['form' => $form->createView(), 'userCount' => $this->getUserCount()]);
 }
예제 #2
0
 /**
  * @param ProcessContextInterface $context
  * @return null|\Sylius\Bundle\FlowBundle\Process\Step\ActionResult|Response
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $adminUser = $this->getDoctrine()->getRepository('ChamiloUserBundle:User')->findOneBy(array('username' => LoadAdminUserData::DEFAULT_ADMIN_USERNAME));
     if (!$adminUser) {
         throw new \RuntimeException("Admin user wasn't loaded in fixtures.");
     }
     $form = $this->createSetupForm();
     $form->get('admin')->setData($adminUser);
     $form->handleRequest($context->getRequest());
     if ($form->isValid()) {
         $this->get('fos_user.user_manager')->updateUser($adminUser);
         // Setting portal parameters
         $settingsManager = $this->get('chamilo.settings.manager');
         $url = $this->get('chamilo_core.manager.access_url')->find(1);
         $settingsManager->setUrl($url);
         $settings = $settingsManager->loadSettings('platform');
         $parameters = array('institution' => $form->get('portal')->get('institution')->getData(), 'institution_url' => $form->get('portal')->get('institution_url')->getData(), 'site_name' => $form->get('portal')->get('site_name')->getData(), 'timezone' => $form->get('portal')->get('timezone')->getData());
         $settings->setParameters($parameters);
         $settingsManager->saveSettings('platform', $settings);
         $parameters = array('administrator_email' => $adminUser->getEmail(), 'administrator_name' => $adminUser->getFirstName(), 'administrator_surname' => $adminUser->getLastName(), 'administrator_phone' => $adminUser->getPhone());
         $settings->setParameters($parameters);
         $settingsManager->saveSettings('admin', $settings);
         return $this->complete();
     }
     return $this->render('ChamiloInstallerBundle:Process/Step:setup.html.twig', array('form' => $form->createView(), 'is_upgrade' => $this->isCommonUpgrade()));
 }
예제 #3
0
 public function displayAction(ProcessContextInterface $context)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $request = $context->getRequest();
     $siteManager = $this->container->get('ritsiga.site.manager');
     $convention = $siteManager->getCurrentSite();
     $university = $user->getStudentDelegation()->getCollege()->getUniversity();
     $form = $this->createForm(new UniversityType(), $university);
     return $this->render(':frontend/registration/process:university.html.twig', array('convention' => $convention, 'form' => $form->createView(), 'user' => $user, 'context' => $context));
 }
예제 #4
0
 public function displayAction(ProcessContextInterface $context)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $request = $context->getRequest();
     $siteManager = $this->container->get('ritsiga.site.manager');
     $convention = $siteManager->getCurrentSite();
     $registration = new Registration();
     $registration->setConvention($convention);
     $form = $this->createForm(new ResponsibleType(), $registration);
     return $this->render(':frontend/registration/process:responsible.html.twig', array('convention' => $convention, 'form' => $form->createView(), 'user' => $user, 'context' => $context));
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $order = $this->getCurrentCart();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::SECURITY_INITIALIZE, $order);
     $request = $context->getRequest();
     $guestForm = $this->getGuestForm();
     $registrationForm = $this->getRegistrationForm();
     if ($this->isGuestOrderAllowed() && $guestForm->handleRequest($request)->isValid()) {
         return $this->processGuestOrder($guestForm, $order);
     } elseif ($registrationForm->handleRequest($request)->isValid()) {
         return $this->processRegistration($registrationForm, $order);
     }
     return $this->renderStep($context, $registrationForm, $guestForm);
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $request = $context->getRequest();
     $order = $this->getCurrentCart();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_INITIALIZE, $order);
     $form = $this->createCheckoutAddressingForm($order, $this->getCustomer());
     if ($form->handleRequest($request)->isValid()) {
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_PRE_COMPLETE, $order);
         $this->getManager()->persist($order);
         $this->getManager()->flush();
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::ADDRESSING_COMPLETE, $order);
         return $this->complete();
     }
     return $this->renderStep($context, $order, $form);
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $request = $context->getRequest();
     $order = $this->getCurrentCart();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::SHIPPING_INITIALIZE, $order);
     $form = $this->createCheckoutShippingForm($order);
     if ($form->handleRequest($request)->isValid()) {
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::SHIPPING_PRE_COMPLETE, $order);
         $this->applyTransition(OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING, $order);
         $this->getManager()->persist($order);
         $this->getManager()->flush();
         $this->dispatchCheckoutEvent(SyliusCheckoutEvents::SHIPPING_COMPLETE, $order);
         return $this->complete();
     }
     return $this->renderStep($context, $order, $form);
 }
예제 #8
0
 public function displayAction(ProcessContextInterface $context)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $request = $context->getRequest();
     $siteManager = $this->container->get('ritsiga.site.manager');
     $convention = $siteManager->getCurrentSite();
     $student_delegation = $user->getStudentDelegation();
     $registration = $this->getDoctrine()->getRepository('AppBundle:Registration')->findOneBy(array('user' => $user, 'convention' => $convention));
     if ($user->getUniversity() == null || $user->getCollege() == null || $user->getStudentDelegation() == null) {
         $this->addFlash('warning', $this->get('translator')->trans('Debe completar su perfil para inscribirse en una asamblea'));
         return $this->redirectToRoute('fos_user_profile_edit');
     }
     if ($registration) {
         return $this->redirectToRoute('registration');
     }
     return $this->render(':frontend/registration/process:welcome.html.twig', array('convention' => $convention, 'user' => $user, 'student_delegation' => $student_delegation, 'context' => $context));
 }
예제 #9
0
 function it_must_not_dispatch_pre_and_post_payment_state_changed_if_state_not_changed(Request $request, ProcessContextInterface $context, GatewayInterface $gateway, EventDispatcherInterface $eventDispatcher)
 {
     $context->getRequest()->willReturn($request);
     $order = new Order();
     $paymentModel = new Payment();
     $paymentModel->setState(Payment::STATE_COMPLETED);
     $paymentModel->setOrder($order);
     $order->addPayment($paymentModel);
     $gateway->execute(Argument::type(GetStatus::class))->will(function ($args) use($order, $paymentModel) {
         $args[0]->markCaptured();
         $args[0]->setModel($paymentModel);
     });
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_INITIALIZE, Argument::type(GenericEvent::class))->shouldBeCalled();
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, Argument::type(GenericEvent::class))->shouldBeCalled();
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_COMPLETE, Argument::type(PurchaseCompleteEvent::class))->shouldBeCalled();
     $this->forwardAction($context)->shouldReturnAnInstanceOf(ActionResult::class);
 }
예제 #10
0
 /**
  * @param ProcessContextInterface $context
  * @return \Sylius\Bundle\FlowBundle\Process\Step\ActionResult|\Symfony\Component\HttpFoundation\Response
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     set_time_limit(600);
     $form = $this->createConfigurationForm();
     $request = $context->getRequest();
     $upgrade = $this->isCommonUpgrade();
     if ($upgrade) {
         return $this->complete();
     }
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $context->getStorage()->set('fullDatabase', $form->has('database') && $form->get('database')->has('chamilo_installer_database_drop_full') && $form->get('database')->get('chamilo_installer_database_drop_full')->getData());
         $this->get('chamilo_installer.yaml_persister')->dump($data);
         return $this->complete();
     }
     return $this->render('ChamiloInstallerBundle:Process/Step:configure.html.twig', array('form' => $form->createView(), 'is_upgrade' => $upgrade, 'scenario' => $this->getScenario()));
 }
예제 #11
0
 /**
  * @param ProcessContextInterface $context
  * @return null|\Sylius\Bundle\FlowBundle\Process\Step\ActionResult|Response
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $adminUser = $this->getDoctrine()->getRepository('ChamiloUserBundle:User')->findOneBy(array('username' => LoadAdminUserData::DEFAULT_ADMIN_USERNAME));
     if (!$adminUser) {
         throw new \RuntimeException("Admin user wasn't loaded in fixtures.");
     }
     $form = $this->createSetupForm();
     $form->get('admin')->setData($adminUser);
     $form->handleRequest($context->getRequest());
     if ($form->isValid()) {
         // pass "load demo fixtures" flag to the next step
         /*$context->getStorage()->set(
               'loadFixtures',
               $form->has('loadFixtures') && $form->get('loadFixtures')->getData()
           );*/
         $this->get('fos_user.user_manager')->updateUser($adminUser);
         // Setting portal parameters
         $settingsManager = $this->get('chamilo.settings.manager');
         $url = $this->get('chamilo_core.manager.access_url')->find(1);
         $settingsManager->setUrl($url);
         $settings = $settingsManager->loadSettings('platform');
         $parameters = array('institution' => $form->get('portal')->get('institution')->getData(), 'institution_url' => $form->get('portal')->get('institution_url')->getData(), 'site_name' => $form->get('portal')->get('site_name')->getData(), 'timezone' => $form->get('portal')->get('timezone')->getData());
         $settings->setParameters($parameters);
         $settingsManager->saveSettings('platform', $settings);
         $parameters = array('administrator_email' => $adminUser->getEmail(), 'administrator_name' => $adminUser->getFirstName(), 'administrator_surname' => $adminUser->getLastName(), 'administrator_phone' => $adminUser->getPhone());
         $settings->setParameters($parameters);
         $settingsManager->saveSettings('admin', $settings);
         /*$defaultCompanyName  = $configManager->get('oro_ui.application_name');
           $defaultCompanyTitle = $configManager->get('oro_ui.application_title');
           $companyName         = $form->get('company_name')->getData();
           $companyTitle        = $form->get('company_title')->getData();
           if (!empty($companyName) && $companyName !== $defaultCompanyName) {
               $configManager->set('oro_ui.application_name', $companyName);
           }
           if (!empty($companyTitle) && $companyTitle !== $defaultCompanyTitle) {
               $configManager->set('oro_ui.application_title', $companyTitle);
           }
           $configManager->flush();
           */
         return $this->complete();
     }
     return $this->render('ChamiloInstallerBundle:Process/Step:setup.html.twig', array('form' => $form->createView()));
 }
예제 #12
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $token = $this->getHttpRequestVerifier()->verify($context->getRequest());
     $this->getHttpRequestVerifier()->invalidate($token);
     $status = new GetStatus($token);
     $this->getPayum()->getGateway($token->getGatewayName())->execute($status);
     /** @var $payment PaymentInterface */
     $payment = $status->getFirstModel();
     $order = $payment->getOrder();
     // Should it be here??
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::PURCHASE_INITIALIZE, $order);
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, $order);
     $this->getDoctrine()->getManager()->flush();
     $event = new PurchaseCompleteEvent($payment);
     $this->dispatchEvent(SyliusCheckoutEvents::PURCHASE_COMPLETE, $event);
     if ($event->hasResponse()) {
         return $event->getResponse();
     }
     return $this->complete();
 }
예제 #13
0
 /**
  * {@inheritdoc}
  */
 public function displayAction(ProcessContextInterface $context)
 {
     $request = $context->getRequest();
     if ($request->query->has('action')) {
         $result = [];
         switch ($request->query->get('action')) {
             case 'createdb':
                 $connection = $this->get('doctrine')->getConnection();
                 $params = $connection->getParams();
                 $dbName = $params['dbname'];
                 unset($params['dbname']);
                 $tmpConnection = DriverManager::getConnection($params);
                 try {
                     $tmpConnection->getSchemaManager()->createDatabase($dbName);
                     $result['success'] = true;
                 } catch (\Exception $e) {
                     if (false !== strpos($e->getMessage(), 'database exists')) {
                         $result['success'] = true;
                     } else {
                         $result['success'] = false;
                         $result['message'] = $e->getMessage();
                     }
                 }
                 break;
             case 'migrations':
                 $migration = $this->get('csbill.installer.database.migration');
                 try {
                     $migration->migrate();
                     $result['success'] = true;
                 } catch (\Exception $e) {
                     $result['success'] = false;
                     $result['message'] = $e->getMessage();
                 }
                 break;
         }
         return new JsonResponse($result);
     }
     return $this->render('CSBillInstallBundle:Flow:install.html.twig');
 }
예제 #14
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $request = $context->getRequest();
     $form = $this->getForm();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $config = array();
         // sets the database details
         foreach ($data['database_config'] as $key => $param) {
             $key = sprintf('database_%s', $key);
             $config[$key] = $param;
         }
         // sets the database details
         foreach ($data['email_settings'] as $key => $param) {
             $key = sprintf('mailer_%s', $key);
             $config[$key] = $param;
         }
         $this->get('csbill.core.config_writer')->dump($config);
         return $this->complete();
     }
     return $this->render('CSBillInstallBundle:Flow:config.html.twig', array('form' => $form->createView()));
 }
예제 #15
0
 /**
  * {@inheritdoc}
  */
 public function forwardAction(ProcessContextInterface $context)
 {
     $token = $this->getHttpRequestVerifier()->verify($context->getRequest());
     $this->getHttpRequestVerifier()->invalidate($token);
     $status = new GetStatus($token);
     $this->getPayum()->getPayment($token->getPaymentName())->execute($status);
     /** @var $payment PaymentInterface */
     $payment = $status->getFirstModel();
     $order = $payment->getOrder();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::PURCHASE_INITIALIZE, $order);
     $nextState = $status->getValue();
     $stateMachine = $this->get('sm.factory')->get($payment, PaymentTransitions::GRAPH);
     if (null !== ($transition = $stateMachine->getTransitionToState($nextState))) {
         $stateMachine->apply($transition);
     }
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, $order);
     $this->getDoctrine()->getManager()->flush();
     $event = new PurchaseCompleteEvent($payment);
     $this->dispatchEvent(SyliusCheckoutEvents::PURCHASE_COMPLETE, $event);
     if ($event->hasResponse()) {
         return $event->getResponse();
     }
     return $this->complete();
 }
예제 #16
0
 function it_must_not_dispatch_pre_and_post_payment_state_changed_if_state_not_changed(Request $request, $factory, ProcessContextInterface $context, PaymentInterface $payment, EventDispatcherInterface $eventDispatcher, StateMachineInterface $sm)
 {
     $context->getRequest()->willReturn($request);
     $order = new Order();
     $paymentModel = new Payment();
     $paymentModel->setState(Payment::STATE_COMPLETED);
     $paymentModel->setOrder($order);
     $order->addPayment($paymentModel);
     $payment->execute(Argument::type('Sylius\\Bundle\\PayumBundle\\Payum\\Request\\GetStatus'))->will(function ($args) use($order, $paymentModel) {
         $args[0]->markCaptured();
         $args[0]->setModel($paymentModel);
     });
     $factory->get($paymentModel, PaymentTransitions::GRAPH)->willReturn($sm);
     $sm->getTransitionToState('completed')->willReturn(null);
     $sm->apply(PaymentTransitions::SYLIUS_COMPLETE)->shouldNotBeCalled();
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_INITIALIZE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled();
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_PRE_COMPLETE, Argument::type('Symfony\\Component\\EventDispatcher\\GenericEvent'))->shouldBeCalled();
     $eventDispatcher->dispatch(SyliusCheckoutEvents::PURCHASE_COMPLETE, Argument::type('Sylius\\Bundle\\CoreBundle\\Event\\PurchaseCompleteEvent'))->shouldBeCalled();
     $this->forwardAction($context)->shouldReturnAnInstanceOf('Sylius\\Bundle\\FlowBundle\\Process\\Step\\ActionResult');
 }
예제 #17
0
 /**
  * @param ProcessContextInterface $context
  * @return JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function displayAction(ProcessContextInterface $context)
 {
     set_time_limit(900);
     $request = $context->getRequest();
     $action = $request->query->get('action');
     switch ($action) {
         case 'upgrade':
             $configurationFile = $this->container->get('kernel')->getConfigurationFile();
             // If configuration.php exists then rename to configuratio.php.bak
             if (file_exists($configurationFile)) {
                 $fs = new Filesystem();
                 $fs->rename($configurationFile, $configurationFile . ".bak");
             }
             // Means it comes from chamilo 2.x
             return $this->handleAjaxAction('chamilo:platform:update', array('--force' => true));
             break;
         case 'pages':
             $this->handleAjaxAction('sonata:page:update-core-routes', array('--site' => array('all')));
             return $this->handleAjaxAction('sonata:page:create-snapshots', array('--site' => array('all')));
         case 'settings':
             return new JsonResponse(array('result' => true, 'exitCode' => 0));
             $settingsManager = $this->container->get('chamilo.settings.manager');
             $url = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:AccessUrl')->find(1);
             $settingsManager->installSchemas($url);
             return new JsonResponse(array('result' => true, 'exitCode' => 0));
             break;
         case 'assets':
             /*return $this->handleAjaxAction(
                   'oro:assets:install',
                   array('target' => './', '--exclude' => ['OroInstallerBundle'])
               );*/
             return $this->handleAjaxAction('assets:install', array('target' => './', '--symlink' => true, '--relative' => true));
         case 'assetic':
             return $this->handleAjaxAction('assetic:dump');
         case 'finish':
             $this->get('event_dispatcher')->dispatch(InstallerEvents::FINISH);
             // everything was fine - update installed flag in parameters.yml
             $dumper = $this->get('chamilo_installer.yaml_persister');
             $params = $dumper->parse();
             $params['system']['installed'] = date('c');
             $dumper->dump($params);
             // launch 'cache:clear' to set installed flag in DI container
             // suppress warning: ini_set(): A session is active. You cannot change the session
             // module's ini settings at this time
             error_reporting(E_ALL ^ E_WARNING);
             return $this->handleAjaxAction('cache:clear', array('--env' => 'prod', '--no-debug' => true));
     }
     // check if we have package installation step
     /*if (strpos($action, 'installerScript-') !== false) {
                 $scriptFile = $this->container->get(
                     'chamilo_installer.script_manager'
                 )->getScriptFileByKey(
                     str_replace('installerScript-', '', $action)
                 );
     
                 $scriptExecutor = new ScriptExecutor(
                     $this->getOutput(),
                     $this->container,
                     new CommandExecutor(
                         $this->container->getParameter('kernel.environment'),
                         $this->getOutput(),
                         $this->getApplication()
                     )
                 );
                 $scriptExecutor->runScript($scriptFile);
     
                 return new JsonResponse(array('result' => true));
             }*/
     $scriptManager = $this->container->get('chamilo_installer.script_manager');
     return $this->render('ChamiloInstallerBundle:Process/Step:installation.html.twig', array('is_upgrade' => $this->isCommonUpgrade(), 'scenario' => $this->getScenario(), 'loadFixtures' => false, 'installerScripts' => $scriptManager->getScriptLabels()));
 }