fix
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Bx\Nullable\App;
|
namespace Bx\Nullable\App;
|
||||||
|
|
||||||
|
|
||||||
use Bx\Nullable\Facade\DefaultDefines;
|
use Bx\Nullable\Facade\DefaultDefines;
|
||||||
use Bx\Nullable\Facade\Defines;
|
use Bx\Nullable\Facade\Defines;
|
||||||
use Bx\Nullable\Facade\DefaultServiceFacade;
|
use Bx\Nullable\Facade\DefaultServiceFacade;
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Bx\Nullable\Factory;
|
namespace Bx\Nullable\Factory;
|
||||||
|
|
||||||
|
|
||||||
use Bx\Nullable\Collection\NullableCollection;
|
use Bx\Nullable\Collection\NullableCollection;
|
||||||
use Bx\Nullable\Entity\NullableEntity;
|
use Bx\Nullable\Entity\NullableEntity;
|
||||||
use Bx\Nullable\ORM\NullableTable;
|
use Bx\Nullable\ORM\NullableTable;
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Bx\Nullable\ORM;
|
namespace Bx\Nullable\ORM;
|
||||||
|
|
||||||
|
|
||||||
use Bitrix\Main\ORM\Fields\DatetimeField;
|
use Bitrix\Main\ORM\Fields\DatetimeField;
|
||||||
use Bitrix\Main\Type\DateTime;
|
use Bitrix\Main\Type\DateTime;
|
||||||
|
use Exception;
|
||||||
use Wt\Core\ORM\ADataManager;
|
use Wt\Core\ORM\ADataManager;
|
||||||
|
|
||||||
class NullableTable extends ADataManager
|
class NullableTable extends ADataManager
|
||||||
@@ -33,7 +32,7 @@ class NullableTable extends ADataManager
|
|||||||
|
|
||||||
public static function getMap()
|
public static function getMap()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'ID' => new \Bitrix\Main\Entity\IntegerField('ID', [
|
'ID' => new \Bitrix\Main\Entity\IntegerField('ID', [
|
||||||
'primary' => true,
|
'primary' => true,
|
||||||
'autocomplete' => true,
|
'autocomplete' => true,
|
||||||
@@ -47,39 +46,39 @@ class NullableTable extends ADataManager
|
|||||||
'title' => 'UpdatedAt',
|
'title' => 'UpdatedAt',
|
||||||
'user_edit' => false,
|
'user_edit' => false,
|
||||||
]),
|
]),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id
|
* @param $primary
|
||||||
* @param array $fields
|
* @param array $data
|
||||||
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
||||||
* @throws \Bitrix\Main\ObjectException
|
* @throws \Bitrix\Main\ObjectException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function update($id, array $fields)
|
public static function update($primary, array $data)
|
||||||
{
|
{
|
||||||
foreach (static::getEntity()->getFields() as $field){
|
foreach (static::getEntity()->getFields() as $field){
|
||||||
if(is_a($field, DatetimeField::class)){
|
if(is_a($field, DatetimeField::class)){
|
||||||
if(isset($fields[$field->getName()]) && !is_a($fields[$field->getName()], DateTime::class)) {
|
if(isset($data[$field->getName()]) && !is_a($data[$field->getName()], DateTime::class)) {
|
||||||
$fields[$field->getName()] = new \Bitrix\Main\Type\DateTime($fields[$field->getName()]);
|
$data[$field->getName()] = new \Bitrix\Main\Type\DateTime($data[$field->getName()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = array_merge($fields, [
|
$data = array_merge($data, [
|
||||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(), // date(CDatabase::DateFormatToPHP(FORMAT_DATETIME))
|
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(), // date(CDatabase::DateFormatToPHP(FORMAT_DATETIME))
|
||||||
]);
|
]);
|
||||||
unset($fields['CREATED_AT']);
|
unset($data['CREATED_AT']);
|
||||||
|
|
||||||
$result = parent::update($id, $fields);
|
return parent::update($primary, $data);
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
* @return \Bitrix\Main\ORM\Data\AddResult
|
* @return \Bitrix\Main\ORM\Data\AddResult
|
||||||
* @throws \Bitrix\Main\ObjectException
|
* @throws \Bitrix\Main\ObjectException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function add(array $fields)
|
public static function add(array $fields)
|
||||||
{
|
{
|
||||||
@@ -88,7 +87,6 @@ class NullableTable extends ADataManager
|
|||||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$result = parent::add($fields);
|
return parent::add($fields);
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user