Adding new "session path" tool entities and basic CRUD.

1.10.x
Julio Montoya 12 years ago
parent e241de5131
commit 355cdf413e
  1. 15
      main/inc/Entity/Repository/SessionTreeRepository.php
  2. 94
      main/inc/Entity/SessionPath.php
  3. 418
      main/inc/Entity/SessionTree.php
  4. 124
      main/inc/Entity/Tool.php
  5. 154
      main/inc/Entity/UserSessionPath.php
  6. 4
      main/inc/routes.php
  7. 12
      main/inc/services.php
  8. 5
      main/template/default/app/session_path/add.tpl
  9. 5
      main/template/default/app/session_path/edit.tpl
  10. 21
      main/template/default/app/session_path/list.tpl
  11. 20
      main/template/default/app/session_path/read.tpl
  12. 5
      main/template/default/app/session_path/session_tree/add.tpl
  13. 22
      main/template/default/app/session_path/session_tree/list.tpl
  14. 118
      src/ChamiloLMS/Controller/App/SessionPath/SessionPathController.php
  15. 78
      src/ChamiloLMS/Controller/App/SessionPath/SessionTreeController.php
  16. 21
      src/ChamiloLMS/Controller/BaseController.php
  17. 44
      src/ChamiloLMS/Form/SessionPathType.php
  18. 80
      src/ChamiloLMS/Form/SessionTreeType.php

@ -0,0 +1,15 @@
<?php
namespace Entity\Repository;
use Doctrine\Common\Collections\Criteria;
use Gedmo\Tree\Entity\Repository\NestedTreeRepository;
/**
* Class SessionTreeRepository
* @package Entity\Repository
*/
class SessionTreeRepository extends NestedTreeRepository
{
}

@ -0,0 +1,94 @@
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* SessionPath
*
* @ORM\Table(name="session_path")
* @ORM\Entity
*/
class SessionPath
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false)
*/
private $description;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return SessionPath
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
* @return SessionPath
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}

