You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
61 lines
1.4 KiB
![]()
7 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
|
|
||
|
namespace Chamilo\ApiBundle\GraphQL\Resolver;
|
||
|
|
||
|
use Chamilo\CoreBundle\Entity\Course;
|
||
|
use Chamilo\CoreBundle\Framework\Container;
|
||
|
use Chamilo\UserBundle\Entity\User;
|
||
|
use Overblog\GraphQLBundle\Definition\Resolver\AliasedInterface;
|
||
|
use Overblog\GraphQLBundle\Definition\Resolver\ResolverInterface;
|
||
|
|
||
|
/**
|
||
|
* Class CourseResolver
|
||
|
*
|
||
|
* @package Chamilo\ApiBundle\GraphQL\Resolver
|
||
|
*/
|
||
|
class CourseResolver implements ResolverInterface, AliasedInterface
|
||
|
{
|
||
|
/**
|
||
|
* Returns methods aliases.
|
||
|
*
|
||
|
* For instance:
|
||
|
* array('myMethod' => 'myAlias')
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public static function getAliases()
|
||
|
{
|
||
|
return [
|
||
|
'resolvePicture' => 'course_picture',
|
||
|
'resolveTeachers' => 'course_teachers',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param Course $course
|
||
|
* @param bool $fullSize
|
||
|
*
|
||
|
* @return null|string
|
||
|
*/
|
||
|
public function resolvePicture(Course $course, $fullSize = false)
|
||
|
{
|
||
|
return \CourseManager::getPicturePath($course, $fullSize);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param Course $course
|
||
|
*
|
||
|
* @return array
|
||
|
*/
|
||
|
public function resolveTeachers(Course $course)
|
||
|
{
|
||
|
$courseRepo = Container::getEntityManager()->getRepository('ChamiloCoreBundle:Course');
|
||
|
$teachers = $courseRepo
|
||
|
->getSubscribedTeachers($course)
|
||
|
->getQuery()
|
||
|
->getResult();
|
||
|
|
||
|
return $teachers;
|
||
|
}
|
||
|
}
|