Skip to content

Commit 4541089

Browse files
wachterjohannesalexander-schranz
authored andcommitted
Implemented system-tasks (#38)
* implemented system-tasks * changed remove execution to abort execution * added upgrade * fixed doctrine tests * added remove system-task * added output * fixed testsetup * changed php-task dependency
1 parent a5a7535 commit 4541089

25 files changed

+969
-37
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ before_script:
3838
- STORAGE=doctrine tests/app/console doctrine:schema:create
3939

4040
script:
41-
- phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
41+
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
4242

4343
after_script:
4444
- if [[ $CODE_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi

UPGRADE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
UPGRADE
22
=======
33

4+
- [1.1.0](#1.1.0)
45
- [0.4.0](#0.4.0)
56

7+
### 1.1.0
8+
9+
In the database table `ta_tasks` a new field was introduced. Run following
10+
command to update the table.
11+
12+
```bash
13+
bin/console doctrine:schema:update
14+
```
15+
616
### 0.4.0
717

818
#### Identifier of tasks and executions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": "~5.5 || ~7.0",
14-
"php-task/php-task": "^1.0",
14+
"php-task/php-task": "dev-develop",
1515
"symfony/http-kernel": "^2.6 || ^3.0",
1616
"symfony/dependency-injection": "^2.6 || ^3.0",
1717
"symfony/config": "^2.6 || ^3.0",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-task library.
5+
*
6+
* (c) php-task
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Task\TaskBundle\Builder;
13+
14+
use Task\TaskInterface;
15+
16+
/**
17+
* Indicates not supported method.
18+
*/
19+
class NotSupportedMethodException extends \Exception
20+
{
21+
/**
22+
* @var string
23+
*/
24+
private $property;
25+
26+
/**
27+
* @var TaskInterface
28+
*/
29+
private $task;
30+
31+
/**
32+
* @param string $property
33+
* @param TaskInterface $task
34+
*/
35+
public function __construct($property, TaskInterface $task)
36+
{
37+
parent::__construct(
38+
sprintf('Property "%s" is not supported for task-class "%s".', $property, get_class($task))
39+
);
40+
41+
$this->property = $property;
42+
$this->task = $task;
43+
}
44+
45+
/**
46+
* Returns property.
47+
*
48+
* @return string
49+
*/
50+
public function getProperty()
51+
{
52+
return $this->property;
53+
}
54+
55+
/**
56+
* Returns task.
57+
*
58+
* @return TaskInterface
59+
*/
60+
public function getTask()
61+
{
62+
return $this->task;
63+
}
64+
}

src/Builder/TaskBuilder.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-task library.
5+
*
6+
* (c) php-task
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Task\TaskBundle\Builder;
13+
14+
use Task\Builder\TaskBuilder as BaseTaskBuilder;
15+
use Task\Builder\TaskBuilderInterface;
16+
use Task\TaskBundle\Entity\Task;
17+
18+
/**
19+
* Extends base task-builder.
20+
*/
21+
class TaskBuilder extends BaseTaskBuilder
22+
{
23+
/**
24+
* Set system-key.
25+
*
26+
* @param string $systemKey
27+
*
28+
* @return TaskBuilderInterface
29+
*
30+
* @throws NotSupportedMethodException
31+
*/
32+
public function setSystemKey($systemKey)
33+
{
34+
if (!$this->task instanceof Task) {
35+
throw new NotSupportedMethodException('systemKey', $this->task);
36+
}
37+
38+
$this->task->setSystemKey($systemKey);
39+
40+
return $this;
41+
}
42+
}

src/Builder/TaskBuilderFactory.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of php-task library.
5+
*
6+
* (c) php-task
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Task\TaskBundle\Builder;
13+
14+
use Task\Builder\TaskBuilderFactoryInterface;
15+
use Task\Scheduler\TaskSchedulerInterface;
16+
use Task\TaskInterface;
17+
18+
/**
19+
* Factory to create new task-builders.
20+
*/
21+
class TaskBuilderFactory implements TaskBuilderFactoryInterface
22+
{
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function createTaskBuilder(TaskInterface $task, TaskSchedulerInterface $taskScheduler)
27+
{
28+
return new TaskBuilder($task, $taskScheduler);
29+
}
30+
}

0 commit comments

Comments
 (0)