mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Allow obj relations
This commit is contained in:
parent
3713e3fc11
commit
85b8bbec04
|
|
@ -678,7 +678,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function getObjectId(object $obj, \ReflectionClass $refClass = null)
|
||||
public static function getObjectId(object $obj, \ReflectionClass $refClass = null)
|
||||
{
|
||||
$refClass = $refClass ?? new \ReflectionClass($obj);
|
||||
$refProp = $refClass->getProperty(static::$columns[static::$primaryField]['internal']);
|
||||
|
|
@ -1007,7 +1007,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
* In case of a many to many relation the relation has to be stored in a relation table
|
||||
*
|
||||
* @param string $propertyName Property name to initialize
|
||||
* @param array $objsIds Object ids to insert
|
||||
* @param array $objsIds Object ids to insert (can also be the object itself)
|
||||
* @param mixed $objId Model to reference
|
||||
*
|
||||
* @return void
|
||||
|
|
@ -1024,6 +1024,11 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
->insert(static::$hasMany[$propertyName]['src'], static::$hasMany[$propertyName]['dst']);
|
||||
|
||||
foreach ($objsIds as $key => $src) {
|
||||
if (\is_object($src)) {
|
||||
$mapper = \get_class($src) . 'Mapper';
|
||||
$src = $mapper::getObjectId($src);
|
||||
}
|
||||
|
||||
$relQuery->values($src, $objId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ final class Request extends RequestAbstract
|
|||
\parse_str($content, $temp);
|
||||
$this->data += $temp;
|
||||
} elseif (\stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false) {
|
||||
$content = file_get_contents('php://input');
|
||||
$content = \file_get_contents('php://input');
|
||||
$stream = \fopen('php://input', 'r');
|
||||
$partInfo = null;
|
||||
$boundary = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user