本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface::isInteractive方法的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface::isInteractive方法的具体用法?PHP InputInterface::isInteractive怎么用?PHP InputInterface::isInteractive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Input\InputInterface
的用法示例。
在下文中一共展示了InputInterface::isInteractive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getHelperSet()->get('dialog');
$whitelist = array('name', 'description', 'author', 'require');
$options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
if (isset($options['author'])) {
$options['authors'] = $this->formatAuthors($options['author']);
unset($options['author']);
}
$options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass();
$file = new JsonFile('composer.json');
$json = $file->encode($options);
if ($input->isInteractive()) {
$output->writeln(array('', $json, ''));
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$file->write($options);
if ($input->isInteractive()) {
$ignoreFile = realpath('.gitignore');
if (false === $ignoreFile) {
$ignoreFile = realpath('.') . '/.gitignore';
}
if (!$this->hasVendorIgnore($ignoreFile)) {
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]?';
if ($dialog->askConfirmation($output, $question, true)) {
$this->addVendorIgnore($ignoreFile);
}
}
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->isEnabled()) {
$bundleName = $input->getArgument("bundle");
$bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
/* @var $bundle BundleInterface */
$entities = array();
foreach ($this->getBundleMetadata($bundle) as $m) {
/* @var $m ClassMetadata */
$_tmp = explode('\\', $m->getName());
$entityName = array_pop($_tmp);
$entities[$bundleName . ':' . $entityName] = $entityName;
}
$command = $this->getApplication()->find('itscaro:generate:crud');
foreach ($entities as $entityShortcut => $entityName) {
try {
$_input = new ArrayInput(['command' => 'itscaro:generate:crud', '--entity' => $entityShortcut, '--route-prefix' => $input->getOption('route-prefix') . strtolower($entityName), '--with-write' => $input->getOption('with-write'), '--format' => $input->getOption('format'), '--overwrite' => $input->getOption('overwrite')]);
$_input->setInteractive($input->isInteractive());
$output->writeln("<info>Executing:</info> {$_input}");
$returnCode = $command->run($_input, $output);
$output->writeln("\t<info>Done</info>");
} catch (\Exception $e) {
$output->writeln("\t<error>Error:</error> " . $e->getMessage());
}
}
} else {
$output->writeln('<error>Cannot find DoctrineBundle</error>');
}
}
示例3: execute
/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getQuestionHelper();
if ($input->isInteractive()) {
$question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
if (!$questionHelper->ask($input, $output, $question)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$entity = Validators::validateEntityName($input->getOption('entity'));
list($bundle, $entity) = $this->parseShortcutNotation($entity);
$prefix = $this->getRoutePrefix($input, $entity);
$forceOverwrite = $input->getOption('overwrite');
$questionHelper->writeSection($output, 'REST api generation');
$entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
$metadata = $this->getEntityMetadata($entityClass);
$bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
$resource = $input->getOption('resource');
$document = $input->getOption('document');
$generator = $this->getGenerator($bundle);
$generator->generate($bundle, $entity, $metadata[0], $prefix, $forceOverwrite, $resource, $document);
$output->writeln('Generating the REST api code: <info>OK</info>');
$errors = array();
// form
$this->generateForm($bundle, $entity, $metadata);
$output->writeln('Generating the Form code: <info>OK</info>');
$questionHelper->writeGeneratorSummary($output, $errors);
}
示例4: execute
/**
* @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getQuestionHelper();
if ($input->isInteractive()) {
$question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
if (!$questionHelper->ask($input, $output, $question)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$entity = Validators::validateEntityName($input->getOption('entity'));
$fields = $this->parseFields($input->getOption('fields'));
if (!$input->getOption('no-summary')) {
$questionHelper->writeSection($output, 'Entity generation');
}
/** @var TemplateInterface $generator */
$generator = $this->getGenerator();
$generator->setConfiguration('fields', $fields);
if ($input->getOption('no-interface')) {
$generator->setConfiguration('with_interface', false);
}
$errors = array();
$runner = $questionHelper->getRunner($output, $errors);
$runner($generator->generate($entity));
if (!$input->getOption('no-summary')) {
$questionHelper->writeGeneratorSummary($output, $generator->getErrors());
}
}
示例5: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getQuestionHelper();
if ($input->isInteractive()) {
$question = new Question($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
if (!$questionHelper->ask($input, $output, $question)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
if (null === $input->getOption('controller')) {
throw new \RuntimeException('The controller option must be provided.');
}
list($bundle, $controller) = $this->parseShortcutNotation($input->getOption('controller'));
if (is_string($bundle)) {
$bundle = Validators::validateBundleName($bundle);
try {
$bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
} catch (\Exception $e) {
$output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
}
}
$questionHelper->writeSection($output, 'Controller generation');
$generator = $this->getGenerator($bundle);
$generator->generate($bundle, $controller, $input->getOption('route-format'), $input->getOption('template-format'), $this->parseActions($input->getOption('actions')));
$output->writeln('Generating the bundle code: <info>OK</info>');
$questionHelper->writeGeneratorSummary($output, array());
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getEntityManager();
if ($input->isInteractive() && !$input->getOption('append')) {
if (!$this->askConfirmation($input, $output, '<question>Careful, database will be purged. Do you want to continue y/N ?</question>', false)) {
return;
}
}
$app = $this->getApp();
$path = $app->getApplicationBase($app->getAppNamespace()) . '/DataFixture';
$loader = new DataFixturesLoader();
$loader->loadFromDirectory($path);
$fixtures = $loader->getFixtures();
if (!$fixtures) {
throw new InvalidArgumentException(sprintf('Could not find any fixtures to load in: %s', "\n\n- {$path}"));
}
foreach ($fixtures as $fixture) {
if ($fixture instanceof ContainerAwareInterface) {
$fixture->setContainer($this->getContainer());
}
}
$purger = new ORMPurger($em);
if ($input->getOption('truncate-only')) {
$purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
$purger->purge();
exit(0);
}
$purger->setPurgeMode($input->getOption('truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
$executor = new ORMExecutor($em, $purger);
$executor->setLogger(function ($message) use($output) {
$output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message));
});
$executor->execute($fixtures, $input->getOption('append'));
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getQuestionHelper();
if ($input->isInteractive()) {
$confirmationQuestion = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
if (!$questionHelper->ask($input, $output, $confirmationQuestion)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
GeneratorUtils::ensureOptionsProvided($input, array('entity', 'fields', 'prefix'));
$entityInput = Validators::validateEntityName($input->getOption('entity'));
list($bundleName, $entity) = $this->parseShortcutNotation($entityInput);
$format = 'annotation';
$fields = $this->parseFields($input->getOption('fields'));
$prefix = $input->getOption('prefix');
$questionHelper->writeSection($output, 'Entity generation');
$bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
$generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle("KunstmaanGeneratorBundle"));
$generator->generate($bundle, $entity, $format, array_values($fields), $input->getOption('with-repository'), $prefix);
$output->writeln('Generating the entity code: <info>OK</info>');
$withAdminlist = $input->getOption('with-adminlist');
if ($withAdminlist) {
$command = $this->getApplication()->find('kuma:generate:adminlist');
$arguments = array('command' => 'doctrine:fixtures:load', '--entity' => $entityInput);
$input = new ArrayInput($arguments);
$command->run($input, $output);
}
$questionHelper->writeGeneratorSummary($output, array());
$output->writeln(array('Make sure you update your database first before you test the entity/adminlist:', ' Directly update your database: <comment>app/console doctrine:schema:update --force</comment>', ' Create a Doctrine migration and run it: <comment>app/console doctrine:migrations:diff && app/console doctrine:migrations:migrate</comment>', ''));
}
示例8: loopBundle
private function loopBundle(QuestionHelper $questionHelper, InputInterface $input, OutputInterface $output)
{
$bundles = ['admin' => ['kernel' => [['bundle' => 'SKCMSAdminBundle', 'namespace' => 'SKCMS\\AdminBundle'], ['bundle' => 'IvoryCKEditorBundle', 'namespace' => 'Ivory\\CKEditorBundle'], ['bundle' => 'FMElfinderBundle', 'namespace' => 'FM\\ElfinderBundle'], ['bundle' => 'StofDoctrineExtensionsBundle', 'namespace' => 'Stof\\DoctrineExtensionsBundle']], 'config' => ['loadSkCMSAdmin', 'loadCKEditor', 'loadDoctrineFunctions'], 'route' => ['routeAdmin']], 'user' => ['kernel' => [['bundle' => 'SKCMSUserBundle', 'namespace' => 'SKCMS\\UserBundle'], ['bundle' => 'FOSUserBundle', 'namespace' => 'FOS\\UserBundle']], 'config' => ['loadFosUser', 'setSecurity'], 'route' => ['routeUser']], 'contact' => ['kernel' => [['bundle' => 'SKCMSContactBundle', 'namespace' => 'SKCMS\\ContactBundle']], 'config' => ['loadSKContact'], 'route' => ['routeContact']], 'tracking' => ['kernel' => [['bundle' => 'SKCMSTrackingBundle', 'namespace' => 'SKCMS\\TrackingBundle']], 'route' => ['routeTracking']], 'shop' => ['kernel' => [['bundle' => 'SKCMSShopBundle', 'namespace' => 'SKCMS\\ShopBundle']], 'route' => ['routeShop']], 'front' => ['kernel' => [['bundle' => 'SKCMSFrontBundle', 'namespace' => 'SKCMS\\FrontBundle']], 'route' => ['routeFront']]];
foreach ($bundles as $bundleName => $bundle) {
if ($input->isInteractive()) {
$question = new ConfirmationQuestion($questionHelper->getQuestion('Install ' . $bundleName . ' (kernel + config)', 'yes', '?'), true);
$auto = $questionHelper->ask($input, $output, $question);
$this->module_installed = $auto;
}
if ($auto) {
foreach ($bundle['kernel'] as $bundleKernel) {
$kernelUpdate = $this->updateKernel($this->getContainer()->get('kernel'), $bundleKernel['namespace'], $bundleKernel['bundle']);
}
if (array_key_exists('config', $bundle) && is_array($bundle['config'])) {
foreach ($bundle['config'] as $configMethod) {
call_user_func([$this, $configMethod]);
}
}
if (array_key_exists('route', $bundle) && is_array($bundle['route'])) {
foreach ($bundle['route'] as $routeMethod) {
call_user_func([$this, $routeMethod]);
}
}
}
}
}
示例9: interactWith
public function interactWith(FormInterface $form, HelperSet $helperSet, InputInterface $input, OutputInterface $output)
{
if (!$form->isRoot()) {
throw new CanNotInteractWithForm('This interactor only works with root forms');
}
if ($input->isInteractive()) {
throw new CanNotInteractWithForm('This interactor only works with non-interactive input');
}
/*
* We need to adjust the input values for repeated types by copying the provided value to both of the repeated
* fields. We only loop through the top-level fields, since there are no command options for deeper lying fields
* anyway.
*
* The fix was provided by @craigh
*
* P.S. If we need to add another fix like this, we should move this out to dedicated "input fixer" classes.
*/
foreach ($form->all() as $child) {
$config = $child->getConfig();
$name = $child->getName();
if ($config->getType()->getInnerType() instanceof RepeatedType && $input->hasOption($name)) {
$input->setOption($name, [$config->getOption('first_name') => $input->getOption($name), $config->getOption('second_name') => $input->getOption($name)]);
}
}
// use the original input as the submitted data
return $input;
}
示例10: execute
/**
* @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
if ($input->isInteractive()) {
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$entity = Validators::validateEntityName($input->getOption('entity'));
$translationEntity = Validators::validateEntityName(sprintf('%sTranslation', $input->getOption('entity')));
list($bundle, $entity) = $this->parseShortcutNotation($entity);
list($translationBundle, $translationEntity) = $this->parseShortcutNotation($translationEntity);
$format = Validators::validateFormat($input->getOption('format'));
$fields = $this->parseFields($input->getOption('fields'));
$translatableFields = $this->parseFields($input->getOption('translatable-fields'));
$dialog->writeSection($output, 'Entities generation');
$kernel = $this->getContainer()->get('kernel');
$bundle = $kernel->getBundle($bundle);
$translationBundle = $kernel->getBundle($translationBundle);
/** @var OrkestroEntityGenerator $generator */
$generator = $this->getGenerator();
$generator->generateTranslatable($bundle, $entity, $translationEntity, $format, array_values($fields), array_values($translatableFields), $input->getOption('with-repository'));
$output->writeln('Generating the entities code: <info>OK</info>');
$dialog->writeGeneratorSummary($output, array());
}
示例11: initialize
/**
* @inheritdoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->stdOut = $output;
$this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$this->stdIn = $input;
self::$interactive = $input->isInteractive();
}
示例12: getBootstrapPathsFromUser
protected function getBootstrapPathsFromUser()
{
$symlinkTarget = $this->input->getArgument('pathTo' . static::$pathName);
$symlinkName = $this->input->getArgument('pathToMopaBootstrapBundle');
if (empty($symlinkName)) {
throw new \Exception("pathToMopaBootstrapBundle not specified");
}
if (!is_dir(dirname($symlinkName))) {
throw new \Exception("pathToMopaBootstrapBundle: " . dirname($symlinkName) . " does not exist");
}
if (empty($symlinkTarget)) {
throw new \Exception(static::$pathName . " not specified");
}
if (substr($symlinkTarget, 0, 1) == "/") {
$this->output->writeln("<comment>Try avoiding absolute paths, for portability!</comment>");
if (!is_dir($symlinkTarget)) {
throw new \Exception("Target path " . $symlinkTarget . "is not a directory!");
}
} else {
$symlinkTarget = $symlinkName . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . $symlinkTarget;
}
if (!is_dir($symlinkTarget)) {
throw new \Exception(static::$pathName . " would resolve to: " . $symlinkTarget . "\n and this is not reachable from \npathToMopaBootstrapBundle: " . dirname($symlinkName));
}
$dialog = $this->getHelperSet()->get('dialog');
$text = <<<EOF
Creating the symlink: {$symlinkName}
Pointing to: {$symlinkTarget}
EOF;
$this->output->writeln(array('', $this->getHelperSet()->get('formatter')->formatBlock($text, 'bg=blue;fg=white', true), ''));
if ($this->input->isInteractive() && !$dialog->askConfirmation($this->output, '<question>Should this link be created? (y/n)</question>', false)) {
throw new \Exception("Aborting due to User not cofirming!");
}
return array($symlinkTarget, $symlinkName);
}
示例13: execute
/**
* @inheritdoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$origin = $input->getOption('origin');
$force = $input->getOption('force');
$interactive = $input->isInteractive();
$this->logger->pushHandler(new ConsoleHandler($output));
$dispatcher = $this->sourceCleaner->getEventDispatcher();
// listen to clean event
$dispatcher->addListener(IoEvents::PRE_CLEAN_SOURCE, function (SourceEvent $event) use($output) {
$source = $event->getSource();
$output->writeln(sprintf('<fg=red>- %s:%s</>', $source->getOrigin()->getName(), $source->getOriginalId()));
});
if ($force) {
$voter = new ThresholdVoter(function () {
return true;
}, $dispatcher);
} else {
$voter = new ThresholdVoter(function ($count, $total, $max, $message) use($output, $interactive) {
$output->writeln($message);
// see if we can ask the user to confirm cleanup
$question = '<question>> Clean these sources anyway? [y]</question> ';
return $interactive && $this->getDialogHelper()->askConfirmation($output, $question);
}, $dispatcher);
}
$numCleaned = $this->clean($voter, $origin);
$output->writeln(sprintf('<info>%s</info> sources cleaned', $numCleaned));
return 0;
}
示例14: execute
/**
* @see Command
*
* @throws \InvalidArgumentException When namespace doesn't end with Bundle
* @throws \RuntimeException When bundle can't be executed
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$questionHelper = $this->getQuestionHelper();
if ($input->isInteractive()) {
if (!$questionHelper->ask($input, $output, new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true))) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
foreach (array('target-bundle', 'fieldtype-name') as $option) {
if (null === $input->getOption($option)) {
throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
}
}
$generator = $this->getGenerator();
$generator->generate($input->getOption('target-bundle'), $input->getOption('target-bundle-dir'), $input->getOption('fieldtype-name'), $input->getOption('fieldtype-name'));
$output->writeln('Generating the FieldType code: <info>OK</info>');
// $errors = array();
// $runner = $questionHelper->getRunner($output, $errors);
//
// // check that the namespace is already autoloaded
// $runner($this->checkAutoloader($output, $namespace, $bundle, $dir));
//
// // register the bundle in the Kernel class
// $runner($this->updateKernel($questionHelper, $input, $output, $this->getContainer()->get('kernel'), $namespace, $bundle));
//
// // routing
// $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format));
//
// $questionHelper->writeGeneratorSummary($output, $errors);
}
示例15: execute
/**
* {@inheritDoc}
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var DialogHelper $dialog */
$dialog = $this->getHelperSet()->get('dialog');
$wsdl = Validators::validateWsdl($input->getOption('wsdl'));
$dir = Validators::validateTargetDir($input->getOption('dir'));
$namespace = Validators::validateNamespace($input->getOption('namespace'));
$licensePath = Validators::validateLicensePath($input->getOption('license-path'));
if ($input->isInteractive()) {
$this->writeSection($output, array(sprintf('Path to the wsdl file: "%s"', $wsdl), sprintf('The directory where to create proxy classes: "%s"', $dir), sprintf('The namespace of proxy classes to create: "%s"', $namespace)));
if (!$dialog->askConfirmation($output, $this->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$generator = new SimpleTypeAbstractGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath);
$generator->execute();
$generator = new ComplexTypeAbstractGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath);
$generator->execute();
$generator = new SimpleTypeGenerator($wsdl, $dir . 'SimpleType', $namespace . '\\SimpleType', array(), $licensePath);
$generator->execute();
$generator = new ComplexTypeGenerator($wsdl, $dir . 'ComplexType', $namespace . '\\ComplexType', array($namespace . '\\SimpleType'), $licensePath);
$generator->execute();
$generator = new SoapClientGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient'), $licensePath);
$generator->execute();
$generator = new SoapServiceGenerator($wsdl, $dir, $namespace, array('RuntimeException', 'SoapFault', 'SoapClient as BaseSoapClient', 'InvalidArgumentException'), $licensePath);
$generator->execute();
unset($generator);
}