@ -0,0 +1,418 @@
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* SessionTree
*
* @ORM\Table(name="session_tree")
* @ORM\Entity(repositoryClass="Entity\Repository\SessionTreeRepository")
* @Gedmo\Tree(type="nested")
*/
class SessionTree
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="session_path_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $sessionPathId;
/**
* @var integer
*
* @ORM\Column(name="session_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $sessionId;
/**
* @var integer
*
* @ORM\Column(name="course_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $courseId;
/**
* @var integer
*
* @ORM\Column(name="tool_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $toolId;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $type;
/**
* @var integer
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $lft;
/**
* @var integer
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $lvl;
/**
* @var integer
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $rgt;
/**
* @var integer
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $root;
/**
* @var integer
*
* @ORM\Column(name="parent_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $parentId;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="SessionTree", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="SessionTree", mappedBy="parent")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity="Tool")
* @ORM\JoinColumn(name="tool_id", referencedColumnName="id")
*/
private $tool;
/**
* @ORM\ManyToOne(targetEntity="SessionPath")
* @ORM\JoinColumn(name="session_path_id", referencedColumnName="id")
*/
private $sessionPath;
/**
* @ORM\ManyToOne(targetEntity="Course")
* @ORM\JoinColumn(name="course_id", referencedColumnName="id")
*/
private $course;
/**
* @ORM\ManyToOne(targetEntity="Session")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
*/
private $session;
public function getTool()
{
return $this->tool;
}
public function setTool($tool)
{
$this->tool = $tool;
return $this;
}
public function getCourse()
{
return $this->course;
}
public function setCourse($course)
{
$this->course = $course;
return $this;
}
public function getSession()
{
return $this->session;
}
public function setSession($session)
{
$this->session = $session;
return $this;
}
public function getSessionPath()
{
return $this->sessionPath;
}
public function setSessionPath($sessionPath)
{
$this->sessionPath = $sessionPath;
return $this;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set sessionPathId
*
* @param integer $sessionPathId
* @return SessionTree
*/
public function setSessionPathId($sessionPathId)
{
$this->sessionPathId = $sessionPathId;
return $this;
}
/**
* Get sessionPathId
*
* @return integer
*/
public function getSessionPathId()
{
return $this->sessionPathId;
}
/**
* Set sessionId
*
* @param integer $sessionId
* @return SessionTree
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId
*
* @return integer
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* Set courseId
*
* @param integer $courseId
* @return SessionTree
*/
public function setCourseId($courseId)
{
$this->courseId = $courseId;
return $this;
}
/**
* Get courseId
*
* @return integer
*/
public function getCourseId()
{
return $this->courseId;
}
/**
* Set toolId
*
* @param integer $toolId
* @return SessionTree
*/
public function setToolId($toolId)
{
$this->toolId = $toolId;
return $this;
}
/**
* Get toolId
*
* @return integer
*/
public function getToolId()
{
return $this->toolId;
}
/**
* Set type
*
* @param string $type
* @return SessionTree
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set lft
*
* @param integer $lft
* @return SessionTree
*/
public function setLft($lft)
{
$this->lft = $lft;
return $this;
}
/**
* Get lft
*
* @return integer
*/
public function getLft()
{
return $this->lft;
}
/**
* Set lvl
*
* @param integer $lvl
* @return SessionTree
*/
public function setLvl($lvl)
{
$this->lvl = $lvl;
return $this;
}
/**
* Get lvl
*
* @return integer
*/
public function getLvl()
{
return $this->lvl;
}
/**
* Set rgt
*
* @param integer $rgt
* @return SessionTree
*/
public function setRgt($rgt)
{
$this->rgt = $rgt;
return $this;
}
/**
* Get rgt
*
* @return integer
*/
public function getRgt()
{
return $this->rgt;
}
/**
* Set root
*
* @param integer $root
* @return SessionTree
*/
public function setRoot($root)
{
$this->root = $root;
return $this;
}
/**
* Get root
*
* @return integer
*/
public function getRoot()
{
return $this->root;
}
/**
* Set parentId
*
* @param integer $parentId
* @return SessionTree
*/
public function setParentId($parentId)
{
$this->parentId = $parentId;
return $this;
}
/**
* Get parentId
*
* @return integer
*/
public function getParentId()
{
return $this->parentId;
}
}

@ -0,0 +1,124 @@
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Tool
*
* @ORM\Table(name="tool")
* @ORM\Entity
*/
class Tool
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="image", type="string", length=255, precision=0, scale=0, nullable=true, unique=false)
*/
private $image;
/**
* @var string
*
* @ORM\Column(name="description", type="text", precision=0, scale=0, nullable=true, unique=false)
*/
private $description;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Tool
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set image
*
* @param string $image
* @return Tool
*/
public function setImage($image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set description
*
* @param string $description
* @return Tool
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
}

@ -0,0 +1,154 @@
<?php
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* UserSessionPath
*
* @ORM\Table(name="user_session_path")
* @ORM\Entity
*/
class UserSessionPath
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="session_path_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $sessionPathId;
/**
* @var integer
*
* @ORM\Column(name="user_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $userId;
/**
* @var string
*
* @ORM\Column(name="status", type="string", length=100, precision=0, scale=0, nullable=true, unique=false)
*/
private $status;
/**
* @var integer
*
* @ORM\Column(name="percentage", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $percentage;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set sessionPathId
*
* @param integer $sessionPathId
* @return UserSessionPath
*/
public function setSessionPathId($sessionPathId)
{
$this->sessionPathId = $sessionPathId;
return $this;
}
/**
* Get sessionPathId
*
* @return integer
*/
public function getSessionPathId()
{
return $this->sessionPathId;
}
/**
* Set userId
*
* @param integer $userId
* @return UserSessionPath
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId
*
* @return integer
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set status
*
* @param string $status
* @return UserSessionPath
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* Set percentage
*
* @param integer $percentage
* @return UserSessionPath
*/
public function setPercentage($percentage)
{
$this->percentage = $percentage;
return $this;
}
/**
* Get percentage
*
* @return integer
*/
public function getPercentage()
{
return $this->percentage;
}
}

