Publish a site using

@param InputInterface $input
@param OutputInterface $output
@param string $profile_name
422287
protected function publish(InputInterface $input, OutputInterface $output, $profile_name) {
        $output->writeln('<info>Publishing to '.$profile_name.'...</info>');
        $parser = new Parser();
        $profile_config = $parser->parse(file_get_contents('deployement/publish_'.$profile_name.'.yml'));

        if(!CommandUtils::checkCommand('rsync')) {
            $output->writeln('<error>rsync not installed, please install it. Exiting now...</error>');
            return 1;
        }
        if($profile_config['use_pem']) {
            $command = 'rsync -rltDvze "ssh -i '.$profile_config['pem_path'].'" ';
        }
        else {
            $command = 'rsync -rltDvz ';
        }

        $is_full = $input->getOption('full');
        if(!$is_full) {
            foreach ($profile_config['exclude'] as $exclude) {
                $command .= '--exclude \'' . $exclude . '\' ';
            }
        }

        if(substr($profile_config['remote_dir'],-1,1) != '/') {
            $profile_config['remote_dir'] .= '/';
        }

        $command .= '. '.$profile_config['username'].'@'.$profile_config['host'].':'.$profile_config['remote_dir'];


        $chmod = array(
            'chown -R '.$profile_config['username'].':'.$profile_config['remote_group'].' '.$profile_config['remote_dir'],
            'chmod -R 750 '.$profile_config['remote_dir'],
            'chmod -R 770 '.$profile_config['remote_dir'].'app/logs',
            'chmod -R 770 '.$profile_config['remote_dir'].'app/proxies',
            'chmod -R 770 '.$profile_config['remote_dir'].'app/public',
            'chmod -R 770 '.$profile_config['remote_dir'].'app/tmp'
        );

        $permissions_commands = 'ssh '
            .($profile_config['use_pem']?'-i '.$profile_config['pem_path']:'')
            .' '
            .$profile_config['username']
            .'@'
            .$profile_config['host']
            .' '
            .($profile_config['use_sudo']?'sudo':'')
            .' \'';
        foreach($chmod as $c) {
                $permissions_commands .= $c. ' && ';
        }
        $permissions_commands = substr($permissions_commands, 0, -3);
        $permissions_commands .= '\'';

        // PUBLISH
        $dump_commands = $input->getOption('dump-commands');
        if($dump_commands) {
            $output->writeln($command);
        }
        else {
            $output->writeln('Publishing with rsync, please wait (it may take a while)...');
            passthru($command);
            $output->writeln('<info>PUBLISH DONE</info>');
        }

        // OPTIMIZE
        $run_optimize = $profile_config['always_run_optimize'];
        if($run_optimize) {
            $output->writeln('Run optimizations...');
            $command = 'ssh '
                .($profile_config['use_pem']?'-i '.$profile_config['pem_path']:'')
                .' '
                .$profile_config['username']
                .'@'
                .$profile_config['host']
                .' '
                .'\'cd '.$profile_config['remote_dir'].' && vendor/bin/pff deploy:optimize\'';

            if($dump_commands) {
                $output->writeln($command);
            }
            else {
                passthru($command);
            }
            $output->writeln('<info>OPTIMIZE DONE</info>');
        }

        // PERMISSIONS
        $output->writeln('Setting permissions...');
        if($dump_commands) {
            $output->writeln($permissions_commands);
        }
        else {
            passthru($permissions_commands);
        }
        $output->writeln('<info>PERMISSIONS DONE</info>');

    }
