Skip to content

Commit

Permalink
Merge pull request #67 from baraja-core/master
Browse files Browse the repository at this point in the history
#62 #66 Nette 3 support + improvement internal code + codestyle
  • Loading branch information
northys authored Dec 25, 2021
2 parents ec2c161 + 4015409 commit a335b7a
Show file tree
Hide file tree
Showing 36 changed files with 714 additions and 723 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ It requires **PHP >= 7.1.0** and **Nette Framework >= 2.4.0**.
It is very simple to use it because configuration is only in method annotations. Example class with tasks follows.

```php
class CronTasks {
class CronTasks
{
/**
* @cronner-task E-mail sending
* @cronner-period 1 day
* @cronner-days working days
* @cronner-time 23:30 - 05:00
*/
public function sendEmails() {
public function sendEmails(): void
{
// Code which sends all your e-mails
}


/**
* @cronner-task Important data replication
* @cronner-period 3 hours
*/
public function replicateImportantData() {
public function replicateImportantData(): void
{
// Replication code
}
}
Expand All @@ -51,7 +55,7 @@ However you can specify service manually if it is not autowireable.

```neon
cronner:
timestampStorage: @myCoolTimestampStorage
timestampStorage: myCoolTimestampStorage
```

Or you can change the directory for default storage.
Expand All @@ -72,14 +76,17 @@ automatically. However you can still add new task objects by your own using `add
Then you can use it very easily in `Presenter`

```php
class CronPresenter extends \Nette\Application\UI\Presenter {
class CronPresenter extends \Nette\Application\UI\Presenter
{
/**
* @var \stekycz\Cronner\Cronner
* @inject
*/
public $cronner;

public function actionCron() {

public function actionCron(): void
{
$this->cronner->run();
}
}
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
},
"require": {
"php": ">=7.1.0",
"tracy/tracy": "^2.4",
"nette/di": "^2.4",
"nette/bootstrap": "^2.4",
"nette/utils": "^2.4",
"tracy/tracy": "^2.6",
"nette/di": "^3.0",
"nette/bootstrap": "^3.0",
"nette/utils": "^3.0",
"nette/reflection": "^2.4",
"nette/safe-stream": "^2.3",
"nette/safe-stream": "^2.4",
"bileto/critical-section": "^2.1"
},
"require-dev": {
"nette/tester": "^1.7",
"jakub-onderka/php-parallel-lint": "^0.9",
"jakub-onderka/php-parallel-lint": "^1.0",
"mockery/mockery": "^0.9",
"phpstan/phpstan": "^0.8"
"phpstan/phpstan": "^1.2"
},
"suggest": {
},
Expand Down
18 changes: 9 additions & 9 deletions src/Cronner/Bar/Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@

namespace stekycz\Cronner\Bar;


use stekycz\Cronner\Cronner;
use Tracy\IBarPanel;

class Tasks implements IBarPanel
final class Tasks implements IBarPanel
{
use \Nette\SmartObject;

/**
* @var Cronner
*/
protected $cronner;
/** @var Cronner */
private $cronner;


public function __construct(Cronner $cronner)
{
$this->cronner = $cronner;
}

public function getPanel() : string

public function getPanel(): string
{
$tasks = [];
foreach ($this->cronner->getTasks() as $task) {
Expand All @@ -37,13 +37,13 @@ public function getPanel() : string
return ob_get_clean();
}

public function getTab() : string

public function getTab(): string
{
ob_start();
$count = $this->cronner->countTasks();
require __DIR__ . '/templates/tab.phtml';

return ob_get_clean();
}

}
13 changes: 9 additions & 4 deletions src/Cronner/Bar/templates/panel.phtml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?php use stekycz\Cronner\Tasks\Parameters; ?>
<style class="tracy-debug">
#nette-cronner-table { width: 100%; }
#nette-cronner-table th { font-size: 15px !important; }
#nette-cronner-overflow { overflow-y: auto; max-height: 500px; min-width: 500px; }
#nette-cronner-table { width: 100% }
#nette-cronner-table th { font-size: 15px !important }
#nette-cronner-overflow { overflow-y: auto }
</style>
<div class="nette-cronner">
<h1>Cronner</h1>

<div id="nette-cronner-overflow">
<?php
if ($tasks === []) {
echo '<div style="text-align:center;padding:1em 0;color:#888">No tasks defined.</div>';
}
?>
<table class="nette-inner tracy-inner" id="nette-cronner-table">
<tbody>
<?php foreach ($tasks as $name => $task): ?>
Expand All @@ -31,4 +36,4 @@
</tbody>
</table>
</div>
</div>
</div>
Loading

0 comments on commit a335b7a

Please sign in to comment.