@ -726,6 +726,10 @@ if ($alreadyInstalled) {
$app->mount('/editor/', new ChamiloLMS\Provider\ReflectionControllerProvider('editor.controller'));
$app->mount('/user/', new ChamiloLMS\Provider\ReflectionControllerProvider('profile.controller'));
$app->mount('/app/session_path', new ChamiloLMS\Provider\ReflectionControllerProvider('session_path.controller'));
$app->mount('/app/session_path/tree', new ChamiloLMS\Provider\ReflectionControllerProvider('session_tree.controller'));
$app->mount('/courses/{course}/curriculum/category', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_category.controller'));
$app->mount('/courses/{course}/curriculum/item', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_item.controller'));
$app->mount('/courses/{course}/curriculum/user', new ChamiloLMS\Provider\ReflectionControllerProvider('curriculum_user.controller'));

@ -814,6 +814,18 @@ $app['curriculum_user.controller'] = $app->share(
}
);
$app['session_path.controller'] = $app->share(
function () use ($app) {
return new ChamiloLMS\Controller\App\SessionPath\SessionPathController($app);
}
);
$app['session_tree.controller'] = $app->share(
function () use ($app) {
return new ChamiloLMS\Controller\App\SessionPath\SessionTreeController($app);
}
);
$app['upgrade.controller'] = $app->share(
function () use ($app) {
return new ChamiloLMS\Controller\Admin\Administrator\UpgradeController($app);

@ -0,0 +1,5 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
{% import app.template_style ~ "/crud_macros/simple_crud.tpl" as actions %}
{{ actions.add(form, links) }}
{% endblock %}

@ -0,0 +1,5 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
{% import app.template_style ~ "/crud_macros/simple_crud.tpl" as actions %}
{{ actions.edit(form, links) }}
{% endblock %}

@ -0,0 +1,21 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
<a href="{{ url(links.create_link) }}">
{{ 'Add' |trans }}
</a>
<table class="table">
{% for item in items %}
<tr>
<td>
<a href="{{ url(links.read_link, { id: item.id }) }}">
{{ item.name }}
</a>
</td>
<td>
<a class="btn" href="{{ url(links.update_link, { id: item.id }) }}"> {{ 'Edit' |trans }}</a>
<a class="btn" href="{{ url(links.delete_link, { id: item.id }) }}"> {{ 'Delete' |trans }}</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

@ -0,0 +1,20 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
<a href="{{ url(links.list_link) }}">
{{ 'List' |trans }}
</a>
<a href="{{ url('session_tree.controller:addTreeItemAction') }}">
{{ 'Add' |trans }}
</a>
{{ item.id }}
<hr />
<ul>
{% for subitem in subitems %}
<li>
<a href="{{ url(links.read_link, { id: subitem.id} ) }}">{{ subitem.branchName }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}

@ -0,0 +1,5 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
{% import app.template_style ~ "/crud_macros/simple_crud.tpl" as actions %}
{{ actions.add(form, links) }}
{% endblock %}

@ -0,0 +1,22 @@
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %}
{% block content %}
<a href="{{ url(links.create_link) }}">
{{ 'Add' |trans }}
</a>
<table class="table">
{% for item in items %}
<tr>
<td>
<a href="{{ url(links.read_link, { id: item.id }) }}">
{{ item.type }}
{{ item.session.name }}
</a>
</td>
<td>
<a class="btn" href="{{ url(links.update_link, { id: item.id }) }}"> {{ 'Edit' |trans }}</a>
<a class="btn" href="{{ url(links.delete_link, { id: item.id }) }}"> {{ 'Delete' |trans }}</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

@ -0,0 +1,118 @@
<?php
/* For licensing terms, see /license.txt */
namespace ChamiloLMS\Controller\App\SessionPath;
use Silex\Application;
use ChamiloLMS\Controller\CommonController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Entity\SessionPath;
use ChamiloLMS\Form\SessionPathType;
/**
* @package ChamiloLMS.Controller
* @author Julio Montoya <gugli100@gmail.com>
*/
class SessionPathController extends CommonController
{
/**
* @Route("/")
* @Method({"GET"})
*/
public function indexAction()
{
return $this->listingAction();
}
/**
*
* @Route("/{id}", requirements={"id" = "\d+"})
* @Method({"GET"})
*/
public function readAction($id)
{
$options = array(
'decorate' => true,
'rootOpen' => '<ul>',
'rootClose' => '</ul>',
'childOpen' => '<li>',
'childClose' => '</li>',
'nodeDecorator' => function($row) {
/*$addChildren = '<a class="btn" href="'.$this->createUrl('add_from_parent_link', array('id' => $row['id'])).'">Add children</a>';
$readLink = '<a href="'.$this->createUrl('read_link', array('id' => $row['id'])).'">'.$row['branchName'].'</a>';
$editLink = '<a class="btn" href="'.$this->createUrl('update_link', array('id' => $row['id'])).'">Edit</a>';
$addDirector = '<a class="btn" href="'.$this->generateUrl('branch.controller:addDirectorAction', array('id' => $row['id'])).'">Add director</a>';
$deleteLink = '<a class="btn" href="'.$this->createUrl('delete_link', array('id' => $row['id'])).'"/>Delete</a>';
return $readLink.' '.$addChildren.' '.$addDirector.' '.$editLink.' '.$deleteLink;*/
}
//'representationField' => 'slug',
//'html' => true
);
// @todo put this in a function
$repo = $this->get('orm.em')->getRepository('Entity\SessionTree');
$query = $this->getManager()
->createQueryBuilder()
->select('node')
->from('Entity\SessionTree', 'node')
//->where('node.cId = 0')
->orderBy('node.root, node.lft', 'ASC')
->getQuery();
$htmlTree = $repo->buildTree($query->getArrayResult(), $options);
$item = $this->getEntity($id);
$this->get('template')->assign('item', $item);
$this->get('template')->assign('tree', $htmlTree);
$this->get('template')->assign('links', $this->generateLinks());
$response = $this->get('template')->render_template($this->getTemplatePath().'read.tpl');
return new Response($response, 200, array());
$this->readEntity($id);
}
protected function getControllerAlias()
{
return 'session_path.controller';
}
/**
* {@inheritdoc}
*/
protected function getTemplatePath()
{
return 'app/session_path/';
}
/**
* {@inheritdoc}
*/
protected function getRepository()
{
return $this->get('orm.em')->getRepository('Entity\SessionPath');
}
/**
* {@inheritdoc}
*/
protected function getNewEntity()
{
return new SessionPath();
}
/**
* {@inheritdoc}
*/
protected function getFormType()
{
return new SessionPathType();
}
}

@ -0,0 +1,78 @@
<?php
/* For licensing terms, see /license.txt */
namespace ChamiloLMS\Controller\App\SessionPath;
use Silex\Application;
use ChamiloLMS\Controller\CommonController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Entity\SessionPath;
use ChamiloLMS\Form\SessionTreeType;
/**
* @package ChamiloLMS.Controller
* @author Julio Montoya <gugli100@gmail.com>
*/
class SessionTreeController extends CommonController
{
/**
* @Route("/")
* @Method({"GET"})
*/
public function indexAction()
{
return $this->listingAction();
}
/**
* @Route("/add_item")
* @Method({"GET"})
*/
public function addTreeItemAction()
{
return $this->addAction();
}
protected function getControllerAlias()
{
return 'session_tree.controller';
}
/**
* {@inheritdoc}
*/
protected function getTemplatePath()
{
return 'app/session_path/session_tree/';
}
/**
* {@inheritdoc}
*/
protected function getRepository()
{
return $this->get('orm.em')->getRepository('Entity\SessionTree');
}
/**
* {@inheritdoc}
*/
protected function getNewEntity()
{
return new SessionTree();
}
/**
* {@inheritdoc}
*/
protected function getFormType()
{
return new SessionTreeType();
}
}

@ -226,10 +226,10 @@ abstract class BaseController extends FlintController
public function listingAction()
{
$items = $this->listAction('array');
$template = $this->get('template');
$template = $this->getTemplate();
$template->assign('items', $items);
$template->assign('links', $this->generateLinks());
$response = $template->render_template($this->getTemplatePath().'list.tpl');
$response = $template->renderTemplate($this->getTemplatePath().'list.tpl');
return new Response($response, 200, array());
}
@ -253,10 +253,10 @@ abstract class BaseController extends FlintController
return $this->redirect($url);
}
$template = $this->get('template');
$template = $this->getTemplate();
$template->assign('links', $this->generateLinks());
$template->assign('form', $form->createView());
$response = $template->render_template($this->getTemplatePath().'add.tpl');
$response = $template->renderTemplate($this->getTemplatePath().'add.tpl');
return new Response($response, 200, array());
}
@ -267,7 +267,7 @@ abstract class BaseController extends FlintController
*/
public function readAction($id)
{
$template = $this->get('template');
$template = $this->getTemplate();
$template->assign('links', $this->generateLinks());
return $this->readEntity($id);
}
@ -297,11 +297,11 @@ abstract class BaseController extends FlintController
return $this->redirect($url);
}
$template = $this->get('template');
$template = $this->getTemplate();
$template->assign('item', $item);
$template->assign('form', $form->createView());
$template->assign('links', $this->generateLinks());
$response = $template->render_template($this->getTemplatePath().'edit.tpl');
$response = $template->renderTemplate($this->getTemplatePath().'edit.tpl');
return new Response($response, 200, array());
} else {
return $this->createNotFoundException();
@ -309,7 +309,6 @@ abstract class BaseController extends FlintController
}
/**
*
* @Route("/{id}/delete", requirements={"id" = "\d+"})
* @Method({"GET"})
*/
@ -324,7 +323,6 @@ abstract class BaseController extends FlintController
}
}
/**
* Base "read" action.
*
@ -432,7 +430,7 @@ abstract class BaseController extends FlintController
/**
* Base "create" action.
*
* @param $object
* @return JsonResponse|NotFoundHttpException
*/
protected function createAction($object)
@ -594,6 +592,9 @@ abstract class BaseController extends FlintController
return $entity;
}
/**
* @return null
*/
protected function getDefaultEntity()
{
return null;

@ -0,0 +1,44 @@
<?php
namespace ChamiloLMS\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Entity;
class SessionPathType extends AbstractType
{
/**
* Builds the form
* For form type details see:
* http://symfony.com/doc/current/reference/forms/types.html
*
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', 'text')
->add('description', 'text')
->add('submit', 'submit');
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
array(
'data_class' => 'Entity\SessionPath'
)
);
}
public function getName()
{
return 'sessionPath';
}
}

@ -0,0 +1,80 @@
<?php
namespace ChamiloLMS\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\ORM\EntityRepository;
use Entity;
class SessionTreeType extends AbstractType
{
/**
* Builds the form
* For form type details see:
* http://symfony.com/doc/current/reference/forms/types.html
*
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('type', 'choice', array('choices' => array('1', '2', '3', '4')));
$builder->add('sessionPath', 'entity', array('class'=>'Entity\SessionPath', 'property' => 'name', 'query_builder'=>
function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.name', 'DESC');
},)
);
$builder->add('tool', 'entity', array('class'=>'Entity\Tool', 'property' => 'name', 'query_builder'=>
function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.name', 'DESC');
},)
);
$builder->add('tool', 'entity', array('class'=>'Entity\Tool', 'property' => 'name', 'query_builder'=>
function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.name', 'DESC');
},)
);
$builder->add('session', 'entity', array('class'=>'Entity\Session', 'property' => 'name', 'query_builder'=>
function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.name', 'DESC');
},)
);
$builder->add('course', 'entity', array('class'=>'Entity\Course', 'property' => 'title', 'query_builder'=>
function (EntityRepository $er) {
return $er->createQueryBuilder('u')
->orderBy('u.title', 'DESC');
},)
);
$builder
->add('submit', 'submit');
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
array(
'data_class' => 'Entity\SessionTree'
)
);
}
public function getName()
{
return 'sessionPath';
}
}
Loading…
Cancel
Save