我正在使用 symfony2、doctroin2 和 calendR。
我正在尝试将calendR 与学说2 集成。
我做了这里描述的服务
services:
booking_repository:
class: Acme\UserBundle\Entity\EventRepository
factory_service: doctrine.orm.default_entity_manager
factory_method: getRepository
arguments: ['UserBundle:MutorSche']
tags:
- { name: calendr.event_provider }
然后我按照这里的描述制作了 EventRepository
class EventRepository extends EntityRepository
{
public function getEventsQueryBuilder(\DateTime $begin, \DateTime $end, array $options = array())
{
$qb = $this->createQueryBuilder('e');
return QueryHelper::addEventQuery($qb, 'e.begin', 'e.end', $begin, $end)
->getQuery()
->getResults()
;
}
}
然后我在下面制作了这样的实体
use Doctrine\ORM\Mapping as ORM;
/**
* MutorSche
*
* @ORM\Table()
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class MutorSche implements \CalendR\Event\Provider\ProviderInterface
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
function getEvents(\DateTime $begin, \DateTime $end, array $options = array()){
}
我认为它实现了 \CalendR\Event\Provider\ProviderInterface 类和函数 getEvents
但它仍然说,
ErrorException: Catchable Fatal Error: Argument 2 passed to CalendR\Event\Manager::addProvider() must implement interface CalendR\Event\Provider\ProviderInterface, instance of Doctrine\ORM\EntityRepository given, called in /Users/whitebear/httproot/muty/app/cache/dev/appDevDebugProjectContainer.php on line 1440 and defined in /Users/whitebear/httproot/muty/vendor/yohang/calendr/src/CalendR/Event/Manager.php line 101
我的堆栈跟踪如下。请给我一些提示。
in /Users/whitebear/httproot/mutor/vendor/yohang/calendr/src/CalendR/Event/Manager.php line 101
at ErrorHandler->handle('4096', 'Argument 2 passed to CalendR\Event\Manager::addProvider() must implement interface CalendR\Event\Provider\ProviderInterface, instance of Doctrine\ORM\EntityRepository given, called in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php on line 1440 and defined', '/Users/whitebear/httproot/mutor/vendor/yohang/calendr/src/CalendR/Event/Manager.php', '101', array('name' => 'booking_repository')) in /Users/whitebear/httproot/mutor/vendor/yohang/calendr/src/CalendR/Event/Manager.php line 101
at Manager->addProvider('booking_repository', object(EntityRepository)) in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 1440
at appDevDebugProjectContainer->getFrequenceWebCalendr_Event_ManagerService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('frequence_web_calendr.event.manager') in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 1457
at appDevDebugProjectContainer->getFrequenceWebCalendr_FactoryService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('frequence_web_calendr.factory') in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 1473
at appDevDebugProjectContainer->getFrequenceWebCalendr_TwigExtensionService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('frequence_web_calendr.twig_extension') in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 4607
at appDevDebugProjectContainer->getTwigService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('twig') in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 100
at appDevDebugProjectContainer->getAssetic_AssetManagerService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('assetic.asset_manager') in /Users/whitebear/httproot/mutor/app/cache/dev/appDevDebugProjectContainer.php line 2032
at appDevDebugProjectContainer->getRouting_LoaderService() in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 129
at Container->get('routing.loader') in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 1426
at Router->getRouteCollection() in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 1218
at Router->getMatcher() in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 1205
at Router->match('/') in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 3611
at RouterListener->onKernelRequest(object(GetResponseEvent))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 451
at Symfony\Component\HttpKernel\Debug\{closure}(object(GetResponseEvent))
at call_user_func(object(Closure), object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 3415
at EventDispatcher->doDispatch(array(object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure), object(Closure)), 'kernel.request', object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 3348
at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/app/cache/dev/classes.php line 3512
at ContainerAwareEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php line 139
at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 992
at HttpKernel->handleRaw(object(Request), '1') in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 977
at HttpKernel->handle(object(Request), '1', true) in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 1103
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in /Users/whitebear/httproot/mutor/app/bootstrap.php.cache line 413
at Kernel->handle(object(Request)) in /Users/whitebear/httproot/mutor/web/app_dev.php line 26