roshyo/planning-bundle

Provides all planning methods for integration in Symfony 3

Installs: 15

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:symfony-bundle

dev-master 2017-11-07 15:42 UTC

This package is not auto-updated.

Last update: 2024-04-25 05:00:25 UTC


README

Provides all planning methods for integration in Symfony 3

Installation

$ composer require roshyo/planning-bundle

Configuration

<?php
// app/AppKernel.php
  public function registerBundles()
  {
    ...,
    new Roshyo\PlanningBundle\RoshyoPlanningBundle(),
    ...,
  }
# app/config.yml

...
roshyo_planning:
    resources:
        resource_name:
            class: 'YourNamespace\YourClass'
            items:
                - 'method'
                - 'method1.method2'

the resource_name can be anything, like employee, customer, doctor, etc...

the class in class section must extend "Roshyo\PlanningBundle\Calendar\Resources"

<?php
// src/AppBundle/Entity/Employee.php
namespace AppBundle\Entity;

use Roshyo\PlanningBundle\Calendar\Resources\Resource;

class Employee extends Resource
{
  ...

Then you can define your fields as usual, and you can map with Doctrine by overriding them or in yml, xml...

Items in item section are a bit more tricky. You have to define which methods return items for the resource. For example, I define :

# app/config.yml

...
roshyo_planning:
    resources:
        resource_name:
            class: 'AppBundle\Entity\Employee'
            items:
                - 'meetings'
                - 'daysOff.dayOff'

Then, there are two different items for my Resource : Employee::getMeetings() returning an array of Items, and Employee::getDaysOff() which returns an array of items with method DayOff::getDayOff(). This second one allows to mark as Item a linked Entity.

The employee must now have at least :

<?php
// src/AppBundle/Entity/Employee.php
namespace AppBundle\Entity;

use Roshyo\PlanningBundle\Calendar\Resources\Resource;

class Employee extends Resource
{
  /**
   * @return \Roshyo\PlanningBundle\Calendar\Items\Item[]
   */
  public function getMeetings(){}
  
  /**
   * @return array|ArrayCollection|EmployeeDayOff[]
   */
  public function getDaysOff(){}
  ...

And the Items:

<?php
// src/AppBundle/Entity/Meeting.php
namespace AppBundle\Entity;

use Roshyo\PlanningBundle\Calendar\Items\Item;

class Meeting extends Item
{
  ...
<?php
// src/AppBundle/Entity/EmployeeDayOff.php
namespace AppBundle\Entity;

class EmployeeDayOff
{
  /**
   * @return DayOff
   */
  public function getDayOff(){}
  ...
<?php
// src/AppBundle/Entity/DayOff.php
namespace AppBundle\Entity;

use Roshyo\PlanningBundle\Calendar\Items\Item;

class DayOff extends Item
{
  ...