geekshub/schedulebundle

为symfony 3+提供的轻量级调度包

安装: 5

依赖者: 0

建议者: 0

安全性: 0

星星: 2

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2019-04-17 09:44 UTC

This package is auto-updated.

Last update: 2024-09-17 22:14:28 UTC


README

您可以在geekshub.net找到此包的功能演示

安装

1. 配置您的应用程序模板
# app/config/config.yml (Symfony <=3)
framework:
    templating:
        engines: ['twig']
2. 使用 Composer 安装此包
composer require geekshub/schedulebundle
3. 将调度包添加到您的应用程序内核
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new \Geekshub\ScheduleBundle\GeekshubScheduleBundle(),
        // ...
    );
}
4. 配置包
# app/config/config.yml
geekshub_schedule: ~

这是一个基本配置,包将使用在配置部分中可以找到的默认值。

使用方法

在您的控制器中

要添加任务到您的调度中,您可以使用 addTaskByAttr() 方法 addTaskByAttr($label, $group, $start_date, $expected_end_date, $real_end_date, $title, $link)

addTaskByAttr() 方法接受七个参数

例如

public function showPlaningAction()
{
   // retrieve the schedule service from container
   $schedule = $this->container->get('geekshub_schedule'); 
   
   // retrieve the data you want to add to the schedule
   $tasks = $this->getManager()->getRepository('Yourclass')->getScheduledTasks(); 
   
   // Loop over the tasks and add them to the schedule 
   
   foreach($tasks as $task){
      $schedule->addTaskByAttr(...) ; 
   }
}

注意:对于Symfony 4.*,您必须使用依赖注入来检索调度。它应该看起来像这样

public function showPlaningAction(Schedule $schedule) // dependency injection
{
   // ... //
}

配置

以下默认参数可以在您的config.yml或类似文件中覆盖

geekshub_schedule:
    show_weekends: false
    use_link: true
    separator_color: "#bdbdbd"
    style:
      taskCellClass: "task_cell"
      yearRowClass: "years_row"
      weekRowClass: "weeks_row"
      monthRowClass: "months_row"
      dayRowClass: "days_row"
      groupRowClass: "group_row"
      taskRowClass: "task_row"
      taskCellDelayClass: "task_cell_delay"

覆盖模板

您可以通过将Resources/views/table.html.twig文件复制到您自己的包中,然后将其作为参数传递给gh_render_planning来覆盖模板。使用scheduleTemplate配置参数

{{ gh_render_planning({ scheduleTemplate: "YourOwnBundle::YourSchedule.html.twig" }) }}

贡献

我们欢迎对此项目的贡献,包括拉取请求和问题(以及现有问题上的讨论)。我们接受任何旨在改进包以服务于更大目的的建议。