Minor - clean entity remove plugin funcionality from entity

- function getBuyCoursePluginPrice
- use protected instead of private
pull/2624/head
Julio Montoya 8 years ago
parent 5d6489654a
commit 905f88afbc
  1. 3
      main/auth/courses_controller.php
  2. 29
      plugin/buycourses/src/buy_course_plugin.class.php
  3. 20
      src/Chamilo/CoreBundle/Entity/Portfolio.php
  4. 20
      src/Chamilo/CoreBundle/Entity/Session.php
  5. 49
      src/Chamilo/CourseBundle/Entity/CItemProperty.php
  6. 2
      src/Chamilo/UserBundle/Entity/User.php

@ -930,7 +930,8 @@ class CoursesController
$actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session->getId();
}
$isThisSessionOnSale = $session->getBuyCoursePluginPrice();
$plugin = \BuyCoursesPlugin::create();
$isThisSessionOnSale = $plugin->getBuyCoursePluginPrice($session);
$sessionsBlock = [
'id' => $session->getId(),

@ -2514,8 +2514,33 @@ class BuyCoursesPlugin extends Plugin
return Database::update(
$serviceSaleTable,
['status' => intval($newStatus)],
['id = ?' => intval($serviceSaleId)]
['status' => (int) $newStatus],
['id = ?' => (int) $serviceSaleId]
);
}
/**
* @param Session $session
*
* @return array
*/
public function getBuyCoursePluginPrice(Session $session)
{
// start buycourse validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
$isThisCourseInSale = $this->buyCoursesForGridCatalogValidator($session->getId(), self::PRODUCT_TYPE_SESSION);
$return = [];
if ($isThisCourseInSale) {
// set the Price label
$return['html'] = $isThisCourseInSale['html'];
// set the Buy button instead register.
if ($isThisCourseInSale['verificator']) {
$return['buy_button'] = $this->returnBuyCourseButton($session->getId(), self::PRODUCT_TYPE_SESSION);
}
}
// end buycourse validation
return $return;
}
}

@ -32,20 +32,20 @@ class Portfolio
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
protected $id;
/**
* @var string
*
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
protected $title;
/**
* @var string
* @ORM\Column(name="content", type="text")
*/
private $content;
protected $content;
/**
* @var User
@ -53,7 +53,7 @@ class Portfolio
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/
private $user;
protected $user;
/**
* @var Course
@ -61,7 +61,7 @@ class Portfolio
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $course = null;
protected $course = null;
/**
* @var Session
@ -69,28 +69,28 @@ class Portfolio
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $session = null;
protected $session = null;
/**
* @var \DateTime
*
* @ORM\Column(name="creation_date", type="datetime")
*/
private $creationDate;
protected $creationDate;
/**
* @var \DateTime
*
* @ORM\Column(name="update_date", type="datetime")
*/
private $updateDate;
protected $updateDate;
/**
* @var bool
*
* @ORM\Column(name="is_visible", type="boolean", options={"default": true})
*/
private $isVisible = true;
protected $isVisible = true;
/**
* @var \Chamilo\CoreBundle\Entity\PortfolioCategory
@ -98,7 +98,7 @@ class Portfolio
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioCategory", inversedBy="items")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $category;
protected $category;
/**
* Portfolio constructor.

@ -1103,26 +1103,6 @@ class Session
return $this->userCourseSubscriptions->matching($criteria);
}
public function getBuyCoursePluginPrice()
{
// start buycourse validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
$plugin = \BuyCoursesPlugin::create();
$isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator($this->id, \BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
$return = [];
if ($isThisCourseInSale) {
// set the Price label
$return['html'] = $isThisCourseInSale['html'];
// set the Buy button instead register.
if ($isThisCourseInSale['verificator']) {
$return['buy_button'] = $plugin->returnBuyCourseButton($this->id, \BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
}
}
// end buycourse validation
return $return;
}
/**
* @param ArrayCollection $studentPublications
*

@ -15,6 +15,22 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CItemProperty
{
/**
* @var int
*
* @ORM\Column(name="iid", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
protected $iid;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=true)
*/
protected $id;
/** //, inversedBy="users",
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", cascade={"persist"})
* @ORM\JoinColumn(name="c_id", referencedColumnName="id")
@ -44,84 +60,69 @@ class CItemProperty
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
*/
protected $session;
/**
* @var int
*
* @ORM\Column(name="iid", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $iid;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=true)
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="tool", type="string", length=100, nullable=false)
*/
private $tool;
protected $tool;
/**
* @var \DateTime
*
* @ORM\Column(name="insert_date", type="datetime", nullable=false)
*/
private $insertDate;
protected $insertDate;
/**
* @var \DateTime
*
* @ORM\Column(name="lastedit_date", type="datetime", nullable=false)
*/
private $lasteditDate;
protected $lasteditDate;
/**
* @var int
*
* @ORM\Column(name="ref", type="integer", nullable=false)
*/
private $ref;
protected $ref;
/**
* @var string
*
* @ORM\Column(name="lastedit_type", type="string", length=100, nullable=false)
*/
private $lasteditType;
protected $lasteditType;
/**
* @var int
*
* @ORM\Column(name="lastedit_user_id", type="integer", nullable=false)
*/
private $lasteditUserId;
protected $lasteditUserId;
/**
* @var int
*
* @ORM\Column(name="visibility", type="integer", nullable=false)
*/
private $visibility;
protected $visibility;
/**
* @var \DateTime
*
* @ORM\Column(name="start_visible", type="datetime", nullable=true)
*/
private $startVisible;
protected $startVisible;
/**
* @var \DateTime
*
* @ORM\Column(name="end_visible", type="datetime", nullable=true)
*/
private $endVisible;
protected $endVisible;
/**
* CItemProperty constructor.

@ -2582,6 +2582,4 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
return $this;
}
}

Loading…
Cancel
Save