Ejemplo n.º 1
0
 public function handle(InputInterface $input, OutputInterface $output)
 {
     $registry = BaseOrm::getRegistry();
     $loader = new Loader();
     $issues = $loader->detectConflicts();
     if (!empty($issues)) {
         $message = 'The following migrations seem to indicate they are both the latest migration :' . PHP_EOL;
         $message .= ' %s ' . PHP_EOL;
         $output->writeln(sprintf($message, Tools::stringify($issues)));
         return;
     }
     if ($input->getOption('no-interaction')) {
         $asker = NonInteractiveAsker::createObject($input, $output);
     } else {
         $asker = InteractiveAsker::createObject($input, $output);
     }
     $autodetector = new AutoDetector($loader->getProjectState(), ProjectState::fromApps($registry), $asker);
     $changes = $autodetector->getChanges($loader->graph);
     if (empty($changes)) {
         $output->writeln('No changes were detected');
         return;
     }
     if ($input->getOption('dry-run')) {
         $output->writeln('<info>Migrations :</info>');
         /** @var $migration Migration */
         foreach ($changes as $migration) {
             $output->writeln('  -- ' . $migration->getName());
         }
         return;
     }
     $this->_writeMigrations($changes, $input, $output);
 }
Ejemplo n.º 2
0
 public static function prepareValue($value, $lookup)
 {
     if (in_array($lookup, ['contains', 'icontains'])) {
         $value = sprintf('%%%s%%', $value);
     } elseif (in_array($lookup, ['startswith', 'istartswith'])) {
         $value = sprintf('%s%%', $value);
     } elseif (in_array($lookup, ['endswith', 'iendswith'])) {
         $value = sprintf('%%%s', $value);
     } elseif ($lookup === 'in' && is_array($value)) {
         var_dump(Tools::stringify($value));
         $value = sprintf('%s', implode(',', $value));
     }
     return $value;
 }
Ejemplo n.º 3
0
 public static function validateLookup($lookup)
 {
     if (!empty($lookup) && !array_key_exists($lookup, self::$lookuOptions)) {
         throw new LookupError(sprintf('`%1$s` is not a valid lookup parameter the options are %2$s', $lookup, Tools::stringify(self::$lookuOptions)));
     }
 }
Ejemplo n.º 4
0
 /**
  * Converts migration object into a string and adds it to the migration file temple, ready to be written on disk.
  *
  * @return string
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 public function getContent()
 {
     $imports = [];
     $stringedOperations = [];
     foreach ($this->migration->getOperations() as $op) {
         list($opString, $importString) = FormatFileContent::formatObject($op);
         array_push($stringedOperations, $opString);
         $imports = array_merge($imports, $importString);
     }
     $imports = array_unique($imports);
     $importPaths = '';
     foreach ($imports as $import) {
         $import = sprintf('use %s;', $import);
         $importPaths .= $import . PHP_EOL;
     }
     $opContent = '[' . PHP_EOL;
     foreach ($stringedOperations as $op) {
         $opContent .= sprintf("\t\t\t%s," . PHP_EOL, $op);
     }
     $opContent .= "\t\t]";
     $dependencies = $this->migration->getDependency();
     $indent = count($dependencies) <= 1 ? false : 3;
     return sprintf($this->getFileTemplate(), $importPaths, $this->migration->getName(), Tools::stringify($dependencies, $indent), $opContent);
 }