Add ProjectApiFormatter

This commit is contained in:
Frederic Guillot
2017-05-22 16:12:23 -04:00
parent 3c79d11e02
commit 435e053f12
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace Kanboard\Plugin\Calendar\Formatter;
/**
* Class ProjectApiFormatter
*
* @package Kanboard\Plugin\Calendar\Formatter
*/
class ProjectApiFormatter extends \Kanboard\Formatter\ProjectApiFormatter
{
public function format()
{
$project = parent::format();
if (! empty($project)) {
$project['url']['calendar'] = $this->helper->url->to('CalendarController', 'project', array('project_id' => $project['id'], 'plugin' => 'Calendar'), '', true);
}
return $project;
}
}

View File

@@ -4,6 +4,7 @@ namespace Kanboard\Plugin\Calendar;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Plugin\Calendar\Formatter\ProjectApiFormatter;
use Kanboard\Plugin\Calendar\Formatter\TaskCalendarFormatter;
class Plugin extends Base
@@ -16,6 +17,10 @@ class Plugin extends Base
return new TaskCalendarFormatter($c);
});
$this->container['projectApiFormatter'] = $this->container->factory(function ($c) {
return new ProjectApiFormatter($c);
});
$this->template->hook->attach('template:dashboard:page-header:menu', 'Calendar:dashboard/menu');
$this->template->hook->attach('template:project:dropdown', 'Calendar:project/dropdown');
$this->template->hook->attach('template:project-header:view-switcher', 'Calendar:project_header/views');