Version20160421112900.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V111;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\DBAL\Types\Type;
  7. /**
  8. * Class Version_a
  9. * Remove enable_nanogong and enable_wami_record settings and create enable_record_audio
  10. * @package Application\Migrations\Schema\V111
  11. */
  12. class Version20160421112900 extends AbstractMigrationChamilo
  13. {
  14. /**
  15. * @param Schema $schema
  16. * @throws \Doctrine\DBAL\Schema\SchemaException
  17. */
  18. public function up(Schema $schema)
  19. {
  20. $em = $this->getEntityManager();
  21. $enableNanogong = $em
  22. ->getRepository('ChamiloCoreBundle:SettingsCurrent')
  23. ->findOneBy(['variable' => 'enable_nanogong']);
  24. $enableWami = $em
  25. ->getRepository('ChamiloCoreBundle:SettingsCurrent')
  26. ->findOneBy(['variable' => 'enable_wami_record']);
  27. $enableRecordAudioValue = 'true';
  28. if ($enableNanogong->getSelectedValue() === 'false' && $enableWami->getSelectedValue() === 'false') {
  29. $enableRecordAudioValue = 'false';
  30. }
  31. $this->addSettingCurrent(
  32. 'enable_record_audio',
  33. null,
  34. 'radio',
  35. 'Course',
  36. $enableRecordAudioValue,
  37. 'EnableRecordAudioTitle',
  38. 'EnableRecordAudioComment',
  39. null,
  40. '',
  41. 1,
  42. true,
  43. false,
  44. [
  45. ['value' => 'false', 'text' => 'No'],
  46. ['value' => 'true', 'text' => 'Yes']
  47. ]
  48. );
  49. $em->remove($enableNanogong);
  50. $em->remove($enableWami);
  51. $em->flush();
  52. }
  53. /**
  54. * @param Schema $schema
  55. */
  56. public function down(Schema $schema)
  57. {
  58. }
  59. }