817841
public function BuildProfile() {
      if (!is_object($this->User))
         throw new Exception(T('Cannot build profile information if user is not defined.'));
      
      $Session = Gdn::Session();
      if (strpos($this->CssClass, 'Profile') === FALSE)
         $this->CssClass .= ' Profile';
      $this->Title(Gdn_Format::Text($this->User->Name));
      
      if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
         // Javascript needed
         $this->AddJsFile('jquery.jcrop.pack.js');
         $this->AddJsFile('profile.js');
         $this->AddJsFile('jquery.gardenmorepager.js');
         $this->AddJsFile('activity.js');
         
         // Build activity URL
         $ActivityUrl = 'profile/activity/';
         if ($this->User->UserID != $Session->UserID)
            $ActivityUrl = UserUrl($this->User, '', 'activity');
         
         // Show activity?
         if (C('Garden.Profile.ShowActivities', TRUE))
            $this->AddProfileTab(T('Activity'), $ActivityUrl, 'Activity', Sprite('SpActivity').' '.T('Activity'));
            
         // Show notifications?
         if ($this->User->UserID == $Session->UserID) {
            $Notifications = T('Notifications');
            $NotificationsHtml = Sprite('SpNotifications').' '.$Notifications;
            $CountNotifications = $Session->User->CountNotifications;
            if (is_numeric($CountNotifications) && $CountNotifications > 0)
               $NotificationsHtml .= ' <span class="Aside"><span class="Count">'.$CountNotifications.'</span></span>';
               
            $this->AddProfileTab($Notifications, 'profile/notifications', 'Notifications', $NotificationsHtml);
         }
         
         // Show invitations?
         if (C('Garden.Registration.Method') == 'Invitation')
            $this->AddProfileTab(T('Invitations'), 'profile/invitations', 'InvitationsLink');
         
         $this->FireEvent('AddProfileTabs');
      }
      
      return TRUE;
   }
1339986
protected function publish_ssh(OutputInterface $output, $target)
    {
        // Get FTP config
        $config = $this->config->get('ssh');

        // Ensure there isn't a leading slash
        $remote_dir = ltrim($config['remote_dir'], '/');

        // Shell command
        $output->writeln(shell_exec("rsync -avze 'ssh -p {$config['port']}' {$target} {$config['user']}@{$config['host']}:{$remote_dir} --exclude .DS_Store --exclude downloads.json --exclude cache/"));

        return true;
    }
279839
public function execute(InputInterface $input, OutputInterface $output)
    {
        $app = $this->getSilexApplication();
        $view = $input->getArgument('view');
        $dir = $input->getArgument('dir');
        $type = $input->getArgument('type');

        $author = $input->getOption('author');
        
        if (!$author) {
            if (isset($app['author.name'])) {
                $author = $app['author.name'];
            } else {
                $author = 'Author';
            }
        }

        $email = $input->getOption('email');

        if (!$email) {
            if (isset($app['author.email'])) {
                $email = $app['author.email'];
            } else {
                $email = 'author@email.com';
            }
        }
        
        try {
            $app['singular.service.front_view']->create($view, $dir, $type, $author, $email);
            $output->writeln(sprintf('<info>View "%s" criada com sucesso!</info>',$view));
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
        }

    }
305470
public function execute(InputInterface $input, OutputInterface $output)
    {
        $host = $input->getArgument('host');
        $ip = $input->getArgument('ip');

        $this->hostFile->add($host, $ip);

        $output->writeLn("\"$ip $host\" was added to file.");
    }
1345910
public function profileEnd($title = null, array $context = [])
    {
        if (!$this->activeKey) {
            return;
        }

        list($category, $name) = explode('|', $this->activeKey);

        if (isset($this->profiles[$category][$name])) {
            $data = $this->profiles[$category][$name];

            $old = $data['_profile_stats'];
            $data['_profile_stats'] = PhpHelper::runtime($old['startTime'], $old['startMem']);
            $data['_profile_end'] = $context;

            $title = $category . ' - ' . ($title ?: $name);

            $this->activeKey = null;
            $this->log(Logger::DEBUG, $title, $data);
        }
    }
