Skip to content

Commit

Permalink
Merge pull request #11 from sulu/enhancement/sulu-update
Browse files Browse the repository at this point in the history
Updated sulu to 1.6
  • Loading branch information
danrot authored Jun 28, 2017
2 parents 80322f7 + 6057f9f commit 822575b
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 80 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ language: php
cache:
directories:
- $HOME/.composer/cache
- downloads

matrix:
include:
- php: 5.5
env:
- COMPOSER_FLAGS="--prefer-lowest --prefer-dist --no-interaction"
- php: 7.0
env:
- COMPOSER_FLAGS="--prefer-dist --no-interaction"

before_script:
- phpenv config-rm xdebug.ini
- composer self-update
- composer install --prefer-dist --no-interaction
- composer update $COMPOSER_FLAGS
- ./Tests/app/console doctrine:database:create
- ./Tests/app/console doctrine:schema:create

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Sulu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
96 changes: 24 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,40 @@
# SuluAutomationBundle

[![Build Status](https://travis-ci.org/sulu/SuluAutomationBundle.svg?branch=master)](https://travis-ci.org/sulu/SuluAutomationBundle)
[![Build Status](https://travis-ci.org/sulu/SuluAutomationBundle.svg)](https://travis-ci.org/sulu/SuluAutomationBundle)
[![StyleCI](https://styleci.io/repos/61883398/shield)](https://styleci.io/repos/61883398)

This bundle integrates the
[php-task library](https://github.com/php-task/php-task) into Sulu.
The SuluAutomationBundle provides a way to manages future tasks which can be scheduled for entities in the Sulu-Admin.
For example schedule the publishing of a page to a specific datetime in the future.

## Installation

### Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following
command to download the latest stable version of this bundle:

```console
$ composer require sulu/automation-bundle
```

This command requires you to have Composer installed globally, as explained in
the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the
Composer documentation.

### Step 2: Enabled the Bundle
To schedule tasks this bundle uses the [php-task library](https://github.com/php-task/php-task).

Then, enable the bundle by adding it to the list of registered bundles in the
`app/AbstractKernel.php` file of your Sulu project.
## Requirements

```php
<?php
// app/AbstractKernel.php
* Composer
* PHP `^5.5 || ^7.0`
* Sulu `^1.5`
* PHP-Task `^1.1`

// ...
abstract class AbstractKernel extends SuluKernel
{
public function registerBundles()
{
$bundles = [
// ...
new Task\TaskBundle\TaskBundle(),
new Sulu\Bundle\AutomationBundle\SuluAutomationBundle(),
];
}
}
```
For detailed requirements see [composer.json](https://github.com/sulu/SuluAutomationBundle/blob/master/composer.json).

### Step 3: Configure the routes
## Documentation

Then, add the required routes to the `app/config/admin/routing.yml` configuration file.
The Documentation is stored in the
[Resources/doc/](https://github.com/sulu/SuluAutomationBundle/blob/master/Resources/doc) folder.

```yaml
# ...
sulu_automation_api:
type: rest
resource: "@SuluAutomationBundle/Resources/config/routing_api.xml"
prefix: /admin/api

sulu_automation:
type: rest
resource: "@SuluAutomationBundle/Resources/config/routing.xml"
prefix: /admin/automation
```
### Step 4: Update the database schema
The bundle needs a few database tables, therefore you should update your schema
using doctrine migrations or the following command:
```console
bin/console doctrine:schema:update --force
```

### Step 5: Export the translations
## Installation

This bundle also includes a few translations, which must be exported:
All the installation instructions are located in the
[documentation](https://github.com/sulu/SuluAutomationBundle/blob/master/Resources/doc/installation.md).

```console
bin/console sulu:translate:export
```
## License

### Step 6: Configure a cronjob
This bundle is under the MIT license. See the complete license [in the bundle](LICENSE)

The php-task library requires a cronjob to run the scheduled tasks. The cronjob
should run the `task:run` command.
## Reporting an issue or a feature request

```console
bin/adminconsole task:run
```
Issues and feature requests are tracked in the [Github issue tracker](https://github.com/Sulu/SuluAutomationBundle/issues).

When reporting a bug, it may be a good idea to reproduce it in a basic project built using the
[Sulu Minimal Edition](https://github.com/sulu/sulu-minimal) to allow developers of the bundle to reproduce the issue
by simply cloning it and following some steps.
8 changes: 8 additions & 0 deletions Resources/doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Documentation of SuluAutomationBundle

This documentation covers basic-topics to install and use this bundle. For detailed information see also the
bundle-documentation in [docs.sulu.io](http://docs.sulu.io/en/1.6/bundles/automation/index.html).

## List of contents

* [Installation](installation.md)
Empty file removed Resources/doc/index.rst
Empty file.
80 changes: 80 additions & 0 deletions Resources/doc/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Installation

## Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following
command to download the latest stable version of this bundle:

```console
$ composer require sulu/automation-bundle
```

This command requires you to have Composer installed globally, as explained in
the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the
Composer documentation.

### Step 2: Enabled the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the
`app/AbstractKernel.php` file of your Sulu project.

```php
<?php
// app/AbstractKernel.php

// ...
abstract class AbstractKernel extends SuluKernel
{
public function registerBundles()
{
$bundles = [
// ...
new Task\TaskBundle\TaskBundle(),
new Sulu\Bundle\AutomationBundle\SuluAutomationBundle(),
];
}
}
```

## Step 3: Configure the routes

Then, add the required routes to the `app/config/admin/routing.yml` configuration file.

```yaml
# ...
sulu_automation_api:
type: rest
resource: "@SuluAutomationBundle/Resources/config/routing_api.xml"
prefix: /admin/api

sulu_automation:
type: rest
resource: "@SuluAutomationBundle/Resources/config/routing.xml"
prefix: /admin/automation
```
## Step 4: Update the database schema
The bundle needs a few database tables, therefore you should update your schema
using doctrine migrations or the following command:
```console
bin/console doctrine:schema:update --force
```

## Step 5: Export the translations

This bundle also includes a few translations, which must be exported:

```console
bin/console sulu:translate:export
```

## Step 6: Configure a cronjob

The php-task library requires a cronjob to run the scheduled tasks. The cronjob
should run the `task:run` command.

```console
bin/adminconsole task:run
```
6 changes: 4 additions & 2 deletions Tasks/Manager/TaskManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public function create(TaskInterface $task)
*/
public function update(TaskInterface $task)
{
$event = $this->eventDispatcher->dispatch(Events::TASK_UPDATE_EVENT, new TaskUpdateEvent($task));
$event = new TaskUpdateEvent($task);
$this->eventDispatcher->dispatch(Events::TASK_UPDATE_EVENT, $event);
$this->scheduler->reschedule($task);

if ($event->isCanceled()) {
Expand All @@ -106,7 +107,8 @@ public function remove($id)
$task = $this->findById($id);
$this->scheduler->remove($task);

$event = $this->eventDispatcher->dispatch(Events::TASK_REMOVE_EVENT, new TaskRemoveEvent($task));
$event = new TaskRemoveEvent($task);
$this->eventDispatcher->dispatch(Events::TASK_REMOVE_EVENT, $event);
if ($event->isCanceled()) {
return;
}
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
}
],
"require": {
"sulu/sulu": "1.5.* || dev-develop",
"sulu/sulu": "^1.5",
"php-task/task-bundle": "^1.0",
"willdurand/hateoas-bundle": "^1.2",
"jms/serializer-bundle": "^1.1",

"sulu/document-manager": "^0.9 || dev-develop"
"jms/serializer-bundle": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "~4.8 || ~5.0",
Expand Down

0 comments on commit 822575b

Please sign in to comment.