parent
34be57a90d
commit
e2506faf93
@ -0,0 +1,37 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Form\Resource; |
||||
|
||||
use Chamilo\CourseBundle\Entity\CCourseDescription; |
||||
use Symfony\Component\Form\AbstractType; |
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
||||
use Symfony\Component\Form\Extension\Core\Type\TextType; |
||||
use Symfony\Component\Form\FormBuilderInterface; |
||||
use Symfony\Component\OptionsResolver\OptionsResolver; |
||||
|
||||
class CCourseDescriptionType extends AbstractType |
||||
{ |
||||
public function buildForm(FormBuilderInterface $builder, array $options) |
||||
{ |
||||
$builder |
||||
->add('title', TextType::class) |
||||
->add('content', TextareaType::class) |
||||
; |
||||
} |
||||
|
||||
public function configureOptions(OptionsResolver $resolver) |
||||
{ |
||||
$resolver->setDefaults( |
||||
[ |
||||
'data_class' => CCourseDescription::class, |
||||
] |
||||
); |
||||
} |
||||
|
||||
public function getName() |
||||
{ |
||||
return 'chamilo_c_course_description'; |
||||
} |
||||
} |
@ -0,0 +1,67 @@ |
||||
<?php |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CourseBundle\Repository; |
||||
|
||||
use APY\DataGridBundle\Grid\Column\Column; |
||||
use APY\DataGridBundle\Grid\Grid; |
||||
use Chamilo\CoreBundle\Component\Utils\ResourceSettings; |
||||
use Chamilo\CoreBundle\Entity\Course; |
||||
use Chamilo\CoreBundle\Entity\Resource\ResourceNode; |
||||
use Chamilo\CoreBundle\Entity\Session; |
||||
use Chamilo\CoreBundle\Repository\ResourceRepository; |
||||
use Chamilo\CoreBundle\Repository\ResourceRepositoryInterface; |
||||
use Chamilo\CourseBundle\Entity\CCourseDescription; |
||||
use Chamilo\CourseBundle\Entity\CGroupInfo; |
||||
use Chamilo\UserBundle\Entity\User; |
||||
use Doctrine\ORM\QueryBuilder; |
||||
use Symfony\Component\Form\FormInterface; |
||||
use Symfony\Component\HttpFoundation\File\UploadedFile; |
||||
|
||||
final class CCourseDescriptionRepository extends ResourceRepository implements ResourceRepositoryInterface |
||||
{ |
||||
public function getResourceSettings(): ResourceSettings |
||||
{ |
||||
$settings = parent::getResourceSettings(); |
||||
|
||||
$settings |
||||
->setAllowNodeCreation(false) |
||||
->setAllowResourceCreation(true) |
||||
->setAllowResourceUpload(false) |
||||
->setAllowDownloadAll(false) |
||||
; |
||||
|
||||
return $settings; |
||||
} |
||||
|
||||
public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroupInfo $group = null): QueryBuilder |
||||
{ |
||||
return $this->getResourcesByCourse($course, $session, $group, $parentNode); |
||||
} |
||||
|
||||
public function getTitleColumn(Grid $grid): Column |
||||
{ |
||||
return $grid->getColumn('title'); |
||||
} |
||||
|
||||
public function saveUpload(UploadedFile $file) { |
||||
|
||||
} |
||||
|
||||
public function saveResource(FormInterface $form, $course, $session, $fileType) |
||||
{ |
||||
/** @var CCourseDescription $newResource */ |
||||
$newResource = $form->getData(); |
||||
|
||||
$newResource |
||||
->setCId($course->getId()) |
||||
; |
||||
|
||||
if ($session) { |
||||
$newResource->setSessionId($session->getId()); |
||||
} |
||||
|
||||
return $newResource; |
||||
} |
||||
} |
Loading…
Reference in new issue