Beispiel #1
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()));
 }
 public function forwardAction(ProcessContextInterface $context)
 {
     $adminUser = $this->getDoctrine()->getRepository('OroUserBundle:User')->findOneBy(array('username' => LoadAdminUserData::DEFAULT_ADMIN_USERNAME));
     if (!$adminUser) {
         throw new \RuntimeException("Admin user wasn't loaded in fixtures.");
     }
     $form = $this->createForm('diamante_installer_setup');
     $form->setData($adminUser);
     $form->handleRequest($this->getRequest());
     if ($form->isValid()) {
         $context->getStorage()->set('loadFixtures', false);
         $this->get('oro_user.manager')->updateUser($adminUser);
         /** @var ConfigManager $configManager */
         $configManager = $this->get('oro_config.global');
         $defaultOrganizationName = $configManager->get('oro_ui.organization_name');
         $organizationName = $form->get('organization_name')->getData();
         if (!empty($organizationName) && $organizationName !== $defaultOrganizationName) {
             $organizationManager = $this->get('oro_organization.organization_manager');
             $organization = $organizationManager->getOrganizationByName('default');
             $organization->setName($organizationName);
             $organizationManager->updateOrganization($organization);
         }
         $defaultAppURL = $configManager->get('oro_ui.application_url');
         $applicationURL = $form->get('application_url')->getData();
         if (!empty($applicationURL) && $applicationURL !== $defaultAppURL) {
             $configManager->set('oro_ui.application_url', $applicationURL);
         }
         $configManager->flush();
         $this->runCommand('diamante:desk:data');
         $this->runCommand('oro:migration:data:load', ['--bundles' => ['DiamanteDistributionBundle']]);
         return $this->complete();
     }
     return $this->render('DiamanteDistributionBundle:Process/Step:setup.html.twig', array('form' => $form->createView()));
 }
Beispiel #3
0
 public function displayAction(ProcessContextInterface $context)
 {
     set_time_limit(600);
     switch ($this->getRequest()->query->get('action')) {
         case 'cache':
             // 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('--no-optional-warmers' => true));
             /*case 'clear-config':
               return $this->handleAjaxAction('oro:entity-config:cache:clear', array('--no-warmup' => true));*/
             /*case 'clear-extend':
               return $this->handleAjaxAction('oro:entity-extend:cache:clear', array('--no-warmup' => true));*/
         /*case 'clear-config':
           return $this->handleAjaxAction('oro:entity-config:cache:clear', array('--no-warmup' => true));*/
         /*case 'clear-extend':
           return $this->handleAjaxAction('oro:entity-extend:cache:clear', array('--no-warmup' => true));*/
         case 'schema-drop':
             return $this->handleAjaxAction('doctrine:schema:drop', array('--force' => true, '--full-database' => $context->getStorage()->get('fullDatabase', false)));
         case 'schema-update':
             // Creating identities:
             return $this->handleAjaxAction('doctrine:schema:update', array('--force' => true));
             // Run migrations
             return $this->handleAjaxAction('oro:migration:load', array('--force' => true));
         case 'fixtures':
             return $this->handleAjaxAction('oro:migration:data:load', array('--no-interaction' => true));
             /*case 'workflows':
                   return $this->handleAjaxAction('oro:workflow:definitions:load');
               case 'processes':
                   return $this->handleAjaxAction('oro:process:configuration:load');*/
     }
     return $this->render('ChamiloInstallerBundle:Process/Step:schema.html.twig', ['is_upgrade' => $this->isCommonUpgrade(), 'scenario' => $this->getScenario()]);
 }
 /**
  * @param ProcessContextInterface $context
  * @return JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function displayAction(ProcessContextInterface $context)
 {
     set_time_limit(900);
     $action = $this->getRequest()->query->get('action');
     switch ($action) {
         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 'fixtures':
             return $this->handleAjaxAction('oro:migration:data:load', array('--fixtures-type' => 'demo'));
         case 'navigation':
             return $this->handleAjaxAction('oro:navigation:init');
             //            case 'js-routing':
             //                return $this->handleAjaxAction('fos:js-routing:dump', array('--target' => 'js/routes.js'));
         //            case 'js-routing':
         //                return $this->handleAjaxAction('fos:js-routing:dump', array('--target' => 'js/routes.js'));
         case 'localization':
             //return $this->handleAjaxAction('oro:localization:dump');
         //return $this->handleAjaxAction('oro:localization:dump');
         case 'assets':
             /*return $this->handleAjaxAction(
                   'oro:assets:install',
                   array('target' => './', '--exclude' => ['OroInstallerBundle'])
               );*/
             $settingsManager = $this->container->get('chamilo.settings.manager');
             $url = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:AccessUrl')->find(1);
             $settingsManager->installSchemas($url);
             return $this->handleAjaxAction('assets:install', array('target' => './', '--symlink' => true, '--relative' => true));
         case 'assetic':
             return $this->handleAjaxAction('assetic:dump');
         case 'translation':
             //return $this->handleAjaxAction('oro:translation:dump');
         //return $this->handleAjaxAction('oro:translation:dump');
         case 'requirejs':
             //return $this->handleAjaxAction('oro:requirejs:build', array('--ignore-errors' => true));
         //return $this->handleAjaxAction('oro:requirejs:build', array('--ignore-errors' => true));
         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));
     }
     return $this->render('ChamiloInstallerBundle:Process/Step:installation.html.twig', array('loadFixtures' => $context->getStorage()->get('loadFixtures'), 'installerScripts' => $this->container->get('chamilo_installer.script_manager')->getScriptLabels()));
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 public function displayAction(ProcessContextInterface $context)
 {
     $order = $this->getCurrentCart();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::PURCHASE_INITIALIZE, $order);
     /** @var $payment PaymentInterface */
     $payment = $order->getPayments()->last();
     $captureToken = $this->getTokenFactory()->createCaptureToken($payment->getMethod()->getGateway(), $payment, $context->getProcess()->getForwardRoute(), array('stepName' => $this->getName()));
     return new RedirectResponse($captureToken->getTargetUrl());
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function displayAction(ProcessContextInterface $context)
 {
     $order = $this->getCurrentCart();
     $this->dispatchCheckoutEvent(SyliusCheckoutEvents::SHIPPING_INITIALIZE, $order);
     $form = $this->createCheckoutShippingForm($order);
     if (empty($this->zones)) {
         return $this->proceed($context->getPreviousStep()->getName());
     }
     return $this->renderStep($context, $order, $form);
 }
