ConsoleRunner.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the LGPL. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\ORM\Tools\Console;
  20. use Symfony\Component\Console\Application;
  21. use Symfony\Component\Console\Helper\HelperSet;
  22. class ConsoleRunner
  23. {
  24. /**
  25. * Run console with the given helperset.
  26. *
  27. * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
  28. * @return void
  29. */
  30. static public function run(HelperSet $helperSet)
  31. {
  32. $cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION);
  33. $cli->setCatchExceptions(true);
  34. $cli->setHelperSet($helperSet);
  35. self::addCommands($cli);
  36. $cli->run();
  37. }
  38. /**
  39. * @param Application $cli
  40. */
  41. static public function addCommands(Application $cli)
  42. {
  43. $cli->addCommands(array(
  44. // DBAL Commands
  45. new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
  46. new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
  47. // ORM Commands
  48. new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
  49. new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
  50. new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
  51. new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
  52. new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
  53. new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
  54. new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
  55. new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
  56. new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
  57. new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
  58. new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
  59. new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
  60. new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
  61. new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),
  62. new \Doctrine\ORM\Tools\Console\Command\InfoCommand()
  63. ));
  64. }
  65. }