More task fixes and implementation

This commit is contained in:
Dennis Eichhorn 2016-05-07 22:59:36 +02:00
parent 482d6166cd
commit 70170f0691
10 changed files with 188 additions and 86 deletions

View File

@ -379,14 +379,14 @@ class Repository
/** /**
* Get active Branch. * Get active Branch.
* *
* @return string * @return Branch
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getActiveBranch() : string public function getActiveBranch() : Branch
{ {
if (!isset($branch)) { if (!isset($this->branch)) {
$branches = $this->getBranches(); $branches = $this->getBranches();
$active = preg_grep('/^\*/', $branches); $active = preg_grep('/^\*/', $branches);
reset($active); reset($active);

View File

@ -19,7 +19,7 @@ namespace phpOMS\Utils\TaskSchedule;
* Array utils. * Array utils.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -64,4 +64,9 @@ class Cron implements ScheduleInterface
{ {
} }
public function run(string $cmd)
{
// TODO: Implement run() method.
}
} }

View File

@ -19,39 +19,25 @@ namespace phpOMS\Utils\TaskSchedule;
* Array utils. * Array utils.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
* @link http://orange-management.com * @link http://orange-management.com
* @since 1.0.0 * @since 1.0.0
*/ */
class CronJob implements TaskInterface class CronJob extends TaskAbstract
{ {
/**
* Interval.
*
* @var Interval
* @since 1.0.0
*/
private $interval = null;
private $command = '';
public function __construct(Interval $interval = null, $cmd = '') public function __construct(Interval $interval = null, $cmd = '')
{ {
$this->interval = $interval; if (!isset($interval)) {
$this->command = $cmd; $this->interval = new Interval();
} } else {
$this->interval = $interval;
}
public function setInterval(Interval $interval) $this->command = $cmd;
{
$this->interval = $interval;
}
public function setCommand(string $command)
{
$this->command = $command;
} }
public function __toString() public function __toString()

View File

@ -16,10 +16,10 @@
namespace phpOMS\Utils\TaskSchedule; namespace phpOMS\Utils\TaskSchedule;
/** /**
* Array utils. * Interval class for tasks.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -29,8 +29,20 @@ namespace phpOMS\Utils\TaskSchedule;
class Interval class Interval
{ {
/**
* Start.
*
* @var \DateTime
* @since 1.0.0
*/
private $start = null; private $start = null;
/**
* End.
*
* @var \DateTime
* @since 1.0.0
*/
private $end = null; private $end = null;
/** /**
@ -208,21 +220,57 @@ class Interval
} }
/**
* Set start.
*
* @param \DateTime $start Start date
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setStart(\DateTime $start) public function setStart(\DateTime $start)
{ {
$this->start = $start; $this->start = $start;
} }
/**
* Get start.
*
* @return \DateTime
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getStart() : \DateTime public function getStart() : \DateTime
{ {
return $this->start; return $this->start;
} }
/**
* Get end.
*
* @return \DateTime
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getEnd() public function getEnd()
{ {
return $this->end; return $this->end;
} }
/**
* Set end.
*
* @param \DateTime $end End date
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setEnd(\DateTime $end) public function setEnd(\DateTime $end)
{ {
$this->end = $end; $this->end = $end;

View File

@ -21,7 +21,7 @@ namespace phpOMS\Utils\TaskSchedule;
* Performing operations on the file system * Performing operations on the file system
* *
* @category System * @category System
* @package Framework * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0

View File

@ -19,38 +19,26 @@ namespace phpOMS\Utils\TaskSchedule;
* Array utils. * Array utils.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
* @link http://orange-management.com * @link http://orange-management.com
* @since 1.0.0 * @since 1.0.0
*/ */
class Schedule implements TaskInterface class Schedule extends TaskAbstract
{ {
private $name = '';
/**
* Interval.
*
* @var Interval
* @since 1.0.0
*/
private $interval = null;
private $command = '';
public function __construct(Interval $interval = null, $cmd = '') public function __construct(Interval $interval = null, $cmd = '')
{ {
if (!isset($interval)) {
$this->interval = new Interval();
} else {
$this->interval = $interval;
}
} $this->command = $cmd;
public function setInterval(Interval $interval)
{
$this->interval = $interval;
}
public function setCommand(string $command)
{
$this->command = $command;
} }
public function __toString() public function __toString()

View File

@ -19,7 +19,7 @@ namespace phpOMS\Utils\TaskSchedule;
* Array utils. * Array utils.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -39,4 +39,6 @@ interface ScheduleInterface
public function set(TaskInterface $task); public function set(TaskInterface $task);
public function save(); public function save();
public function run(string $cmd);
} }

View File

@ -0,0 +1,102 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Utils\TaskSchedule;
/**
* Abstract task class.
*
* @category Framework
* @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
abstract class TaskAbstract
{
/**
* Interval.
*
* @var Interval
* @since 1.0.0
*/
protected $interval = null;
/**
* Command.
*
* @var string
* @since 1.0.0
*/
protected $command = '';
/**
* Set interval.
*
* @param Interval $interval Interval
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setInterval(Interval $interval)
{
$this->interval = $interval;
}
/**
* Get interval.
*
* @return Interval
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getInterval() : Interval
{
return $this->interval;
}
/**
* Set command.
*
* @param string $command Command
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setCommand(string $command)
{
$this->command = $command;
}
/**
* Get command.
*
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getCommand() : string
{
return $this->command;
}
}

View File

@ -1,34 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Utils\TaskSchedule;
/**
* Array utils.
*
* @category Framework
* @package Utils
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
interface TaskInterface
{
public function setInterval(Interval $interval);
public function setCommand(string $command);
}

View File

@ -19,7 +19,7 @@ namespace phpOMS\Utils\TaskSchedule;
* Array utils. * Array utils.
* *
* @category Framework * @category Framework
* @package Utils * @package phpOMS\Utils\TaskSchedule
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -62,4 +62,9 @@ class TaskScheduler implements ScheduleInterface
{ {
} }
public function run(string $cmd)
{
// TODO: Implement run() method.
}
} }