roshyo / planning-bundle
为 Symfony 3 提供所有集成规划方法
dev-master
2017-11-07 15:42 UTC
Requires
- php: ^7.0
- doctrine/doctrine-bundle: ^1.6
- symfony/symfony: 3.*
This package is not auto-updated.
Last update: 2024-09-26 06:48:53 UTC
README
为 Symfony 3 提供所有集成规划方法
安装
$ composer require roshyo/planning-bundle
配置
<?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'
资源名可以是任何名称,如员工、客户、医生等...
在类部分中,必须扩展 "Roshyo\PlanningBundle\Calendar\Resources" 类
<?php // src/AppBundle/Entity/Employee.php namespace AppBundle\Entity; use Roshyo\PlanningBundle\Calendar\Resources\Resource; class Employee extends Resource { ...
然后,您可以像平常一样定义字段,并且可以通过覆盖它们或在 yml、xml 中进行映射,与 Doctrine 进行映射
项目部分中的项目有点复杂。您必须定义哪些方法返回资源的项目。例如,我定义了
# app/config.yml ... roshyo_planning: resources: resource_name: class: 'AppBundle\Entity\Employee' items: - 'meetings' - 'daysOff.dayOff'
然后,对于我的资源,有两个不同的项目:Employee::getMeetings() 返回一个包含项目的数组,以及 Employee::getDaysOff() 返回一个包含项目的数组,其中使用 DayOff::getDayOff() 方法。第二个允许将链接的实体标记为项目。
现在员工至少需要
<?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(){} ...
并且项目
<?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 { ...