mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-14 23:48:40 +00:00
Fixing remaining static bugs
This commit is contained in:
parent
f18d9e953a
commit
5a854ce1c9
|
|
@ -55,7 +55,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function update($obj);
|
public static function update($obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save data.
|
* Save data.
|
||||||
|
|
@ -65,7 +65,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function save();
|
public static function save();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete data.
|
* Delete data.
|
||||||
|
|
@ -75,7 +75,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function delete();
|
public static function delete();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find data.
|
* Find data.
|
||||||
|
|
@ -99,7 +99,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function listResults(Builder $query);
|
public static function listResults(Builder $query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate data.
|
* Populate data.
|
||||||
|
|
@ -111,7 +111,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function populate(array $result);
|
public static function populate(array $result);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate data.
|
* Populate data.
|
||||||
|
|
@ -123,7 +123,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function populateIterable(array $result) : array;
|
public static function populateIterable(array $result) : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load.
|
* Load.
|
||||||
|
|
@ -135,7 +135,7 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function with(...$objects);
|
public static function with(...$objects);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object.
|
* Get object.
|
||||||
|
|
@ -147,6 +147,6 @@ interface DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function get($primaryKey);
|
public static function get($primaryKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,8 @@ use phpOMS\DataStorage\DataMapperInterface;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class DataMapperAbstract //implements DataMapperInterface
|
class DataMapperAbstract implements DataMapperInterface
|
||||||
{
|
{
|
||||||
protected static $CLASS = __CLASS__;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database connection.
|
* Database connection.
|
||||||
*
|
*
|
||||||
|
|
@ -163,7 +161,9 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
private function __construct() {}
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone.
|
* Clone.
|
||||||
|
|
@ -171,7 +171,9 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
private function __clone() {}
|
private function __clone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set database connection.
|
* Set database connection.
|
||||||
|
|
@ -280,19 +282,19 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
|
|
||||||
public static function clear()
|
public static function clear()
|
||||||
{
|
{
|
||||||
self::$overwrite = true;
|
self::$overwrite = true;
|
||||||
self::$primaryField = '';
|
self::$primaryField = '';
|
||||||
self::$createdAt = '';
|
self::$createdAt = '';
|
||||||
self::$columns = [];
|
self::$columns = [];
|
||||||
self::$hasMany = [];
|
self::$hasMany = [];
|
||||||
self::$ownsMany = [];
|
self::$ownsMany = [];
|
||||||
self::$hasOne = [];
|
self::$hasOne = [];
|
||||||
self::$isExtending = [];
|
self::$isExtending = [];
|
||||||
self::$extends = [];
|
self::$extends = [];
|
||||||
self::$ownsOne = [];
|
self::$ownsOne = [];
|
||||||
self::$table = '';
|
self::$table = '';
|
||||||
self::$fields = [];
|
self::$fields = [];
|
||||||
self::$collection = [
|
self::$collection = [
|
||||||
'primaryField' => [],
|
'primaryField' => [],
|
||||||
'createdAt' => [],
|
'createdAt' => [],
|
||||||
'columns' => [],
|
'columns' => [],
|
||||||
|
|
@ -332,7 +334,7 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
* Create object in db.
|
* Create object in db.
|
||||||
*
|
*
|
||||||
* @param mixed $obj Object reference (gets filled with insert id)
|
* @param mixed $obj Object reference (gets filled with insert id)
|
||||||
* @param bool $relations Create all relations as well
|
* @param int $relations Create all relations as well
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
|
|
@ -341,7 +343,7 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function create($obj, bool $relations = true)
|
public static function create($obj, int $relations = RelationType::ALL)
|
||||||
{
|
{
|
||||||
self::extend(__CLASS__);
|
self::extend(__CLASS__);
|
||||||
|
|
||||||
|
|
@ -421,7 +423,7 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
$objId = self::$db->con->lastInsertId();
|
$objId = self::$db->con->lastInsertId();
|
||||||
|
|
||||||
// handle relations
|
// handle relations
|
||||||
if ($relations) {
|
if ($relations === RelationType::ALL) {
|
||||||
foreach (static::$hasMany as $member => $rel) {
|
foreach (static::$hasMany as $member => $rel) {
|
||||||
/* is a has many property */
|
/* is a has many property */
|
||||||
$property = $reflectionClass->getProperty($member); // throws ReflectionException
|
$property = $reflectionClass->getProperty($member); // throws ReflectionException
|
||||||
|
|
@ -664,7 +666,7 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
|
|
||||||
foreach ($result as $member => $values) {
|
foreach ($result as $member => $values) {
|
||||||
if ($reflectionClass->hasProperty($member)) {
|
if ($reflectionClass->hasProperty($member)) {
|
||||||
$mapper = static::$hasMany[$member]['mapper'];
|
$mapper = static::$hasMany[$member]['mapper'];
|
||||||
$reflectionProperty = $reflectionClass->getProperty($member);
|
$reflectionProperty = $reflectionClass->getProperty($member);
|
||||||
|
|
||||||
if (!($accessible = $reflectionProperty->isPublic())) {
|
if (!($accessible = $reflectionProperty->isPublic())) {
|
||||||
|
|
@ -899,14 +901,14 @@ class DataMapperAbstract //implements DataMapperInterface
|
||||||
* Get all by custom query.
|
* Get all by custom query.
|
||||||
*
|
*
|
||||||
* @param Builder $query Query
|
* @param Builder $query Query
|
||||||
* @param bool $relations Relations
|
* @param int $relations Relations
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function getAllByQuery(Builder $query, bool $relations = true) : array
|
public static function getAllByQuery(Builder $query, int $relations = RelationType::ALL) : array
|
||||||
{
|
{
|
||||||
$sth = self::$db->con->prepare($query->toSql());
|
$sth = self::$db->con->prepare($query->toSql());
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user