fix
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Bx\Null\AbstractFactory;
|
||||||
|
|
||||||
|
|
||||||
|
use Wt\Core\AbstractFactory\AAbstractFactory;
|
||||||
|
use Bx\Null\Factory\NullFactory;
|
||||||
|
|
||||||
|
class MainAbstractFactory extends AAbstractFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return NullFactory
|
||||||
|
*/
|
||||||
|
public function getNullFactory()
|
||||||
|
{
|
||||||
|
return $this->resolveFactory(NullFactory::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,9 +5,10 @@ namespace Bx\Null\Entity;
|
|||||||
|
|
||||||
|
|
||||||
use Bx\Null\IFields\NullFields;
|
use Bx\Null\IFields\NullFields;
|
||||||
|
use Wt\Core\Entity\AEntity;
|
||||||
use Wt\Core\Supports\Entity;
|
use Wt\Core\Supports\Entity;
|
||||||
|
|
||||||
class NullEntity extends Entity
|
class NullEntity extends AEntity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return NullFields
|
* @return NullFields
|
||||||
|
|||||||
@@ -4,9 +4,17 @@
|
|||||||
namespace Bx\Null\Facade;
|
namespace Bx\Null\Facade;
|
||||||
|
|
||||||
|
|
||||||
|
use Bx\Null\AbstractFactory\MainAbstractFactory;
|
||||||
use Wt\Core\Facade\AFacade;
|
use Wt\Core\Facade\AFacade;
|
||||||
|
|
||||||
class DefaultFactoryFacade extends AFacade
|
class DefaultFactoryFacade extends AFacade
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return MainAbstractFactory
|
||||||
|
*/
|
||||||
|
public function main()
|
||||||
|
{
|
||||||
|
return $this->app->container()->make($this->app->module()->getId().':mainAbstractFactory');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -37,12 +37,20 @@ class NullFactory extends AORMFactory
|
|||||||
*/
|
*/
|
||||||
public function getEntityById($id)
|
public function getEntityById($id)
|
||||||
{
|
{
|
||||||
|
return parent::getEntityById($id);
|
||||||
$res = $this->getList(['=ID' => $id]);
|
|
||||||
if( $res ){
|
|
||||||
return $this->getEntityByResult(reset($res));
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
/**
|
||||||
|
* @param array $filter
|
||||||
|
* @param array $order
|
||||||
|
* @param array $select
|
||||||
|
* @param null $limit
|
||||||
|
* @param null $offset
|
||||||
|
* @return NullCollection
|
||||||
|
*/
|
||||||
|
public function getCollection($filter = [], $order = [], $select = [], $limit = null, $offset = null)
|
||||||
|
{
|
||||||
|
return parent::getCollection($filter, $order, $select, $limit, $offset); // TODO: Change the autogenerated stub
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,13 +40,12 @@ class NullTable extends ADataManager
|
|||||||
'title' => 'Id',
|
'title' => 'Id',
|
||||||
]),
|
]),
|
||||||
'CREATED_AT' => new \Bitrix\Main\Entity\DatetimeField('CREATED_AT', [
|
'CREATED_AT' => new \Bitrix\Main\Entity\DatetimeField('CREATED_AT', [
|
||||||
'default_value' => new \Bitrix\Main\Type\DateTime(),
|
|
||||||
'title' => 'CreatedAt',
|
'title' => 'CreatedAt',
|
||||||
'in_form' => false,
|
'user_edit' => false,
|
||||||
]),
|
]),
|
||||||
'UPDATED_AT' => new \Bitrix\Main\Entity\DatetimeField('UPDATED_AT', [
|
'UPDATED_AT' => new \Bitrix\Main\Entity\DatetimeField('UPDATED_AT', [
|
||||||
'title' => 'UpdatedAt',
|
'title' => 'UpdatedAt',
|
||||||
'in_form' => false,
|
'user_edit' => false,
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -58,7 +57,7 @@ class NullTable extends ADataManager
|
|||||||
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
||||||
* @throws \Bitrix\Main\ObjectException
|
* @throws \Bitrix\Main\ObjectException
|
||||||
*/
|
*/
|
||||||
public static function update($id, $fields)
|
public static function update($id, array $fields)
|
||||||
{
|
{
|
||||||
foreach (static::getEntity()->getFields() as $field){
|
foreach (static::getEntity()->getFields() as $field){
|
||||||
if(is_a($field, DatetimeField::class)){
|
if(is_a($field, DatetimeField::class)){
|
||||||
@@ -71,6 +70,7 @@ class NullTable extends ADataManager
|
|||||||
$fields = array_merge($fields, [
|
$fields = array_merge($fields, [
|
||||||
'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']);
|
||||||
|
|
||||||
$result = parent::update($id, $fields);
|
$result = parent::update($id, $fields);
|
||||||
return $result;
|
return $result;
|
||||||
@@ -81,7 +81,7 @@ class NullTable extends ADataManager
|
|||||||
* @return \Bitrix\Main\ORM\Data\AddResult
|
* @return \Bitrix\Main\ORM\Data\AddResult
|
||||||
* @throws \Bitrix\Main\ObjectException
|
* @throws \Bitrix\Main\ObjectException
|
||||||
*/
|
*/
|
||||||
public static function add($fields)
|
public static function add(array $fields)
|
||||||
{
|
{
|
||||||
$fields = array_merge($fields, [
|
$fields = array_merge($fields, [
|
||||||
'CREATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
'CREATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Bx\Null\Providers;
|
||||||
|
|
||||||
|
|
||||||
|
use Bx\Null\AbstractFactory\MainAbstractFactory;
|
||||||
|
use Wt\Core\Interfaces\IApp;
|
||||||
|
use Wt\Core\Interfaces\IServiceProvider;
|
||||||
|
|
||||||
|
class DefaultFactoryProvider implements IServiceProvider
|
||||||
|
{
|
||||||
|
public function register(IApp $app)
|
||||||
|
{
|
||||||
|
$config = $app->config();
|
||||||
|
$serviceContainer = $app->container();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $mainAbstractFactory MainAbstractFactory
|
||||||
|
*/
|
||||||
|
$mainAbstractFactory = $serviceContainer->make(MainAbstractFactory::class, [$config->get('MainAbstractFactory', [])]);
|
||||||
|
$serviceContainer->singleton($app->module()->getId().':mainAbstractFactory', $mainAbstractFactory);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user