Minor - fix entity property

pull/2715/head
Julio Montoya 7 years ago
parent 75577f6b5e
commit 88a1f5fcfb
  1. 2
      app/Migrations/AbstractMigrationChamilo.php
  2. 6
      main/inc/lib/api.lib.php
  3. 44
      src/CoreBundle/Entity/SettingsCurrent.php
  4. 4
      tests/scripts/fix_duplicate_settings.php

@ -95,7 +95,7 @@ abstract class AbstractMigrationChamilo extends AbstractMigration
->setComment($comment)
->setScope($scope)
->setSubkeytext($subKeyText)
->setAccessUrl($accessUrl)
->setUrl($accessUrl)
->setAccessUrlChangeable($accessUrlChangeable)
->setAccessUrlLocked($accessUrlLocked);

@ -6015,7 +6015,7 @@ function api_add_setting(
$value = trim($value);
}
$criteria = ['variable' => $variable, 'accessUrl' => $accessUrlId];
$criteria = ['variable' => $variable, 'url' => $accessUrlId];
if (!empty($subKey)) {
$criteria['subkey'] = $subKey;
@ -6037,6 +6037,8 @@ function api_add_setting(
// Item not found for this access_url, we have to check if the whole thing is missing
// (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
$setting = new SettingsCurrent();
$url = api_get_url_entity();
$setting
->setVariable($variable)
->setSelectedValue($value)
@ -6047,7 +6049,7 @@ function api_add_setting(
->setComment($comment)
->setScope($scope)
->setSubkeytext($subKeyText)
->setAccessUrl($accessUrlId)
->setUrl(api_get_url_entity())
->setAccessUrlChangeable($visibility);
$em->persist($setting);

@ -22,11 +22,6 @@ use Doctrine\ORM\Mapping as ORM;
*/
class SettingsCurrent
{
/**
* @ORM\ManyToOne(targetEntity="AccessUrl", inversedBy="settings", cascade={"persist"})
* @ORM\JoinColumn(name="access_url", referencedColumnName="id")
*/
protected $url;
/**
* @var int
*
@ -36,6 +31,14 @@ class SettingsCurrent
*/
protected $id;
/**
* @var AccessUrl
*
* @ORM\ManyToOne(targetEntity="AccessUrl", inversedBy="settings", cascade={"persist"})
* @ORM\JoinColumn(name="access_url", referencedColumnName="id")
*/
protected $url;
/**
* @var string
*
@ -99,13 +102,6 @@ class SettingsCurrent
*/
protected $subkeytext;
/**
* @var int
*
* @ORM\Column(name="access_url", type="integer", nullable=false, options={"default": 1 } )
*/
protected $accessUrl;
/**
* @var int
*
@ -344,30 +340,6 @@ class SettingsCurrent
return $this->subkeytext;
}
/**
* Set accessUrl.
*
* @param int $accessUrl
*
* @return SettingsCurrent
*/
public function setAccessUrl($accessUrl)
{
$this->accessUrl = $accessUrl;
return $this;
}
/**
* Get accessUrl.
*
* @return int
*/
public function getAccessUrl()
{
return $this->accessUrl;
}
/**
* Set accessUrlChangeable.
*

@ -24,7 +24,7 @@ foreach ($settingsCurrent as $settingCurrent) {
[
$settingCurrent->getVariable(),
$settingCurrent->getSubkey(),
$settingCurrent->getAccessUrl()
$settingCurrent->getUrl()
]
);
@ -68,7 +68,7 @@ if (empty($duplicatedCurrent)) {
foreach ($duplicatedCurrent as $settingCurrent) {
echo vsprintf(
"variable = '%s' subkey = '%s' access_url = '%s'<br>" . PHP_EOL,
[$settingCurrent->getVariable(), $settingCurrent->getSubkey(), $settingCurrent->getAccessUrl()]
[$settingCurrent->getVariable(), $settingCurrent->getSubkey(), $settingCurrent->getUrl()]
);
$entityManager->remove($settingCurrent);

Loading…
Cancel
Save