mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
initial commit
This commit is contained in:
commit
7a85e00c16
29
ChillTaskBundle.php
Normal file
29
ChillTaskBundle.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
namespace Chill\TaskBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class ChillTaskBundle extends Bundle
|
||||
{
|
||||
|
||||
}
|
13
Controller/DefaultController.php
Normal file
13
Controller/DefaultController.php
Normal file
@ -0,0 +1,13 @@
|
||||
?php
|
||||
|
||||
namespace Chill\TaskBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
return $this->render('ChillTaskBundle:Default:index.html.twig');
|
||||
}
|
||||
}
|
28
DependencyInjection/ChillTaskExtension.php
Normal file
28
DependencyInjection/ChillTaskExtension.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration.
|
||||
*
|
||||
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
|
||||
*/
|
||||
class ChillTaskExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
//$loader->load('services.yml');
|
||||
}
|
||||
}
|
29
DependencyInjection/Configuration.php
Normal file
29
DependencyInjection/Configuration.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This is the class that validates and merges configuration from your app/config files.
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('chill_task');
|
||||
|
||||
// Here you should define the parameters that are allowed to
|
||||
// configure your bundle. See the documentation linked above for
|
||||
// more information on that topic.
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
169
Entity/AbstractTask.php
Normal file
169
Entity/AbstractTask.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
|
||||
/**
|
||||
* AbstractTask
|
||||
*
|
||||
* @ORM\MappedSuperclass()
|
||||
*/
|
||||
abstract class AbstractTask
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="type", type="string", length=255)
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var json
|
||||
*
|
||||
* @ORM\Column(name="current_states", type="json")
|
||||
*/
|
||||
private $currentStates = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="title", type="text")
|
||||
*/
|
||||
private $title = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="description", type="text")
|
||||
*/
|
||||
private $description = '';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var User
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\User"
|
||||
* )
|
||||
*/
|
||||
private $assignee;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Person
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*/
|
||||
private $person;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Scope
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\MainBundle\Entity\Scope"
|
||||
* )
|
||||
*/
|
||||
private $circle;
|
||||
|
||||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return AbstractTask
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set currentStates
|
||||
*
|
||||
* @param json $currentStates
|
||||
*
|
||||
* @return AbstractTask
|
||||
*/
|
||||
public function setCurrentStates($currentStates)
|
||||
{
|
||||
$this->currentStates = $currentStates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currentStates
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function getCurrentStates()
|
||||
{
|
||||
return $this->currentStates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string $title
|
||||
*
|
||||
* @return AbstractTask
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set description
|
||||
*
|
||||
* @param string $description
|
||||
*
|
||||
* @return AbstractTask
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
}
|
||||
|
210
Entity/RecurringTask.php
Normal file
210
Entity/RecurringTask.php
Normal file
@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* RecurringTask
|
||||
*
|
||||
* @ORM\Table(name="chill_task.recurring_task")
|
||||
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\RecurringTaskRepository")
|
||||
*/
|
||||
class RecurringTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="first_occurence_end_date", type="date")
|
||||
*/
|
||||
private $firstOccurenceEndDate;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="last_occurence_end_date", type="date")
|
||||
*/
|
||||
private $lastOccurenceEndDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="occurence_frequency", type="string", length=255)
|
||||
*/
|
||||
private $occurenceFrequency;
|
||||
|
||||
/**
|
||||
* @var dateinterval
|
||||
*
|
||||
* @ORM\Column(name="occurence_start_date", type="dateinterval")
|
||||
*/
|
||||
private $occurenceStartDate;
|
||||
|
||||
/**
|
||||
* @var dateinterval
|
||||
*
|
||||
* @ORM\Column(name="occurence_warning_interval", type="dateinterval", nullable=true)
|
||||
*/
|
||||
private $occurenceWarningInterval;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Collection
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="SingleTask",
|
||||
* mappedBy="recurringTask"
|
||||
* )
|
||||
*/
|
||||
private $singleTasks;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->singleTasks = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set firstOccurenceEndDate
|
||||
*
|
||||
* @param \DateTime $firstOccurenceEndDate
|
||||
*
|
||||
* @return RecurringTask
|
||||
*/
|
||||
public function setFirstOccurenceEndDate($firstOccurenceEndDate)
|
||||
{
|
||||
$this->firstOccurenceEndDate = $firstOccurenceEndDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get firstOccurenceEndDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getFirstOccurenceEndDate()
|
||||
{
|
||||
return $this->firstOccurenceEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set lastOccurenceEndDate
|
||||
*
|
||||
* @param \DateTime $lastOccurenceEndDate
|
||||
*
|
||||
* @return RecurringTask
|
||||
*/
|
||||
public function setLastOccurenceEndDate($lastOccurenceEndDate)
|
||||
{
|
||||
$this->lastOccurenceEndDate = $lastOccurenceEndDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastOccurenceEndDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getLastOccurenceEndDate()
|
||||
{
|
||||
return $this->lastOccurenceEndDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set occurenceFrequency
|
||||
*
|
||||
* @param string $occurenceFrequency
|
||||
*
|
||||
* @return RecurringTask
|
||||
*/
|
||||
public function setOccurenceFrequency($occurenceFrequency)
|
||||
{
|
||||
$this->occurenceFrequency = $occurenceFrequency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get occurenceFrequency
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOccurenceFrequency()
|
||||
{
|
||||
return $this->occurenceFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set occurenceStartDate
|
||||
*
|
||||
* @param dateinterval $occurenceStartDate
|
||||
*
|
||||
* @return RecurringTask
|
||||
*/
|
||||
public function setOccurenceStartDate($occurenceStartDate)
|
||||
{
|
||||
$this->occurenceStartDate = $occurenceStartDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get occurenceStartDate
|
||||
*
|
||||
* @return dateinterval
|
||||
*/
|
||||
public function getOccurenceStartDate()
|
||||
{
|
||||
return $this->occurenceStartDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set occurenceWarningInterval
|
||||
*
|
||||
* @param dateinterval $occurenceWarningInterval
|
||||
*
|
||||
* @return RecurringTask
|
||||
*/
|
||||
public function setOccurenceWarningInterval($occurenceWarningInterval)
|
||||
{
|
||||
$this->occurenceWarningInterval = $occurenceWarningInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get occurenceWarningInterval
|
||||
*
|
||||
* @return dateinterval
|
||||
*/
|
||||
public function getOccurenceWarningInterval()
|
||||
{
|
||||
return $this->occurenceWarningInterval;
|
||||
}
|
||||
}
|
||||
|
138
Entity/SingleTask.php
Normal file
138
Entity/SingleTask.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* SingleTask
|
||||
*
|
||||
* @ORM\Table("chill_task.single_task")
|
||||
* @ORM\Entity(repositoryClass="Chill\TaskBundle\Repository\SingleTaskRepository")
|
||||
*/
|
||||
class SingleTask extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="start_date", type="date", nullable=true)
|
||||
*/
|
||||
private $startDate;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="end_date", type="date", nullable=true)
|
||||
*/
|
||||
private $endDate;
|
||||
|
||||
/**
|
||||
* @var \DateInterval
|
||||
*
|
||||
* @ORM\Column(name="warning_interval", type="dateinterval", nullable=true)
|
||||
*/
|
||||
private $warningInterval;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var RecurringTask
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="RecurringTask",
|
||||
* inversedBy="singleTasks"
|
||||
* )
|
||||
*/
|
||||
private $recurringTask;
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set startDate
|
||||
*
|
||||
* @param \DateTime $startDate
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
public function setStartDate($startDate)
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get startDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getStartDate()
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set endDate
|
||||
*
|
||||
* @param \DateTime $endDate
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
public function setEndDate($endDate)
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get endDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getEndDate()
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set warningInterval
|
||||
*
|
||||
* @param string $warningInterval
|
||||
*
|
||||
* @return SingleTask
|
||||
*/
|
||||
public function setWarningInterval($warningInterval)
|
||||
{
|
||||
$this->warningInterval = $warningInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get warningInterval
|
||||
*
|
||||
* @return \DateInterval
|
||||
*/
|
||||
public function getWarningInterval(): ?\DateInterval
|
||||
{
|
||||
return $this->warningInterval;
|
||||
}
|
||||
}
|
||||
|
13
Repository/AbstractTaskRepository.php
Normal file
13
Repository/AbstractTaskRepository.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Repository;
|
||||
|
||||
/**
|
||||
* AbstractTaskRepository
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
abstract class AbstractTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
{
|
||||
}
|
13
Repository/RecurringTaskRepository.php
Normal file
13
Repository/RecurringTaskRepository.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Repository;
|
||||
|
||||
/**
|
||||
* RecurringTaskRepository
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class RecurringTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
{
|
||||
}
|
13
Repository/SingleTaskRepository.php
Normal file
13
Repository/SingleTaskRepository.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Repository;
|
||||
|
||||
/**
|
||||
* SingleTaskRepository
|
||||
*
|
||||
* This class was generated by the Doctrine ORM. Add your own custom
|
||||
* repository methods below.
|
||||
*/
|
||||
class SingleTaskRepository extends \Doctrine\ORM\EntityRepository
|
||||
{
|
||||
}
|
1
Resources/config/routing.yml
Normal file
1
Resources/config/routing.yml
Normal file
@ -0,0 +1 @@
|
||||
|
43
Resources/migrations/Version20180413135614.php
Normal file
43
Resources/migrations/Version20180413135614.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Create a table for Single task.
|
||||
*/
|
||||
class Version20180413135614 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SCHEMA chill_task');
|
||||
$this->addSql('CREATE SEQUENCE chill_task.single_task_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_task.single_task (id INT NOT NULL, assignee_id INT DEFAULT NULL, person_id INT DEFAULT NULL, circle_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, current_states JSONB NOT NULL, title TEXT NOT NULL, description TEXT NOT NULL, start_date DATE DEFAULT NULL, end_date DATE DEFAULT NULL, warning_interval INTERVAL DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_194CB3D859EC7D60 ON chill_task.single_task (assignee_id)');
|
||||
$this->addSql('CREATE INDEX IDX_194CB3D8217BBB47 ON chill_task.single_task (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_194CB3D870EE2FF6 ON chill_task.single_task (circle_id)');
|
||||
$this->addSql('COMMENT ON COLUMN chill_task.single_task.warning_interval IS \'(DC2Type:dateinterval)\'');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D859EC7D60 FOREIGN KEY (assignee_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D8217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D870EE2FF6 FOREIGN KEY (circle_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('DROP SCHEMA chill_task CASCADE');
|
||||
|
||||
}
|
||||
}
|
49
Resources/migrations/Version20180413201023.php
Normal file
49
Resources/migrations/Version20180413201023.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Create recurring task
|
||||
*/
|
||||
class Version20180413201023 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('CREATE SEQUENCE chill_task.recurring_task_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_task.recurring_task (id INT NOT NULL, assignee_id INT DEFAULT NULL, person_id INT DEFAULT NULL, circle_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, current_states JSONB NOT NULL, title TEXT NOT NULL, description TEXT NOT NULL, first_occurence_end_date DATE NOT NULL, last_occurence_end_date DATE NOT NULL, occurence_frequency VARCHAR(255) NOT NULL, occurence_start_date INTERVAL NOT NULL, occurence_warning_interval INTERVAL DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_9F663B9059EC7D60 ON chill_task.recurring_task (assignee_id)');
|
||||
$this->addSql('CREATE INDEX IDX_9F663B90217BBB47 ON chill_task.recurring_task (person_id)');
|
||||
$this->addSql('CREATE INDEX IDX_9F663B9070EE2FF6 ON chill_task.recurring_task (circle_id)');
|
||||
$this->addSql('COMMENT ON COLUMN chill_task.recurring_task.occurence_start_date IS \'(DC2Type:dateinterval)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_task.recurring_task.occurence_warning_interval IS \'(DC2Type:dateinterval)\'');
|
||||
$this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B9059EC7D60 FOREIGN KEY (assignee_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B90217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_task.recurring_task ADD CONSTRAINT FK_9F663B9070EE2FF6 FOREIGN KEY (circle_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task ADD recurringTask_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task ADD CONSTRAINT FK_194CB3D840868C31 FOREIGN KEY (recurringTask_id) REFERENCES chill_task.recurring_task (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_194CB3D840868C31 ON chill_task.single_task (recurringTask_id)');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_task.single_task DROP CONSTRAINT FK_194CB3D840868C31');
|
||||
$this->addSql('DROP SEQUENCE chill_task.recurring_task_id_seq CASCADE');
|
||||
|
||||
$this->addSql('DROP TABLE chill_task.recurring_task');
|
||||
$this->addSql('ALTER TABLE chill_task.single_task DROP recurringTask_id');
|
||||
}
|
||||
}
|
17
Tests/Controller/DefaultControllerTest.php
Normal file
17
Tests/Controller/DefaultControllerTest.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\TaskBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class DefaultControllerTest extends WebTestCase
|
||||
{
|
||||
public function testIndex()
|
||||
{
|
||||
$client = static::createClient();
|
||||
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
$this->assertContains('Hello World', $client->getResponse()->getContent());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user