Generate the base security yaml file to be used by the client

@param  InputInterface  $input  The input interface
@param  OutputInterface $output The output interface
331840
protected function execute(InputInterface $input, OutputInterface $output) {
        //Start by getting the security service reference
        $security = $this->getContainer()->get('mesd.jasper.report.security');

        //Process the input options
        $roles  = $input->getOption('roles')  ?: $security->getDefaultRoles();
        $backup = $input->getOption('backup') ? true : false;
        $path   = $input->getOption('path')   ?: $security->getSecurityFile();
        $depth  = intval($input->getOption('depth'))  ?: -1;

        //Init the security service (normally done automatically via the setRole and canView)
        $security->init();

        //Backup the existing file if the backup flag is set and the existing file exists
        if ($backup && $security->isLoadedFromFile()) {
            //change the existing path to add that it is a backup
            $currentPath = explode('/', $security->getSecurityFile());
            $currentPath[count($currentPath) - 1] = '~' . $currentPath[count($currentPath) - 1];
            $security->saveSecurityConfiguration(implode('/', $currentPath), true);
        }

        //Turn off security for the client for the time being
        $this->getContainer()->get('mesd.jasper.report.client')->setUseSecurity(false);

        //Convert the file structure to an array with the roles set
        $this->setResource($security, $security->getDefaultFolder(), $roles, $depth);

        //Save the security configuration
        $security->saveSecurityConfiguration($path, true);
    }
739175
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->validateCommand($input);

        $output->writeln('> Loading configuration file');
        $config = $input->getOption('config');
        $files = (new ConfigResolver())->getFileList($config);
        $output->writeLn('- Found '.count($files).' files');

        $preloader = (new Factory())->create($this->getOptions($input));

        $outputFile = $input->getOption('output');
        $handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types'));

        $output->writeln('> Compiling classes');

        $count = 0;
        $countSkipped = 0;
        $comments = !$input->getOption('strip_comments');

        foreach ($files as $file) {
            $count++;

            try {
                $code = $preloader->getCode($file, $comments);
                $output->writeln('- Writing '.$file);
                fwrite($handle, $code."\n");
            } catch (VisitorExceptionInterface $e) {
                $countSkipped++;
                $output->writeln('- Skipping '.$file);
            }
        }

        fclose($handle);

        $output->writeln("> Compiled loader written to $outputFile");
        $output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')');
        $output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb');
    }
10924
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        $config = $this->config;
        $tempDir = $config->get('dotfiles.temp_dir');

        $output->writeln('Start checking new version');
        $url = static::BASE_URL.'/dotfiles.phar.json';
        $versionFile = $tempDir.'/update/dotfiles.phar.json';
        Toolkit::ensureFileDir($versionFile);
        $downloader = $this->downloader;
        $downloader->run($url, $versionFile);
        $contents = file_get_contents($versionFile);
        if ('' === trim($contents)) {
            throw new InstallFailedException('Can not parse dotfiles.phar.json file');
        }
        $json = json_decode($contents, true);

        $this->versionFile = $versionFile;
        $this->version = $json['version'];
        $this->branchAlias = $json['branch'];
        $this->date = $json['date'];

        if (Application::VERSION !== $this->version) {
            $output->writeln("Begin update into <comment>{$this->version}</comment>");
            $this->doUpdate($output);
            $this->getApplication()->get('clear-cache')->run($input, $output);
        } else {
            $output->writeln('You already have latest <comment>dotfiles</comment> version');
        }
    }
156923
protected function init(InputInterface $input, OutputInterface $output)
    {
    	$this->input = $input;
    	$this->output = $output;

    	$this->bbapp = $this->getContainer()->get('bbapp');
    	$this->entyMgr = $this->bbapp->getEntityManager();

    	return $this;
    }
