Beispiel #1
0
 public function onGetClassFixClass(GetClassEvent $event)
 {
     $fileLocation = $event->getFileLocation();
     $command = new FixCommand();
     $arguments = ['path' => $fileLocation];
     $arguments = array_merge($arguments, $this->arguments);
     $output = isset($this->output) ? $this->output : new BufferedOutput();
     $output->writeln(sprintf('<info>Running PSR Fixer on %s</info>', $fileLocation));
     $input = new ArrayInput($arguments);
     $command->run($input, $output);
 }
Beispiel #2
0
 /**
  * Use flysystem to save the file in the desired location.
  *
  * @param \Onema\ClassyFile\Event\GetClassEvent $event
  */
 public function onGetClassGenerateFile(GetClassEvent $event)
 {
     $statement = $event->getStatements();
     $fileLocation = $event->getFileLocation();
     $code = $event->getCode();
     $name = $statement->name;
     if (!$this->filesystem->has($fileLocation)) {
         // dir doesn't exist, make it
         $this->filesystem->createDir($fileLocation);
     }
     $location = sprintf('%s/%s.php', $fileLocation, $name);
     $this->filesystem->put($location, $code);
     $adapter = $this->filesystem->getAdapter();
     if ($adapter instanceof AbstractAdapter) {
         $prefix = $adapter->getPathPrefix();
         $location = Util::normalizePath($location);
         $event->setFileLocation(sprintf('%s%s', $prefix, $location));
     }
 }