Fix function addSettingCurrent

1.10.x
Julio Montoya 11 years ago
parent 051dea3bf2
commit 63ccf68d85
  1. 71
      src/Chamilo/CoreBundle/Migrations/AbstractMigrationChamilo.php

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Migrations; namespace Chamilo\CoreBundle\Migrations;
@ -33,29 +34,31 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
/** /**
* Speeds up SettingsCurrent creation * Speeds up SettingsCurrent creation
* @param string $variable The variable itself * @param string $variable The variable itself
* @param string $subKey The subkey * @param string $subKey The subkey
* @param string $type The type of setting (text, radio, select, etc) * @param string $type The type of setting (text, radio, select, etc)
* @param string $category The category (Platform, User, etc) * @param string $category The category (Platform, User, etc)
* @param string $selectedValue The default value * @param string $selectedValue The default value
* @param string $title The setting title string name * @param string $title The setting title string name
* @param string $comment The setting comment string name * @param string $comment The setting comment string name
* @param string $scope The scope * @param string $scope The scope
* @param string $subKeyText Text if there is a subKey * @param string $subKeyText Text if there is a subKey
* @param int $accessUrl What URL it is for * @param int $accessUrl What URL it is for
* @param bool $accessUrlChangeable Whether it can be changed on each url * @param bool $accessUrlChangeable Whether it can be changed on each url
* @param bool $accessUrlLocked Whether the setting for the current URL is locked to the current value * @param bool $accessUrlLocked Whether the setting for the current URL is
* @param array $options Optional array in case of a radio-type field, to insert options * locked to the current value
* @param array $options Optional array in case of a radio-type field,
* to insert options
*/ */
public function addSettingCurrent( public function addSettingCurrent(
$variable, $variable,
$subKey = '', $subKey,
$type, $type,
$category, $category,
$selectedValue, $selectedValue,
$title, $title,
$comment, $comment,
$scope = null, $scope = '',
$subKeyText = '', $subKeyText = '',
$accessUrl = 1, $accessUrl = 1,
$accessUrlChangeable = false, $accessUrlChangeable = false,
@ -63,25 +66,25 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
$options = array() $options = array()
) { ) {
$setting = new SettingsCurrent(); $setting = new SettingsCurrent();
$setting->setVariable($variable); $setting
$setting->setSubkey($subKey); ->setVariable($variable)
$setting->setType($type); ->setSubkey($subKey)
$setting->setCategory($category); ->setType($type)
$setting->setSelectedValue($selectedValue); ->setCategory($category)
$setting->setTitle($title); ->setSelectedValue($selectedValue)
$setting->setComment($comment); ->setTitle($title)
$setting->setScope($scope); ->setComment($comment)
$setting->setSubkeytext($subKeyText); ->setScope($scope)
$setting->setAccessUrl($accessUrl); ->setSubkeytext($subKeyText)
$setting->setAccessUrlChangeable($accessUrlChangeable); ->setAccessUrl($accessUrl)
$setting->setAccessUrlLocked($accessUrlLocked); ->setAccessUrlChangeable($accessUrlChangeable)
->setAccessUrlLocked($accessUrlLocked);
$this->getEntityManager()->persist($setting); $this->getEntityManager()->persist($setting);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
if (count($options) > 0) { if (count($options) > 0) {
foreach ($options as $option) { foreach ($options as $option) {
$option = new SettingsOptions();
$option->setVariable($variable);
$option->setValue($option['value']);
if (empty($option['text'])) { if (empty($option['text'])) {
if ($option['value'] == 'true') { if ($option['value'] == 'true') {
$option['text'] = 'Yes'; $option['text'] = 'Yes';
@ -89,8 +92,12 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
$option['text'] = 'No'; $option['text'] = 'No';
} }
} }
$option->setDisplayText($option['text']); $settingOption = new SettingsOptions();
$this->getEntityManager()->persis($option); $settingOption
->setVariable($variable)
->setValue($option['value'])
->setDisplayText($option['text']);
$this->getEntityManager()->persist($settingOption);
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
} }
} }

Loading…
Cancel
Save