update 2023-08-01 07:50:04
This commit is contained in:
parent
861f56ba6d
commit
368dc3a410
@ -15,9 +15,11 @@ abstract Watcher #Orange {
|
|||||||
# Insert $insert
|
# Insert $insert
|
||||||
# Update $update
|
# Update $update
|
||||||
# bool $fresh
|
# bool $fresh
|
||||||
|
# bool $force
|
||||||
# ?object $target
|
# ?object $target
|
||||||
# string $table
|
# string $table
|
||||||
+ __construct(Load $load, Insert $insert, ...)
|
+ __construct(Load $load, Insert $insert, ...)
|
||||||
|
+ forceUpdate() : void
|
||||||
+ isNew() : bool
|
+ isNew() : bool
|
||||||
# hold() : bool
|
# hold() : bool
|
||||||
# bump() : bool
|
# bump() : bool
|
||||||
@ -35,6 +37,13 @@ note right of Watcher::__construct
|
|||||||
Update $update
|
Update $update
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of Watcher::forceUpdate
|
||||||
|
The switch to force a local update
|
||||||
|
|
||||||
|
since: 2.0.1
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
note right of Watcher::isNew
|
note right of Watcher::isNew
|
||||||
The see if new target is newly installed
|
The see if new target is newly installed
|
||||||
|
|
||||||
|
@ -57,6 +57,14 @@ abstract class Watcher
|
|||||||
*/
|
*/
|
||||||
protected bool $fresh = false;
|
protected bool $fresh = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The force update
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
protected bool $force = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target
|
* The target
|
||||||
*
|
*
|
||||||
@ -95,6 +103,17 @@ abstract class Watcher
|
|||||||
$this->today = (new Date())->toSql();
|
$this->today = (new Date())->toSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The switch to force a local update
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
public function forceUpdate(): void
|
||||||
|
{
|
||||||
|
$this->force = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The see if new target is newly installed
|
* The see if new target is newly installed
|
||||||
*
|
*
|
||||||
@ -114,6 +133,12 @@ abstract class Watcher
|
|||||||
*/
|
*/
|
||||||
protected function hold(): bool
|
protected function hold(): bool
|
||||||
{
|
{
|
||||||
|
// if we are being forced
|
||||||
|
if ($this->force)
|
||||||
|
{
|
||||||
|
return false; // we no longer hold, but force an update
|
||||||
|
}
|
||||||
|
|
||||||
// Create DateTime objects from the strings
|
// Create DateTime objects from the strings
|
||||||
try {
|
try {
|
||||||
$today = new \DateTime($this->today);
|
$today = new \DateTime($this->today);
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
*/
|
*/
|
||||||
protected bool $fresh = false;
|
protected bool $fresh = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The force update
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
protected bool $force = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target
|
* The target
|
||||||
*
|
*
|
||||||
@ -68,6 +76,17 @@
|
|||||||
$this->today = (new Date())->toSql();
|
$this->today = (new Date())->toSql();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The switch to force a local update
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
public function forceUpdate(): void
|
||||||
|
{
|
||||||
|
$this->force = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The see if new target is newly installed
|
* The see if new target is newly installed
|
||||||
*
|
*
|
||||||
@ -87,6 +106,12 @@
|
|||||||
*/
|
*/
|
||||||
protected function hold(): bool
|
protected function hold(): bool
|
||||||
{
|
{
|
||||||
|
// if we are being forced
|
||||||
|
if ($this->force)
|
||||||
|
{
|
||||||
|
return false; // we no longer hold, but force an update
|
||||||
|
}
|
||||||
|
|
||||||
// Create DateTime objects from the strings
|
// Create DateTime objects from the strings
|
||||||
try {
|
try {
|
||||||
$today = new \DateTime($this->today);
|
$today = new \DateTime($this->today);
|
||||||
|
@ -26,6 +26,7 @@ class Watcher << (F,LightGreen) >> #Green {
|
|||||||
+ getLastChapter(string $translation, int $book) : ?int
|
+ getLastChapter(string $translation, int $book) : ?int
|
||||||
+ getNextBook(string $translation, int $book, ...) : ?int
|
+ getNextBook(string $translation, int $book, ...) : ?int
|
||||||
+ getPreviousBook(string $translation, int $book, ...) : ?int
|
+ getPreviousBook(string $translation, int $book, ...) : ?int
|
||||||
|
- forceUpdate(bool $state) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Watcher::__construct
|
note right of Watcher::__construct
|
||||||
@ -50,6 +51,7 @@ note left of Watcher::sync
|
|||||||
string $translation
|
string $translation
|
||||||
int $book
|
int $book
|
||||||
int $chapter
|
int $chapter
|
||||||
|
bool $force = false
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Watcher::isNew
|
note right of Watcher::isNew
|
||||||
@ -123,6 +125,13 @@ note left of Watcher::getPreviousBook
|
|||||||
int $book
|
int $book
|
||||||
int $try
|
int $try
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of Watcher::forceUpdate
|
||||||
|
The method to set the update state
|
||||||
|
|
||||||
|
since: 2.0.1
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
@ -93,12 +93,16 @@ final class Watcher
|
|||||||
* @param string $translation The translation.
|
* @param string $translation The translation.
|
||||||
* @param int $book The book number.
|
* @param int $book The book number.
|
||||||
* @param int $chapter The chapter number.
|
* @param int $chapter The chapter number.
|
||||||
|
* @param bool $force The switch to force an update.
|
||||||
*
|
*
|
||||||
* @return bool True on success
|
* @return bool True on success
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
*/
|
*/
|
||||||
public function sync(string $translation, int $book, int $chapter): bool
|
public function sync(string $translation, int $book, int $chapter, bool $force = false): bool
|
||||||
{
|
{
|
||||||
|
// set the update state
|
||||||
|
$this->forceUpdate($force);
|
||||||
|
|
||||||
// is the translation details in sync
|
// is the translation details in sync
|
||||||
if (!$this->translation->sync($translation))
|
if (!$this->translation->sync($translation))
|
||||||
{
|
{
|
||||||
@ -315,6 +319,25 @@ final class Watcher
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPreviousBook($translation, $previous, $try);
|
return $this->getPreviousBook($translation, $previous, $try);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method to set the update state
|
||||||
|
*
|
||||||
|
* @param bool $state The switch to force an update.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
private function forceUpdate(bool $state): void
|
||||||
|
{
|
||||||
|
// force all updates
|
||||||
|
if ($state)
|
||||||
|
{
|
||||||
|
$this->translation->forceUpdate();
|
||||||
|
$this->book->forceUpdate();
|
||||||
|
$this->chapter->forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +66,16 @@
|
|||||||
* @param string $translation The translation.
|
* @param string $translation The translation.
|
||||||
* @param int $book The book number.
|
* @param int $book The book number.
|
||||||
* @param int $chapter The chapter number.
|
* @param int $chapter The chapter number.
|
||||||
|
* @param bool $force The switch to force an update.
|
||||||
*
|
*
|
||||||
* @return bool True on success
|
* @return bool True on success
|
||||||
* @since 2.0.1
|
* @since 2.0.1
|
||||||
*/
|
*/
|
||||||
public function sync(string $translation, int $book, int $chapter): bool
|
public function sync(string $translation, int $book, int $chapter, bool $force = false): bool
|
||||||
{
|
{
|
||||||
|
// set the update state
|
||||||
|
$this->forceUpdate($force);
|
||||||
|
|
||||||
// is the translation details in sync
|
// is the translation details in sync
|
||||||
if (!$this->translation->sync($translation))
|
if (!$this->translation->sync($translation))
|
||||||
{
|
{
|
||||||
@ -288,4 +292,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->getPreviousBook($translation, $previous, $try);
|
return $this->getPreviousBook($translation, $previous, $try);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The method to set the update state
|
||||||
|
*
|
||||||
|
* @param bool $state The switch to force an update.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 2.0.1
|
||||||
|
*/
|
||||||
|
private function forceUpdate(bool $state): void
|
||||||
|
{
|
||||||
|
// force all updates
|
||||||
|
if ($state)
|
||||||
|
{
|
||||||
|
$this->translation->forceUpdate();
|
||||||
|
$this->book->forceUpdate();
|
||||||
|
$this->chapter->forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user