commit 7a85e00c1655b9bd9c5e06520608a3d5af756b45 Author: Julien Fastré Date: Fri Apr 13 22:16:40 2018 +0200 initial commit diff --git a/ChillTaskBundle.php b/ChillTaskBundle.php new file mode 100644 index 000000000..6155882cd --- /dev/null +++ b/ChillTaskBundle.php @@ -0,0 +1,29 @@ + + * + * 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 . + */ +namespace Chill\TaskBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +/** + * + * + */ +class ChillTaskBundle extends Bundle +{ + +} diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php new file mode 100644 index 000000000..74b3aa34e --- /dev/null +++ b/Controller/DefaultController.php @@ -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'); + } +} diff --git a/DependencyInjection/ChillTaskExtension.php b/DependencyInjection/ChillTaskExtension.php new file mode 100644 index 000000000..0a933e247 --- /dev/null +++ b/DependencyInjection/ChillTaskExtension.php @@ -0,0 +1,28 @@ +processConfiguration($configuration, $configs); + + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + //$loader->load('services.yml'); + } +} diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php new file mode 100644 index 000000000..e0989cd69 --- /dev/null +++ b/DependencyInjection/Configuration.php @@ -0,0 +1,29 @@ +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; + } +} diff --git a/Entity/AbstractTask.php b/Entity/AbstractTask.php new file mode 100644 index 000000000..3e65be165 --- /dev/null +++ b/Entity/AbstractTask.php @@ -0,0 +1,169 @@ +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; + } +} + diff --git a/Entity/RecurringTask.php b/Entity/RecurringTask.php new file mode 100644 index 000000000..20bffab18 --- /dev/null +++ b/Entity/RecurringTask.php @@ -0,0 +1,210 @@ +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; + } +} + diff --git a/Entity/SingleTask.php b/Entity/SingleTask.php new file mode 100644 index 000000000..81d987b5c --- /dev/null +++ b/Entity/SingleTask.php @@ -0,0 +1,138 @@ +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; + } +} + diff --git a/Repository/AbstractTaskRepository.php b/Repository/AbstractTaskRepository.php new file mode 100644 index 000000000..d5c7627c0 --- /dev/null +++ b/Repository/AbstractTaskRepository.php @@ -0,0 +1,13 @@ +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'); + + } +} diff --git a/Resources/migrations/Version20180413201023.php b/Resources/migrations/Version20180413201023.php new file mode 100644 index 000000000..f068fe0e2 --- /dev/null +++ b/Resources/migrations/Version20180413201023.php @@ -0,0 +1,49 @@ +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'); + } +} diff --git a/Tests/Controller/DefaultControllerTest.php b/Tests/Controller/DefaultControllerTest.php new file mode 100644 index 000000000..a370af892 --- /dev/null +++ b/Tests/Controller/DefaultControllerTest.php @@ -0,0 +1,17 @@ +request('GET', '/'); + + $this->assertContains('Hello World', $client->getResponse()->getContent()); + } +}