Closed ibrasdev closed 6 years ago
Hello @ibrasdev ,
Your class LoadDataListener looks like a service. If so you might have declared it in a service.yml. Then did you place the right service in the arguments of this service ?
Yes ive declared the service in services.yml of CMRBundle : ` cmr.service.listener: class: CMRBundle\EventListener\LoadDataListener tags:
Thank you for helping
Ok then to solve your error, you need to add to your service cmr.service.listener
:
arguments: ["@doctrine.orm.entity_manager"]
Thank you very much its been 2 weeks that i try to solve this much love !
But i have an other problem :
Error: Cannot instantiate abstract class AncaRebeca\FullCalendarBundle\Model\Event
its about :
foreach ($schedules as $schedule) { $calendarEvent->addEvent(new Event($schedule->getTitle(), $schedule->getStart())); }
Look at the step 3 of the installation, You need to create a custom Entity that extends the Event class.
I already created the Schedule entity and ive created 2 events on db but still have same errors
I see, instead of adding your custom event Schedule, you should :
use AncaRebeca\FullCalendarBundle\Model\Event;
class Schedule extends Event {
2. Add the new custom event :
```php
foreach ($schedules as $schedule) {
$calendarEvent->addEvent($schedule);
}
Then this should be good.
Ive added what you said, the error seem to be fixed but i got a new error :(
Compile Error: Access level to CMRBundle\Entity\Schedule::$id must be protected
My class Schedule must be empty ?
Your class Schedule does'nt need to be empty. But if you open the class AncaRebeca\FullCalendarBundle\Model\Event
, you will see some fields already existant.
There are many solutions to this issue :
Pick the one you need.
Hello, I think that i turn around, i got this error :
Error: Call to a member function format() on null
Its about :
$event['start'] = $this->getStartDate()->format("Y-m-d\TH:i:sP");
This is my class Schedule : `class Schedule extends Event { /**
}`
Ive just put the id and ive delete it from Event : ` class Event implements EventInterface { /**
You have two issues here :
The function is used on Event.php :
$event['start'] = $this->getStartDate()->format("Y-m-d\TH:i:sP");
When i genetrate entities i only got the id field on the schedule table not all the fields from the Event
Two ways again :
private $start;
to
protected $startDate;
$event['start'] = $this->getStart()->format("Y-m-d\TH:i:sP");
Hello, Ive recreated Schedule Entity based on Event.php now i got all the fields on the db with protected.
I got this new error :
{"error":"Could not convert database value \"\" to Doctrine Type array"}
Ma patate tu est ou i need you xD
Are the data in your DB important ?
Yes ive generated a new table with all the fields in the Event.php
But when i try to load fixture i got this error :
[Symfony\Component\Debug\Exception\ContextErrorException] Warning: Missing argument 1 for CMRBundle\Entity\Schedule::__construct(), c alled in C:\wamp64\www\No\src\CMRBundle\DataFixtures\ORM\LoadScheduleData.p hp on line 12 and defined
This is the LoadScheduleData.php: `public function load(ObjectManager $manager) { $schedule = new Schedule(); $schedule->setTitle('Yoga class'); $today = new \DateTime(); $schedule->setStartDate($today); $schedule->setEndDate($today); $manager->persist($schedule);
$schedule = new Schedule();
$schedule->setTitle('German class');
$tomorrow = new \DateTime('tomorrow');
$schedule->setStartDate($tomorrow);
$schedule->setEndDate($tomorrow);
$manager->persist($schedule);
$manager->flush();
}`
its about : $schedule = new Schedule();
Si if i have all the fields on the Schedule i must delete the extends Event ?
No, but since you extends this class the __construct is diferent :
/**
* @param string $title
* @param \DateTime $start
*/
public function __construct($title, \DateTime $start)
{
$this->title = $title;
$this->startDate = $start;
}
This is the same code that i have in Event; nothing changes still got the error on doctrine:fixtures:load and on the calendar page Error: Call to a member function format() on null
If the db is empty i got : [] on a blank page but if i add something in the db i got : {"error":"Could not convert database value \"\" to Doctrine Type array"}
The construct needs additionnal parameters, so change your fixture :
$schedule = new Schedule();
$schedule->setTitle('Yoga class');
$today = new \DateTime();
$schedule->setStartDate($today);
to
$today = new \DateTime();
$schedule = new Schedule('Yoga class', $today);
Merci patate.
I dont have more errors on the page but when i acces "full-calendar/load" i have an array with the correct informations in the DB ! Yeah :) But when i show the calendar there is no events !
You're Welcome !
At least you made some progress.
Yes Grace à toi :)
But why i dont get events on the calendar layout ?
When you're on the calendar layout. What does the profiler says about your ajax requests ?
The profiler shows :
POST | xhr | 404 | /full-calendar/load | 26ms | n/a
Did you add the code below in your routing.yml ?
ancarebeca_fullcalendar:
resource: "@FullCalendarBundle/Resources/config/routing.yml"
Yes of course when i access app_dev.php/full-calendar/load i got the events from the table on an array, But in the layout cant get events and my ajax request still 404
Try to clear the cache of the prod environnement.
Ive clear the DEV&PROD cache but nothing changes, i got the same error and my ajax request still 404 :-(
Is FOSJsRouting config properly ?
Yeah ive already config it jsrouting-bundle version 1.6.1.
There is a way to know that ive config well the jsrouting ?
Sorry @ibrasdev, I'm out of time for today. I'll be back tomorrow.
Thank you very much @PATATESUPREME 👍 for your collaboration on this issue. Looks like the original issue was solved, I am going to close this.
Hello, I dont know why i cant run the calendar in good way this is my files please help me its been 2 weeks that i try to solve that :
LoadData :
`<?php
namespace CMRBundle\EventListener;
use AncaRebeca\FullCalendarBundle\Event\CalendarEvent; use AncaRebeca\FullCalendarBundle\Model\Event; use AncaRebeca\FullCalendarBundle\Model\FullCalendarEvent; use CMRBundle\Entity\Schedule; use Doctrine\ORM\EntityManager; class LoadDataListener { /**
@var EntityManager */ private $em;
public function __construct(EntityManager $em) { $this->em = $em; }
/**
@return FullCalendarEvent[] */ public function loadData(CalendarEvent $calendarEvent) { // You can retrieve information from the event dispatcher (eg, You may want which day was selected in the calendar): // $startDate = $calendarEvent->getStart(); // $endDate = $calendarEvent->getEnd(); // $filters = $calendarEvent->getFilters();
} } `
Schedule :
`<?php
namespace CMRBundle\EventListener;
use Doctrine\ORM\Mapping as ORM;
/**
@ORM\Entity(repositoryClass="CMRBundle\Repository\ScheduleRepository") */ class Schedule { /**
/**
/**
/**
/**
/**
@return Schedule */ public function setTitle($title) { $this->title = $title;
return $this; }
/**
/**
/**
/**
/**
And this is the error i dont understand what im missing :
{"error":"Catchable Fatal Error: Argument 1 passed to CMRBundle\\EventListener\\LoadDataListener::__construct() must be an instance of Doctrine\\ORM\\EntityManager, none given, called in C:\\wamp64\\www\\No\\var\\cache\\dev\\appDevDebugProjectContainer.php on line 492 and defined"}
Ive used the example available