You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 line
942B

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\composer;
  8. use Composer\Composer;
  9. use Composer\IO\IOInterface;
  10. use Composer\Plugin\PluginInterface;
  11. /**
  12. * Plugin is the composer plugin that registers the Yii composer installer.
  13. *
  14. * @author Qiang Xue <qiang.xue@gmail.com>
  15. * @since 2.0
  16. */
  17. class Plugin implements PluginInterface
  18. {
  19. /**
  20. * @inheritdoc
  21. */
  22. public function activate(Composer $composer, IOInterface $io)
  23. {
  24. $installer = new Installer($io, $composer);
  25. $composer->getInstallationManager()->addInstaller($installer);
  26. $file = rtrim($composer->getConfig()->get('vendor-dir'), '/') . '/yiisoft/extensions.php';
  27. if (!is_file($file)) {
  28. @mkdir(dirname($file), 0777, true);
  29. file_put_contents($file, "<?php\n\nreturn [];\n");
  30. }
  31. }
  32. }