19439
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $aliasId = $input->getArgument('aliasId');
        $limit = 20;

        $objectManager = $this->getContainer()->get('object_manager');
        $siteClass = $this->getContainer()->getParameter('open_orchestra_model.document.site.class');
        $nodeClass = $this->getContainer()->getParameter('open_orchestra_model.document.node.class');

        $site = $objectManager->getRepository($siteClass)
            ->findOneBy(array(
                'aliases.'.$aliasId => array('$exists' => true)
                )
            );

        if($site instanceof $siteClass) {
            $aliases = $site->getAliases();
            if ($aliases->containsKey($aliasId)) {
                $siteId = $site->getSiteId();
                $language = $aliases[$aliasId]->getLanguage();
                $lastAlias = true;
                foreach ($aliases as $key => $alias) {
                    if ($alias->getLanguage() == $language && $key != $aliasId) {
                        $lastAlias = false;
                    }
                }
            }

            if ($lastAlias) {
                $io->comment('Remove use references of nodes');

                $deleteSiteTools = $this->getContainer()->get('open_orchestra_backoffice.command.orchestra_delete_site_tools');

                $nodes = $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->getQuery()->execute();

                $usedInNodes = $deleteSiteTools->findUsageReferenceInOtherSite($siteId, $nodes);
                if (!empty($usedInNodes)) {
                    $io->section('Usage of nodes in other sites');
                    $deleteSiteTools->displayUsedReferences($io, $usedInNodes);
                    throw new \RuntimeException('You should remove usage of nodes before remove alias ' . $aliasId);
                }

                $count = count($nodes);

                for ($skip = 0; $skip < $count; $skip += $limit) {
                    $nodes = $objectManager->createQueryBuilder($nodeClass)
                        ->field('siteId')->equals($siteId)
                        ->field('language')->equals($language)
                        ->sort('id', 'asc')
                        ->skip($skip)
                        ->limit($limit)
                        ->getQuery()->execute();
                    foreach ($nodes as $node) {
                        $this->getContainer()->get('open_orchestra_backoffice.reference.manager')->removeReferencesToEntity($node);
                    }
                    $objectManager->clear();
                }

                $io->comment('Remove nodes');
                $objectManager->createQueryBuilder($nodeClass)
                    ->field('siteId')->equals($siteId)
                    ->field('language')->equals($language)
                    ->remove()->getQuery()->execute();
            }

            $site->removeAlias($aliases->get($aliasId));
            $objectManager->persist($site);
            $objectManager->flush();

        }
    }
521780
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $configFilesOption = $input->getOption('config');
        $outputOption = $input->getOption('output');
        $formatOption = $input->getOption('format');

        '@phan-var string $configFilesOption';
        '@phan-var string $outputOption';
        '@phan-var string $formatOption';

        $configFiles       = $this->getPossibleConfigFiles($configFilesOption);
        $configuration     = $this->linterConfigurationLocator->loadConfiguration($configFiles);
        $paths             = $input->getArgument('paths') ?: $configuration->getPaths();
        $outputTarget      = $input->getOption('output');
        $exitWithExitCode  = $input->getOption('exit-code') || $input->getOption('fail-on-warnings');

        '@phan-var string[] $paths';

        if (false == $outputTarget) {
            throw new BadOutputFileException('Bad output file.');
        }

        if ($outputOption === '-') {
            $reportOutput = $output;
        } else {
            $fileHandle = fopen($outputOption, 'w');
            if ($fileHandle === false) {
                throw new \Exception("could not open file '${outputOption}' for writing");
            }

            $reportOutput = new StreamOutput($fileHandle);
        }

        $logger = $this->loggerBuilder->createLogger($formatOption, $reportOutput, $output);

        $report   = new Report();
        $patterns = $configuration->getFilePatterns();

        $files = $this->finder->getFilenames($paths, $patterns, new CallbackFinderObserver(function ($name) use ($logger) {
            $logger->notifyFileNotFound($name);
        }));
        $logger->notifyFiles($files);

        foreach ($files as $filename) {
            $logger->notifyFileStart($filename);
            $fileReport = $this->linter->lintFile($filename, $report, $configuration, $logger);
            $logger->notifyFileComplete($filename, $fileReport);
        }

        $logger->notifyRunComplete($report);

        $exitCode = 0;
        if ($report->countIssuesBySeverity(Issue::SEVERITY_ERROR) > 0) {
            $exitCode = 2;
        } else if ($exitWithExitCode && $report->countIssues() > 0) {
            $exitCode = 2;
        }

        $this->eventDispatcher->addListener(
            ConsoleEvents::TERMINATE,
            function (ConsoleTerminateEvent $event) use ($exitCode) {
                $event->setExitCode($exitCode);
            }
        );
    }
