public static function enableInstallMode(CommandEvent $event) { if (!file_exists(SystemUtil::getInstallDoneFilePath())) { SystemUtil::enableInstallMode(); } $event->getIO()->write('CampaignChain: Enabled install mode.'); }
public function preUp(Schema $schema) { $userImg = file_get_contents(SystemUtil::getRootDir() . 'vendor/campaignchain/core/Resources/public/images/default_user.png'); /** @var FileUploadService $fileUploadService */ $fileUploadService = $this->container->get('campaignchain.core.service.file_upload'); $fileUploadService->storeImage('default_user.png', $userImg); }
public function preUp(Schema $schema) { $themeDataDir = SystemUtil::getRootDir() . 'vendor/campaignchain/core/Resources/data/theme/'; /** @var FileUploadService $fileUploadService */ $fileUploadService = $this->container->get('campaignchain.core.service.file_upload'); $faviconContent = file_get_contents($themeDataDir . 'favicon.ico'); $newFaviconPath = Theme::STORAGE_PATH . '/favicon.ico'; $fileUploadService->storeImage($newFaviconPath, $faviconContent); $logoContent = file_get_contents($themeDataDir . 'logo.png'); $newLogoPath = Theme::STORAGE_PATH . '/logo.png'; $fileUploadService->storeImage($newLogoPath, $logoContent); }
public function resetSystemAction(Request $request) { $formData = array(); $form = $this->createFormBuilder($formData)->add('confirm', 'checkbox', array('label' => 'Confirm', 'required' => false, 'data' => false, 'attr' => array('align_with_widget' => true, 'help_text' => 'Please confirm that you aware that all data will be lost.')))->getForm(); $form->handleRequest($request); if ($form->isValid() && !$form['confirm']->getData()) { $this->get('session')->getFlashBag()->add('warning', 'Please confirm.'); } elseif ($form->isValid() && $form['confirm']->getData()) { SystemUtil::resetApp(); header('Location: ../../campaignchain/install.php'); exit; } return $this->render('CampaignChainCoreBundle:Base:new.html.twig', array('page_title' => 'Reset System', 'form' => $form->createView(), 'form_submit_label' => 'Reset', 'blockui' => true)); }
/** * @param array $files * @param bool $doDrop */ public function load(array $files, $doDrop = true) { try { $this->em->getConnection()->beginTransaction(); $userProcessor = new UserProcessor(realpath(SystemUtil::getRootDir() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR), $this->userService, $this->mimeTypeGuesser, $this->extensionGuesser); // Create Alice manager and fixture set $this->fixtureManager->addProcessor($userProcessor); $set = $this->fixtureManager->createFixtureSet(); // Add the fixture files foreach ($files as $file) { $set->addFile($file, 'yaml'); } $set->setDoDrop($doDrop); $set->setDoPersist(true); $set->setSeed(1337 + 42); // TODO Keep Module data intact $bundles = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Bundle")->findAll(); $modules = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Module")->findAll(); if ($this->fixtureManager->load($set)) { // TODO: Restore modules data foreach ($bundles as $bundle) { $this->em->persist($bundle); } foreach ($modules as $module) { $this->em->persist($module); } $this->em->flush(); $this->em->getConnection()->commit(); return true; } return false; } catch (\Exception $e) { $this->em->getConnection()->rollback(); $this->setException($e); return false; } }
public function getGlobals() { if (SystemUtil::isInstallMode()) { return array(); } return array("campaignchain_user_time_format" => array('moment_js' => $this->datetime->getUserTimeFormat()), "campaignchain_user_datetime_format" => array('moment_js' => $this->datetime->getUserDatetimeFormat('moment_js'), 'iso8601' => $this->container->get('session')->get('campaignchain.dateFormat') . ' ' . $this->container->get('session')->get('campaignchain.timeFormat')), "campaignchain_user_timezone_offset" => $this->getGlobalTimezoneOffset(), "campaignchain_user_timezone_abbreviation" => $this->getGlobalTimezoneAbbreviation(), 'campaignchain_system' => $this->system(), 'campaignchain_theme' => $this->theme(), 'campaignchain_env' => $this->container->getParameter('campaignchain.env'), 'campaignchain_core_scheduler_interval' => $this->container->getParameter('campaignchain_core.scheduler.interval'), 'campaignchain_relative_start_date' => new \DateTime(Campaign::RELATIVE_START_DATE), 'campaignchain_layout' => $this->getGlobalLayout(), 'campaignchain_is_first_login' => $this->isFirstLogin()); }
protected function initializeContainer() { \CampaignChain\CoreBundle\Util\SystemUtil::redirectInstallMode(); parent::initializeContainer(); date_default_timezone_set('UTC'); }
public function execute($parameters) { $this->command->createAdminUser($parameters); SystemUtil::disableInstallMode(); }
/** * Puts the CampaignChain app into same status as after a fresh * <code> * composer create-project * </code> * installation. */ public static function resetApp() { // Set install mode. SystemUtil::enableInstallMode(); $currentDir = getcwd(); chdir(self::getRootDir()); ob_start(); // Drop all tables $command = 'php app/console doctrine:schema:drop --force --full-database'; system($command, $output); // Run composer post install command. $command = 'composer run-script post-install-cmd'; system($command, $output); ob_get_clean(); chdir($currentDir); }