Move constants into constant classes

pull/3844/head
Julio Montoya 4 years ago
parent 539d245e7c
commit 6d7e5c1f95
  1. 6
      public/main/inc/lib/api.lib.php
  2. 9
      public/main/inc/lib/career.lib.php
  3. 11
      public/main/inc/lib/promotion.lib.php
  4. 8
      src/CoreBundle/Entity/Career.php
  5. 8
      src/CoreBundle/Entity/Promotion.php

@ -432,12 +432,6 @@ define('HOOK_EVENT_TYPE_PRE', 0);
define('HOOK_EVENT_TYPE_POST', 1);
define('HOOK_EVENT_TYPE_ALL', 10);
define('CAREER_STATUS_ACTIVE', 1);
define('CAREER_STATUS_INACTIVE', 0);
define('PROMOTION_STATUS_ACTIVE', 1);
define('PROMOTION_STATUS_INACTIVE', 0);
// Group permissions
define('GROUP_PERMISSION_OPEN', '1');
define('GROUP_PERMISSION_CLOSED', '2');

@ -3,6 +3,7 @@
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
use Chamilo\CoreBundle\Entity\Career as CareerEntity;
/**
* Class Career.
@ -104,8 +105,8 @@ class Career extends Model
public function get_status_list()
{
return [
CAREER_STATUS_ACTIVE => get_lang('Unarchived'),
CAREER_STATUS_INACTIVE => get_lang('Archived'),
CareerEntity::CAREER_STATUS_ACTIVE => get_lang('Unarchived'),
CareerEntity::CAREER_STATUS_INACTIVE => get_lang('Archived'),
];
}
@ -124,7 +125,7 @@ class Career extends Model
$form = new FormValidator('career', 'post', $url);
// Setting the form elements
$header = get_lang('Add');
if ('edit' == $action) {
if ('edit' === $action) {
$header = get_lang('Edit');
}
@ -146,7 +147,7 @@ class Career extends Model
$status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ('edit' == $action) {
if ('edit' === $action) {
$extraField = new ExtraField('career');
$extraField->addElements($form, $id);

@ -2,6 +2,8 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Promotion as PromotionEntity;
/**
* Class Promotion
* This class provides methods for the promotion management.
@ -145,14 +147,11 @@ class Promotion extends Model
);
}
/**
* @return array
*/
public function get_status_list()
public function get_status_list(): array
{
return [
PROMOTION_STATUS_ACTIVE => get_lang('active'),
PROMOTION_STATUS_INACTIVE => get_lang('inactive'),
PromotionEntity::PROMOTION_STATUS_ACTIVE => get_lang('active'),
PromotionEntity::PROMOTION_STATUS_INACTIVE => get_lang('inactive'),
];
}

@ -20,6 +20,9 @@ class Career
{
use TimestampableEntity;
public const CAREER_STATUS_ACTIVE = 1;
public const CAREER_STATUS_INACTIVE = 0;
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
@ -43,6 +46,11 @@ class Career
*/
protected int $status;
public function __construct()
{
$this->status = self::CAREER_STATUS_ACTIVE;
}
/**
* Get id.
*

@ -20,6 +20,9 @@ class Promotion
{
use TimestampableEntity;
public const PROMOTION_STATUS_ACTIVE = 1;
public const PROMOTION_STATUS_INACTIVE = 0;
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
@ -49,6 +52,11 @@ class Promotion
*/
protected int $status;
public function __construct()
{
$this->status = self::PROMOTION_STATUS_ACTIVE;
}
/**
* Get id.
*

Loading…
Cancel
Save