Beispiel #7
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));
 }
Beispiel #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();
     $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));
 }
 public function displayAction(ProcessContextInterface $context)
 {
     set_time_limit(600);
     switch ($this->getRequest()->query->get('action')) {
         case 'cache':
             // 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', ['--no-optional-warmers' => true]);
         case 'clear-config':
             return $this->handleAjaxAction('oro:entity-config:cache:clear', ['--no-warmup' => true]);
         case 'clear-extend':
             return $this->handleAjaxAction('oro:entity-extend:cache:clear', ['--no-warmup' => true]);
         case 'schema-drop':
             return $this->handleAjaxAction('doctrine:schema:drop', ['--force' => true, '--full-database' => $context->getStorage()->get('fullDatabase', false)]);
         case 'schema-update':
             return $this->handleSchemaUpdate();
         case 'workflows':
             return $this->handleAjaxAction('oro:workflow:definitions:load');
         case 'processes':
             return $this->handleAjaxAction('oro:process:configuration:load');
         case 'fixtures':
             return $this->handleFixtures();
         case 'navigation':
             return $this->handleAjaxAction('oro:navigation:init');
         case 'js-routing':
             return $this->handleAjaxAction('fos:js-routing:dump', ['--target' => 'js/routes.js']);
         case 'localization':
             return $this->handleAjaxAction('oro:localization:dump');
         case 'assets':
             return $this->handleAjaxAction('oro:assets:install', array('target' => './', '--symlink', '--exclude' => ['OroInstallerBundle']));
         case 'assetic':
             return $this->handleAjaxAction('assetic:dump');
         case 'translation':
             return $this->handleAjaxAction('oro:translation:dump');
         case 'requirejs':
             return $this->handleAjaxAction('oro:requirejs:build', ['--ignore-errors' => true]);
         case 'finish':
             $this->get('event_dispatcher')->dispatch(InstallerEvents::FINISH);
             // everything was fine - update installed flag in parameters.yml
             $dumper = $this->get('oro_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');
     }
     return $this->render('DiamanteDistributionBundle:Process/Step:initialization.html.twig');
 }
Beispiel #10
0
 public function forwardAction(ProcessContextInterface $context)
 {
     set_time_limit(600);
     $form = $this->createConfigurationForm();
     $form->handleRequest($this->getRequest());
     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()));
 }
Beispiel #11
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);
 }
Beispiel #12
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);
 }
