-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
581703c
commit 2b15ebd
Showing
2 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
/** | ||
* Class DocumentStoreOne | ||
* | ||
* @version 1.22.1 2022-03-12 | ||
* @version 1.23 2022-03-20 | ||
* @author Jorge Castro Castillo [email protected] | ||
* @link https://github.com/EFTEC/DocumentStoreOne | ||
* @license LGPLv3 or commercial | ||
|
@@ -85,6 +85,8 @@ class DocumentStoreOne | |
protected $autoSerialize; | ||
public $throwable = true; | ||
public $latestError = ''; | ||
/** @var DocumentStoreOne */ | ||
protected static $instance; | ||
/*protected $memcache;*/ | ||
/** | ||
* @var string= 'sequencephp' (snowfake generation),'nextsequence' (generated by a document) or the name of the | ||
|
@@ -144,7 +146,24 @@ public function __construct( | |
. $this->getPath() . | ||
'. You could create the collection with createCollection()'); | ||
} | ||
if (self::$instance === null) { | ||
self::$instance = $this; | ||
} | ||
} | ||
/** | ||
* It returns the first instance created DocumentStoreOne or throw an error if the instance is not set. | ||
* @param bool $throwIfNull if true and the instance is not set, then it throws an exception<br> | ||
* if false and the instance is not set, then it returns null | ||
* @return DocumentStoreOne|null | ||
*/ | ||
public static function instance(bool $throwIfNull = true): ?DocumentStoreOne | ||
{ | ||
if (self::$instance === null && $throwIfNull) { | ||
throw new RuntimeException('instance not created for DocumentStoreOne'); | ||
} | ||
return self::$instance; | ||
} | ||
|
||
|
||
public function isTabular(): bool | ||
{ | ||
|