858638
public function outputProfiling($blnPrintOutput = true)
    {
        $strPath = isset($_SERVER['REQUEST_URI']) ?
            $_SERVER['REQUEST_URI'] :
            $_SERVER['PHP_SELF'];

        $strOut = '<div class="qDbProfile">';
        if ($this->blnEnableProfiling) {
            $strOut .= sprintf('<form method="post" id="frmDbProfile%s" action="%s/profile.php"><div>',
                $this->intDatabaseIndex, QCUBED_PHP_URL);
            $strOut .= sprintf('<input type="hidden" name="strProfileData" value="%s" />',
                base64_encode(serialize($this->strProfileArray)));
            $strOut .= sprintf('<input type="hidden" name="intDatabaseIndex" value="%s" />', $this->intDatabaseIndex);
            $strOut .= sprintf('<input type="hidden" name="strReferrer" value="%s" /></div></form>',
                htmlentities($strPath));

            $intCount = round(count($this->strProfileArray));
            if ($intCount == 0) {
                $strQueryString = 'No queries';
            } else {
                if ($intCount == 1) {
                    $strQueryString = '1 query';
                } else {
                    $strQueryString = $intCount . ' queries';
                }
            }

            $strOut .= sprintf('<b>PROFILING INFORMATION FOR DATABASE CONNECTION #%s</b>: %s performed.  Please <a href="#" onclick="var frmDbProfile = document.getElementById(\'frmDbProfile%s\'); frmDbProfile.target = \'_blank\'; frmDbProfile.submit(); return false;">click here to view profiling detail</a><br />',
                $this->intDatabaseIndex, $strQueryString, $this->intDatabaseIndex);
        } else {
            $strOut .= '<form></form><b>Profiling was not enabled for this database connection (#' . $this->intDatabaseIndex . ').</b>  To enable, ensure that ENABLE_PROFILING is set to TRUE.';
        }
        $strOut .= '</div>';

        $strOut .= '<script>$j(function() {$j(".qDbProfile").draggable();});</script>';    // make it draggable so you can move it out of the way if needed.

        if ($blnPrintOutput) {
            print ($strOut);
            return null;
        } else {
            return $strOut;
        }
    }
429224
protected function _setProfile() {
        $projectName = basename(dirname(realpath(APPLICATION_PATH)));
        $profileName = $projectName . '_' . APPLICATION_ENV;

        $this->_profile = $profileName;
    }
69039
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;

        /** @var $repository Repository */
        $repository = $this->getContainer()->get('ezpublish.api.repository');

        /** @var $contentTypeService ContentTypeService */
        $contentTypeService = $repository->getContentTypeService();
        /** @var $contentLanguageService LanguageService */
        $contentLanguageService = $repository->getContentLanguageService();

        /** @var $questionHelper QuestionHelper */
        $questionHelper = $this->getHelper('question');

        $struct = array();

        $struct['contentTypeGroup'] = $this->getContentTypeGroup($contentTypeService, $questionHelper);
        $struct['contentTypeIdentifier'] = $this->getContentTypeIdentifier($questionHelper);
        $struct['contentTypeName'] = $this->getContentTypeName($questionHelper);
        $struct['contentTypeMainLanguage'] = $this->getContentTypeMainLanguage($contentLanguageService, $questionHelper);
        $struct['contentTypeNameSchema'] = $this->getContentTypeNameSchema($questionHelper);
        $struct['fields'] = array();

        while (true) {
            $struct['fields'][] = $this->getContentTypeField($questionHelper, $struct['contentTypeMainLanguage']);
            $question = new ConfirmationQuestion(
                '<question>Do you want to add new field?</question> ',
                false
            );

            if (!$questionHelper->ask($input, $output, $question)) {
                $output->writeln('');
                break;
            }
        }

        /** @var $configResolver ConfigResolver */
        $configResolver = $this->getContainer()->get('ezpublish.config.resolver');
        $adminID = $configResolver->getParameter('adminid', 'smile_ez_tools');

        $contentTypeService = new ContentType($repository);
        $contentTypeService->setAdminID($adminID);
        try {
            $contentTypeService->add($struct);
            $output->writeln("<info>Content type created</info>");
        } catch (UnauthorizedException $e) {
            $output->writeln("<error>" . $e->getMessage() . "</error>");
        } catch (ForbiddenException $e ) {
            $output->writeln("<error>" . $e->getMessage() . "</error>");
        }
    }
1326830
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Registered version providers');
        $providers = $this->manager->getProviders();

        $table = new Table($output);
        $table->setHeaders(array('Alias', 'Class', 'Priority', 'Supported'))
            ->setStyle('borderless');

        foreach ($providers as $alias => $providerEntry) {
            /** @var $provider ProviderInterface */
            $provider = $providerEntry['provider'];
            $supported = $provider->isSupported() ? 'Yes' : 'No';
            $table->addRow(array($alias, get_class($provider), $providerEntry['priority'], $supported));
        }

        $table->render();
    }