391615
protected function execute(InputInterface $input, OutputInterface $output)
    {

        $output->writeln('
                                       __                              _      __  
          _________  ____  _________  / /__     ____ ___  ____ _____ _(_)____/ /__
         / ___/ __ \/ __ \/ ___/ __ \/ / _ \   / __ `__ \/ __ `/ __ `/ / ___/ //_/
        / /__/ /_/ / / / (__  ) /_/ / /  __/  / / / / / / /_/ / /_/ / / /__/ ,<   
        \___/\____/_/ /_/____/\____/_/\___/  /_/ /_/ /_/\__,_/\__, /_/\___/_/|_|  
                                                             /____/               
        ');


        $helper = $this->getHelper('question');

        if (file_exists($this->filename)) {
            $output->writeln('Reading existing alias file');
            $fileContents = file_get_contents($this->filename);
            $contents = Yaml\Yaml::parse($fileContents);
        } else {
            $output->writeln('Before we start, i need to create some files');

            mkdir(PATH_site.'../configs/', 0755, true);
            mkdir(PATH_site.'../configs/console/', 0755, true);
            touch($this->filename);
        }



        $question = new ChoiceQuestion(
            'Would you like to add a new alias?',
            array('yes', 'no', 'help'),
            '1'
        );
        $question->setMultiselect(false);

        $aliasCreation = $helper->ask($input, $output, $question);

        if($aliasCreation == 'yes'){

            $result = $this->createAlias($input,$output);

            $first_key = key($result);

            $contents[$first_key] = $result[$first_key];

            $yaml = Yaml\Yaml::dump($contents);
            file_put_contents($this->filename, $yaml);



        }else if($aliasCreation == 'help') {

            $output->writeln('You have just selected: ' . $aliasCreation);

        }else {
            return 0;
        }

        return 0;

    }
325035
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getConsoleHelper($input, $output);
        
        $output->writeln([]);
        
        $message = sprintf('Set configuration filepath relative current work directory "<comment>%s</comment>"', $this->currentWorkDirectory);
        
        $configuration = $helper->askQuestion($message, 'config.yml');
        $configuration = "{$this->currentWorkDirectory}/$configuration";

        $configurationFile = new \SplFileInfo($configuration);
        
        if ($configurationFile->getExtension() === 'php') {
            $this->configuration = new Configuration(include_once $configurationFile->getRealPath());
        } else {
            $this->configuration = Configuration::createFromFile($configurationFile->getRealPath());
        }
    }
87012
protected function loadConfig(InputInterface $input, OutputInterface $output)
    {
        $configFilePath = $this->locateConfigFile($input);
        $output->writeln('<info>using config file</info> .' . str_replace(getcwd(), '', realpath($configFilePath)));

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

        // If no parser is specified try to determine the correct one from the file extension.  Defaults to YAML
        if ($parser === null) {
            $extension = pathinfo($configFilePath, PATHINFO_EXTENSION);

            switch (strtolower($extension)) {
                case 'json':
                    $parser = 'json';
                    break;
                case 'php':
                    $parser = 'php';
                    break;
                case 'yml':
                default:
                    $parser = 'yaml';
            }
        }

        switch (strtolower($parser)) {
            case 'json':
                $config = Config::fromJson($configFilePath);
                break;
            case 'php':
                $config = Config::fromPhp($configFilePath);
                break;
            case 'yaml':
                $config = Config::fromYaml($configFilePath);
                break;
            default:
                throw new \InvalidArgumentException(sprintf('\'%s\' is not a valid parser.', $parser));
        }

        $output->writeln('<info>using config parser</info> ' . $parser);

        $this->setConfig($config);
    }
935911
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $uuids = array();

        $count = filter_var(
            $input->getOption('count'),
            FILTER_VALIDATE_INT,
            array(
                'default' => 1,
                'min_range' => 1,
            )
        );

        for ($i = 0; $i < $count; $i++) {
            $uuids[] = $this->createUuid(
                $input->getArgument('version'),
                $input->getArgument('namespace'),
                $input->getArgument('name')
            );
        }

        foreach ($uuids as $uuid) {
            $output->writeln((string) $uuid);
        }
    }
833285
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->setIo($input, $output);

        $outputFile = $input->getOption('generate');

        $output->writeln("<info>Generating your {$outputFile}...</info>");
        $output->writeln("<comment>{$this->banner}\n</comment>");

        $generated['source'] = $this->setupSources();
        $generated['build'] = $this->setupBuild();
        $generated['deploy'] = $this->setupDeploy();
        $generated['gulp'] = $this->setupGulp();
        $generated['serve'] = $this->setupServe($generated);

        $yaml = $this->createYaml($generated);

        if ($input->getOption('dry-run')) {

            $output->writeln("\n<info>Ready to write config file</info>");
            $output->writeln($yaml);

            if ( ! $this->confirm("Write the above configuration to <path>{$outputFile}</path>?")) {
                return $output->writeln('<error>Aborted!</error>');
            }
        }

        if ( ! $this->files->put($outputFile, $yaml)) {
            return $output->writeln('<error>Failed to save config file.</error>');
        }

        $output->writeln("<info>Success! <path>{$outputFile}</path> written.</info>");

        if ( ! empty($generated['source']['git.url'])) {
            $output->writeln("Try a <comment>steak pull</comment> next to fetch your sources...");
        } else {
            $output->writeln("Try <comment>steak serve</comment> to start building your site...");
        }
    }
460715
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $inputFile = $input->getArgument('input-file');
        $exampleFile = $input->getArgument('example-file');
        $number = $input->getOption('number');

        $parserGenerator = new ParserGenerator(new PegFile());

        $parser = $parserGenerator->createParser($inputFile);
        $contents = file_get_contents($exampleFile);
        $start = microtime(true);
        $memoryUsage = $memoryBase = memory_get_usage();

        for ($i = 0; $i < $number; $i++) {
            $parser->parse($contents);

            if ($i === 0) {
                $memoryUsage = memory_get_usage() - $memoryBase;
            }
        }

        $memory = $this->humanReadable($memoryUsage);
        $time = microtime(true) - $start;
        $ms = round($time * 1000);
        $avg = round($time * 1000 / $number);
        $rps = round($number / $time);

        $output->writeln("Memory usage: {$memory}");
        $output->writeln("Number of runs: {$number}");
        $output->writeln("Total time: {$ms}ms");
        $output->writeln("Average time: {$avg}ms");
        $output->writeln("Runs per second: {$rps}");
    }
1368034
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (! $this->vagrantfileExists()) {
            $this->createVagrantfile();
        }

        if (! $input->getOption('no-aliases') && ! $this->aliasesFileExists()) {
            $this->createAliasesFile();
        }

        if (! $input->getOption('no-after') && ! $this->afterShellScriptExists()) {
            $this->createAfterShellScript();
        }

        $format = $input->getOption('json') ? 'json' : 'yaml';

        if (! $this->settingsFileExists($format)) {
            $this->createSettingsFile($format, [
                'name' => $input->getOption('name'),
                'hostname' => $input->getOption('hostname'),
                'ip' => $input->getOption('ip'),
            ]);
        }

        if ($input->getOption('example') && ! $this->exampleSettingsExists($format)) {
            $this->createExampleSettingsFile($format);
        }

        $this->checkForDuplicateConfigs($output);

        $output->writeln('Homestead Installed!');
    }
619570
protected function initializeLicenser(InputInterface $input, OutputInterface $output)
    {
        $license = $input->getArgument('license');

        try {
            $licenseHeader = $this->licenseHeaderFactory->createFromLicenseName(
                $license,
                ['owners' => $input->getOption('owners')]
            );
        } catch (\InvalidArgumentException $e) {
            $licenseHeader = file_get_contents($license);
        }

        $this->licenser->setLicenseHeader($licenseHeader);
        $this->licenser->setOutputStream($output);
    }
6138
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);

        $session = $this->mustBeModelManagerSession($this->getSession());

        $this->updateOutput(
            $output,
            (new StructureGenerator(
                $session,
                $this->schema,
                $this->relation,
                $this->getPathFile($input->getArgument('config-name'), $this->relation, null, 'AutoStructure', $input->getOption('psr4')),
                $this->getNamespace($input->getArgument('config-name'), 'AutoStructure')
            ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
        );

        $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, 'Model', '', $input->getOption('psr4'));
        if (!file_exists($pathFile) || $input->getOption('force')) {
            $this->updateOutput(
                $output,
                (new ModelGenerator(
                    $session,
                    $this->schema,
                    $this->relation,
                    $pathFile,
                    $this->getNamespace($input->getArgument('config-name'))
                ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
            );
        } elseif ($output->isVerbose()) {
            $this->writelnSkipFile($output, $pathFile, 'model');
        }

        $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, '', '', $input->getOption('psr4'));
        if (!file_exists($pathFile) || $input->getOption('force')) {
            $this->updateOutput(
                $output,
                (new EntityGenerator(
                    $session,
                    $this->schema,
                    $this->relation,
                    $pathFile,
                    $this->getNamespace($input->getArgument('config-name')),
                    $this->flexible_container
                ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions())))
            );
        } elseif ($output->isVerbose()) {
            $this->writelnSkipFile($output, $pathFile, 'entity');
        }
    }
185178
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $targetArg = rtrim($input->getArgument('target'), '/');

        if (!is_dir($targetArg)) {
            throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
        }

        $wantedVersion = $input->getOption('zeroclipboard-version');

        try {
            $versionConstraint = Constraint::parse($wantedVersion);
        } catch (UnexpectedValueException $e) {
            $output->writeln(
                '<error>Error:</error> <info>' .
                $wantedVersion . '</info> is not a valid version constraint.'
            );
            return;
        }

        $minimalConstraint =
            new SimpleConstraint(
                new Operator('>='),
                Version::parse($this->minimalSupportedVersion)
            );

        if(!$minimalConstraint->matches($versionConstraint)) {
            $output->writeln(
                '<error>Error:</error> <info>' .
                $wantedVersion . '</info> is not supported. Minimal version is: ' .
                $this->minimalSupportedVersion
            );
            return;
        }

        $curl = new Curl();
        $curl->get(
            'https://api.github.com' .
            '/repos/zeroclipboard/zeroclipboard/tags?per_page=100'
        );

        $versionToInstall = null;
        $versionToInstallObj = new Version(1, 0, 6);

        foreach(json_decode($curl->response) as $release) {
            try {
                $tag = Version::parse($release->name);
                if ($tag->getStability()->isStable()) {
                    $constraint = new SimpleConstraint(new Operator('='), $tag);
                    if ($constraint->isSubsetOf($versionConstraint)) {
                        if ($tag->compare($versionToInstallObj) > 0) {
                            $versionToInstall = $release->name;
                            $versionToInstallObj = $tag;
                        }
                    } else {
                    }
                }
            } catch(\Exception $e) {

            }
        }

        if(!$versionToInstall) {
            $output->writeln(
                '<error>Error:</error> <info>' .
                $wantedVersion . '</info> is greator than the last release. '
            );
            return;
        }

        /** @var Filesystem $filesystem */
        $filesystem = $this->getContainer()->get('filesystem');

        // Create the bundles directory otherwise symlink will fail.
        $bundlesDir = $targetArg . '/bundles/';
        $filesystem->mkdir($bundlesDir, 0777);

        $output->writeln(
            'Installing ZeroClipboard assets.'
        );

        $targetDir  = $bundlesDir . 'zeroclipboard-assets';

        $namespaceParts = explode('\\', __NAMESPACE__);
        array_pop($namespaceParts);

        $output->writeln(
            sprintf(
                'Installing assets for <comment>%s</comment> into <comment>%s</comment>',
                implode('\\', $namespaceParts),
                $targetDir
            )
        );

        $filesystem->remove($targetDir);

        $filesystem->mkdir($targetDir, 0777);

        $filesystem->mkdir($targetDir . '/tmp');

        $zip = file_get_contents(
            'https://github.com/zeroclipboard/zeroclipboard/archive/' . $versionToInstall . '.zip'
        );

        file_put_contents($targetDir . '/tmp/zeroclipboard.zip', $zip);

        $zip = new \ZipArchive;

        if ($zip->open($targetDir . '/tmp/zeroclipboard.zip') === TRUE) {
            $zip->extractTo($targetDir . '/tmp');
            $zip->close();

            if(file_exists($targetDir . '/tmp/zeroclipboard-' . $versionToInstall . '/dist')) {
                $filesystem->mirror(
                    $targetDir . '/tmp/zeroclipboard-' . $versionToInstall . '/dist',
                    $targetDir
                );
            } else {
                $versionToInstall = $versionToInstallObj->getMajor() .'.' .
                    $versionToInstallObj->getMinor() .'.' .
                    $versionToInstallObj->getRevision();
                if(file_exists($targetDir . '/tmp/zeroclipboard-' . $versionToInstall . '/dist')) {
                    $filesystem->mirror(
                        $targetDir . '/tmp/zeroclipboard-' . $versionToInstall . '/dist',
                        $targetDir
                    );
                } else {
                    foreach( array(
                                 'ZeroClipboard.js',
                                 'ZeroClipboard.min.js',
                                 'ZeroClipboard.min.map',
                                 'ZeroClipboard.Core.js',
                                 'ZeroClipboard.Core.min.js',
                                 'ZeroClipboard.Core.min.map',
                                 'ZeroClipboard.swf',
                             ) as $file) {
                        if(
                        file_exists(
                            $targetDir .
                            '/tmp/zeroclipboard-' .
                            $versionToInstall .
                            '/' . $file)) {
                            $filesystem->copy(
                                $targetDir . '/tmp/zeroclipboard-' . $versionToInstall . '/' . $file,
                                $targetDir . '/' . $file
                            );
                        }
                    }
                }
            }
            $filesystem->remove($targetDir . '/tmp');
        } else {
            throw new FileException('File Error');
        }
    }
323992
protected function execute(InputInterface $input, OutputInterface $output)
	{
		$this->setupEnvironment('site', $input, $output);

		$version = new \JVersion;

		if ($input->getOption('short'))
		{
			$result = $version->getShortVersion();
		}
		elseif ($input->getOption('release'))
		{
			$result = $version->RELEASE;
		}
		else
		{
			$result = $version->getLongVersion();
		}
		$output->writeln($result);
	}
1157482
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Start generating...');
        $generated = $this->getFacade()->generateDataProvider();

        if ($output->isVerbose()) {
            foreach ($generated as $provider) {
                $output->writeln($provider . ' generated');
            }
        }
    }
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);
            }
        );
    }