Skip to content

Implemented system-tasks #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ before_script:
- STORAGE=doctrine tests/app/console doctrine:schema:create

script:
- phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.clover

after_script:
- if [[ $CODE_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar ; fi
Expand Down
10 changes: 10 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
UPGRADE
=======

- [1.1.0](#1.1.0)
- [0.4.0](#0.4.0)

### 1.1.0

In the database table `ta_tasks` a new field was introduced. Run following
command to update the table.

```bash
bin/console doctrine:schema:update
```

### 0.4.0

#### Identifier of tasks and executions
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": "~5.5 || ~7.0",
"php-task/php-task": "^1.0",
"php-task/php-task": "dev-develop",
"symfony/http-kernel": "^2.6 || ^3.0",
"symfony/dependency-injection": "^2.6 || ^3.0",
"symfony/config": "^2.6 || ^3.0",
Expand Down
64 changes: 64 additions & 0 deletions src/Builder/NotSupportedMethodException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Task\TaskBundle\Builder;

use Task\TaskInterface;

/**
* Indicates not supported method.
*/
class NotSupportedMethodException extends \Exception
{
/**
* @var string
*/
private $property;

/**
* @var TaskInterface
*/
private $task;

/**
* @param string $property
* @param TaskInterface $task
*/
public function __construct($property, TaskInterface $task)
{
parent::__construct(
sprintf('Property "%s" is not supported for task-class "%s".', $property, get_class($task))
);

$this->property = $property;
$this->task = $task;
}

/**
* Returns property.
*
* @return string
*/
public function getProperty()
{
return $this->property;
}

/**
* Returns task.
*
* @return TaskInterface
*/
public function getTask()
{
return $this->task;
}
}
42 changes: 42 additions & 0 deletions src/Builder/TaskBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Task\TaskBundle\Builder;

use Task\Builder\TaskBuilder as BaseTaskBuilder;
use Task\Builder\TaskBuilderInterface;
use Task\TaskBundle\Entity\Task;

/**
* Extends base task-builder.
*/
class TaskBuilder extends BaseTaskBuilder
{
/**
* Set system-key.
*
* @param string $systemKey
*
* @return TaskBuilderInterface
*
* @throws NotSupportedMethodException
*/
public function setSystemKey($systemKey)
{
if (!$this->task instanceof Task) {
throw new NotSupportedMethodException('systemKey', $this->task);
}

$this->task->setSystemKey($systemKey);

return $this;
}
}
30 changes: 30 additions & 0 deletions src/Builder/TaskBuilderFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of php-task library.
*
* (c) php-task
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Task\TaskBundle\Builder;

use Task\Builder\TaskBuilderFactoryInterface;
use Task\Scheduler\TaskSchedulerInterface;
use Task\TaskInterface;

/**
* Factory to create new task-builders.
*/
class TaskBuilderFactory implements TaskBuilderFactoryInterface
{
/**
* {@inheritdoc}
*/
public function createTaskBuilder(TaskInterface $task, TaskSchedulerInterface $taskScheduler)
{
return new TaskBuilder($task, $taskScheduler);
}
}
Loading