Beispiel #13
0
 /**
  * {@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()]);
 }
 public function forwardAction(ProcessContextInterface $context)
 {
     $form = $this->createForm('oro_installer_setup');
     $form->handleRequest($this->getRequest());
     if ($form->isValid()) {
         // pass "load demo fixtures" flag to the next step
         $context->getStorage()->set('loadFixtures', $form->has('loadFixtures') && $form->get('loadFixtures')->getData());
         $user = $form->getData();
         $role = $this->getDoctrine()->getRepository('OroUserBundle:Role')->findOneBy(array('role' => 'ROLE_ADMINISTRATOR'));
         $businessUnit = $this->getDoctrine()->getRepository('OroOrganizationBundle:BusinessUnit')->findOneBy(array('name' => 'Main'));
         $user->setEnabled(true)->setOwner($businessUnit)->addBusinessUnit($businessUnit)->addRole($role);
         $this->get('oro_user.manager')->updateUser($user);
         return $this->complete();
     }
     return $this->render('OroInstallerBundle:Process/Step:setup.html.twig', array('form' => $form->createView()));
 }
Beispiel #15
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);
 }
Beispiel #16
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);
 }
Beispiel #17
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));
 }
Beispiel #18
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()));
 }
Beispiel #19
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();
 }
Beispiel #20
0
 /**
  * @param ProcessContextInterface $context
  *
  * @return mixed
  */
 protected function handleDropDatabase(ProcessContextInterface $context)
 {
     $dropDatabase = $context->getStorage()->get('dropDatabase', 'none');
     if ($dropDatabase === 'app') {
         $exitCode = 0;
         $managers = $this->get('doctrine')->getManagers();
         foreach ($managers as $name => $manager) {
             if ($manager instanceof EntityManager) {
                 $exitCode = $this->runCommand('doctrine:schema:drop', array('--force' => true, '--em' => $name));
                 if ($exitCode) {
                     break;
                 }
             }
         }
         return $this->getAjaxActionResponse($exitCode);
     } elseif ($dropDatabase === 'full') {
         return $this->handleAjaxAction('doctrine:schema:drop', array('--force' => true, '--full-database' => true));
     } else {
         return true;
     }
 }
Beispiel #21
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');
 }
 public function displayAction(ProcessContextInterface $context)
 {
     set_time_limit(900);
     switch ($this->getRequest()->query->get('action')) {
         case 'fixtures':
             return $this->handleAjaxAction('oro:demo:fixtures:load');
         case 'search':
             return $this->handleAjaxAction('oro:search:create-index');
         case 'navigation':
             return $this->handleAjaxAction('oro:navigation:init');
         case 'js-routing':
             return $this->handleAjaxAction('fos:js-routing:dump', array('--target' => 'js/routes.js'));
         case 'localization':
             return $this->handleAjaxAction('oro:localization:dump');
         case 'assets':
             return $this->handleAjaxAction('assets:install', array('target' => './'));
         case 'assetic':
             return $this->handleAjaxAction('assetic:dump');
         case 'assetic-oro':
             return $this->handleAjaxAction('oro:assetic:dump');
         case 'translation':
             return $this->handleAjaxAction('oro:translation:dump');
         case 'requirejs':
             return $this->handleAjaxAction('oro:requirejs:build');
         case 'finish':
             $this->get('event_dispatcher')->dispatch(InstallerEvents::FINISH);
             // everything was fine - update installed flag in parameters.yml
             $dumper = $this->get('oro_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');
     }
     return $this->render('OroInstallerBundle:Process/Step:installation.html.twig', array('loadFixtures' => $context->getStorage()->get('loadFixtures')));
 }
Beispiel #23
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()));
 }
Beispiel #24
0
 /**
  * Redirect to step display action.
  *
  * @param ProcessInterface $process
  * @param StepInterface    $step
  * @param ParameterBag     $queryParameters
  *
  * @return RedirectResponse
  */
 protected function redirectToStepDisplayAction(ProcessInterface $process, StepInterface $step, ParameterBag $queryParameters = null)
 {
     $this->context->addStepToHistory($step->getName());
     if (null !== ($route = $process->getDisplayRoute())) {
         $url = $this->router->generate($route, array_merge($process->getDisplayRouteParams(), array('stepName' => $step->getName()), $queryParameters ? $queryParameters->all() : array()));
         return new RedirectResponse($url);
     }
     // Default parameters for display route
     $routeParameters = array('scenarioAlias' => $process->getScenarioAlias(), 'stepName' => $step->getName());
     if (null !== $queryParameters) {
         $routeParameters = array_merge($queryParameters->all(), $routeParameters);
     }
     return new RedirectResponse($this->router->generate('sylius_flow_display', $routeParameters));
 }
Beispiel #25
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();
 }
Beispiel #26
0
 /**
  * @param ProcessInterface $process
  * @param string           $scenarioAlias
  *
  * @return RedirectResponse
  */
 protected function goToLastValidStep(ProcessInterface $process, $scenarioAlias)
 {
     //the step we are supposed to display was not found in the history.
     if (null === $this->context->getPreviousStep()) {
         //there is no previous step go to start
         return $this->start($scenarioAlias);
     }
     //we will go back to previous step...
     $history = $this->context->getStepHistory();
     if (empty($history)) {
         //there is no history
         return $this->start($scenarioAlias);
     }
     $step = $process->getStepByName(end($history));
     $this->context->initialize($process, $step);
     return $this->redirectToStepDisplayAction($process, $step);
 }
 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');
 }
Beispiel #28
0
 /**
  * Execute continue action of given step.
  *
  * @param Request $request
  * @param string  $scenarioAlias
  * @param string  $stepName
  *
  * @return Response
  */
 public function forwardAction(Request $request, $scenarioAlias, $stepName)
 {
     $this->processContext->setRequest($request);
     return $this->processCoordinator->forward($scenarioAlias, $stepName);
 }
Beispiel #29
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()));
 }