44321
public function getProfile($name){
        if($this->loadProfiles != 'ALL' && !in_array($name, $this->loadProfiles)){
            $this->connection->select('id, name, join, error_redirect, error_forward');
            $this->connection->from($this->tableProfile);
            $this->connection->where('name = :name', array('name' => $name));
            $profile= $this->connection->get()->fetch(\PDO::FETCH_ASSOC);
            
            $this->connection->select('m.name');
            $this->connection->from($this->tableModulePermit . ' p');
            $this->connection->join($this->tableModule . ' m', 'p.moduleId = m.id');
            $this->connection->where('p.profileId = :id', array('id' => $profile['id']));
            $rta= $this->connection->get();
            $permitModules= array();
            while($module= $rta->fetch()){
                $permitModules[]= $module[0]; 
            }
            
            $this->connection->select('m.name');
            $this->connection->from($this->tableModuleDeny . ' p');
            $this->connection->join($this->tableModule . ' m', 'p.moduleId = m.id');
            $this->connection->where('p.profileId = :id', array('id' => $profile['id']));
            $rta= $this->connection->get();
            $denyModules= array();
            while($module= $rta->fetch()){
                $denyModules[]= $module[0]; 
            }
            
            $this->profiles[$name]= array('permit' => $permitModules, 'deny' => $denyModules, 'error-redirect' => $profile['error_redirect'], 'error-forward' => $profile['error_forward']);
            $this->loadProfiles[]= $name;
        }
        return $this->profiles[$name];
    }
328341
public function githubCreateRepo(InputInterface $input, OutputInterface $output)
    {
        $this->api->setCredentials($this->getCredentials($output));
        $name = $this->repoName($input);
        try {
            $this->api->createRepo($name,$this->repoDescription($input));
        } catch (ServerException $se) {
            //TODO
            $output->writeln('<error>Server exception thrown</error>');
            die();
        } catch (ClientException $ce) {
            $this->showError( $ce , $output );
        }
        $output->writeln('<info>Repository ' . $name . ' created</info>');
    }
1073195
private void onProfileUpdate(ProfileUpdateEvent event) {
        handler.post(() -> listener.onProfileUpdate(event));
        log("Event published " + event.toString());
    }
1236979
protected function unpublishElements(ReadSiteInterface $site, OutputInterface $output)
    {
        $elementPublisherManager = $this->getContainer()->get($this->getManagerName());

        $output->writeln("\n<info>Unpublishing ".$this->getElementType()."s for siteId " . $site->getSiteId() . "</info>");

        $unpublishResult = $elementPublisherManager->unpublishElements($site);

        if (AutoPublishManagerInterface::ERROR_NO_PUBLISHED_STATUS == $unpublishResult) {
            $output->writeln("<error>There is no published status defined.</error>");

        } elseif (AutoPublishManagerInterface::ERROR_NO_UNPUBLISHED_STATUS == $unpublishResult) {
            $output->writeln("<error>There is no status defined to unpublish ".$this->getElementType()."s.</error>");

        } elseif (is_array($unpublishResult)) {
            foreach ($unpublishResult as $element) {
                $output->writeln("<comment>-> " . $element['name'] . " (v" . $element['version'] . " " . $element['language'] . ") unpublished</comment>");
            }
        }
    }
387156
public function publishPages(OutputInterface $output)
    {
        /** @var \Networking\InitCmsBundle\Entity\PageManager $modelManager */
        $modelManager = $this->get('networking_init_cms.page_manager');
        $selectedModels = $modelManager->findAll();

        try {
            foreach ($selectedModels as $selectedModel) {
                /* @var \Networking\InitCmsBundle\Model\PageInterface $selectedModel */
                $selectedModel->setStatus(\Networking\InitCmsBundle\Model\PageInterface::STATUS_PUBLISHED);
                $modelManager->save($selectedModel);
                /** @var $pageHelper \Networking\InitCmsBundle\Helper\PageHelper */
                $pageHelper = $this->get('networking_init_cms.helper.page_helper');
                $pageHelper->makePageSnapshot($selectedModel);
            }

            return 0;
        } catch (\Exception $e) {
            $output->writeln($e->getMessage());

            return 1;
        }
    }