This commit is contained in:
2024-07-07 12:39:20 +03:00
parent 67484d79f9
commit d8b103fe33
29 changed files with 156 additions and 128 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"id": "bx.null", "id": "bx.nullable",
"prefix": "bx_null", "prefix": "bx_nullable",
"namespace": "Bx\\Null", "namespace": "Bx\\Nullable",
"gitUrl": "https://bitbucket.org/bellord13/bx.null/", "gitUrl": "https://bitbucket.org/bellord13/bx.null/",
"version": "1.0.0", "version": "1.0.0",
"date": "2024-01-01 00:00:00", "date": "2024-01-01 00:00:00",
+1 -1
View File
@@ -3,7 +3,7 @@
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php');
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php'); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php');
$adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('bx.null', 'main'); $adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('bx.nullable', 'main');
$adminPage->render(); $adminPage->render();
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php'); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php');
+1 -4
View File
@@ -1,5 +1,2 @@
<? <?
$MESS['MAIN_OPTIONS_PARAMETERS'] = 'Общие'; $MESS['MAIN_OPTIONS_PARAMETERS'] = 'Общие';
$MESS['LOGO_IMAGE'] = 'Логотип сайта';
$MESS['CACHE_OPTIONS'] = 'Кеш';
$MESS['CACHE_STORAGE'] = 'Место хранения кеша';
+1 -1
View File
@@ -8,4 +8,4 @@ Loc::loadMessages(__FILE__);
return (new GlobalMenuItem()) return (new GlobalMenuItem())
->setSort(10) ->setSort(10)
->setTitle('Null Main'); ->setTitle('Nullable Main');
+4 -4
View File
@@ -1,17 +1,17 @@
<?php <?php
use Bx\Null\ORM\NullTable; use Bx\Nullable\ORM\NullableTable;
use Wt\Core\Admin\TableAdminPage; use Wt\Core\Admin\TableAdminPage;
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin.php');
/** /**
* @var $ormTable NullTable * @var $ormTable NullableTable
*/ */
$ormTable = resolve(NullTable::class); $ormTable = resolve(NullableTable::class);
$tableAdminPage = new TableAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_null.main.null_table.row.php'); $tableAdminPage = new TableAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_nullable.main.nullable_table.row.php');
$tableAdminPage $tableAdminPage
->checkPermission() ->checkPermission()
->start() ->start()
+2 -1
View File
@@ -7,7 +7,8 @@ Loc::loadMessages(__FILE__);
return (new GlobalMenuItem()) return (new GlobalMenuItem())
->setVisible(false)
->setSort(1300) ->setSort(1300)
->setTitle('Null Table') ->setTitle('Nullable Table')
->setIcon('iblock_menu_icon_iblocks') ->setIcon('iblock_menu_icon_iblocks')
->setUrl(); ->setUrl();
@@ -1,17 +1,17 @@
<? <?
use Bx\Null\ORM\NullTable; use Bx\Nullable\ORM\NullableTable;
use Wt\Core\Admin\TableRowAdminPage; use Wt\Core\Admin\TableRowAdminPage;
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_after.php');
/** /**
* @var $ormTable NullTable * @var $ormTable NullableTable
*/ */
$ormTable = resolve(NullTable::class); $ormTable = resolve(NullableTable::class);
$AdminPageTableRow = new TableRowAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_null.main.null_table.php'); $AdminPageTableRow = new TableRowAdminPage($ormTable, $_REQUEST, '/bitrix/admin/bx_nullable.main.nullable_table.php');
$AdminPageTableRow->checkPermission(); $AdminPageTableRow->checkPermission();
$AdminPageTableRow->start(); $AdminPageTableRow->start();
@@ -7,7 +7,7 @@ Loc::loadMessages(__FILE__);
return (new GlobalMenuItem()) return (new GlobalMenuItem())
->setSort(1400) ->setSort(1400)
->setTitle('Null Table Row') ->setTitle('Nullable Table Row')
->setIcon('default_menu_icon') ->setIcon('default_menu_icon')
->setVisible(false) ->setVisible(false)
->setUrl(); ->setUrl();
+1 -1
View File
@@ -12,7 +12,7 @@ CAjax::Init();
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
$adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('bx.null', 'main.settings'); $adminPage = new \Wt\Core\Admin\SiteSettingsAdminPage('bx.nullable', 'main.settings');
$adminPage->render(); $adminPage->render();
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php'); require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_admin.php');
+43 -12
View File
@@ -1,32 +1,37 @@
<?php <?php
use Wt\Core\App\ModuleEntity;
require './../wt.core/include.php'; require './../wt.core/include.php';
$curPath = __DIR__; $curPath = __DIR__;
$newPath = realpath($argv[1]); $newPath = realpath($argv[1]);
$newEntity = __getModuleEntity($newPath); $newEntity = __getModuleEntity($newPath);
$nullEntity = __getModuleEntity(__DIR__); $nullableEntity = __getModuleEntity(__DIR__);
function copy_folder($d1, $d2, $upd = true, $force = true, $exclude = []) { function copy_folder_safe($d1, $d2, $upd = true, $force = true, $exclude = []) {
$cm = 0;
str_replace($exclude, $exclude, $d1, $cm);
if($cm){
echo 'skip ' . $d1 . PHP_EOL;
return;
}
if ( is_dir( $d1 ) ) { if ( is_dir( $d1 ) ) {
$d2 = mkdir_safe( $d2, $force ); $d2 = mkdir_safe( $d2, $force );
if (!$d2) { if (!$d2) {
fs_log("!!fail $d2");
return; return;
} }
$d = dir( $d1 ); $d = dir( $d1 );
while ( false !== ( $entry = $d->read() ) ) { while ( false !== ( $entry = $d->read() ) ) {
if ( $entry != '.' && $entry != '..' ) if ( $entry != '.' && $entry != '..' )
copy_folder( "$d1/$entry", "$d2/$entry", $upd, $force ); copy_folder_safe( "$d1/$entry", "$d2/$entry", $upd, $force, $exclude);
} }
$d->close(); $d->close();
} }
else { else {
$ok = copy_safe( $d1, $d2, $upd ); $ok = copy_safe( $d1, $d2, $upd );
$ok = ($ok) ? "ok-- " : " -- ";
fs_log("{$ok}$d1");
} }
} //function copy_folder }
function mkdir_safe( $dir, $force ) { function mkdir_safe( $dir, $force ) {
if (file_exists($dir)) { if (file_exists($dir)) {
@@ -35,7 +40,7 @@ function mkdir_safe( $dir, $force ) {
unlink($dir); unlink($dir);
} }
return (mkdir($dir, 0777, true)) ? $dir : false; return (mkdir($dir, 0777, true)) ? $dir : false;
} //function mkdir_safe }
function copy_safe ($f1, $f2, $upd) { function copy_safe ($f1, $f2, $upd) {
$time1 = filemtime($f1); $time1 = filemtime($f1);
@@ -46,18 +51,44 @@ function copy_safe ($f1, $f2, $upd) {
$ok = copy($f1, $f2); $ok = copy($f1, $f2);
if ($ok) touch($f2, $time1); if ($ok) touch($f2, $time1);
return $ok; return $ok;
} //function copy_safe }
function fs_log($str) { function fs_log($str) {
return; return;
$log = fopen("./fs_log.txt", "a"); $log = fopen('./fs_log.txt', 'a');
$time = date("Y-m-d H:i:s"); $time = date('Y-m-d H:i:s');
fwrite($log, "$str ($time)\n"); fwrite($log, "$str ($time)\n");
fclose($log); fclose($log);
} }
function _fix($newPath, ModuleEntity $newEntity, ModuleEntity $nullableEntity){
$d = new RecursiveDirectoryIterator( $newPath );
foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
if( is_file( $path ) && str_ends_with($path, '.php')){
$orig_file = file_get_contents($path);
$new_file = $orig_file;
$cr = 0;
$new_file = str_replace($nullableEntity->getLangPrefix(), $newEntity->getLangPrefix(), $new_file, $cr);
$new_file = str_replace($nullableEntity->fields()->id, $newEntity->fields()->id, $new_file, $cr);
$new_file = str_replace($nullableEntity->fields()->prefix, $newEntity->fields()->prefix, $new_file, $cr);
$new_file = str_replace($nullableEntity->getNamespace(), $newEntity->getNamespace(), $new_file, $cr);
echo $cr . ' ' .$path . PHP_EOL;
if($orig_file != $new_file){
file_put_contents($path, $new_file);
}
}
}
}
echo $newEntity->getId() . PHP_EOL; echo $newEntity->getId() . PHP_EOL;
copy_folder($nullEntity->getDir(), $newEntity->getDir()); copy_folder_safe($nullableEntity->getPath(), $newEntity->getPath(), true, true, [
'.git',
'clone.php',
'.module.json',
]);
_fix($newPath, $newEntity, $nullableEntity);
+1 -1
View File
@@ -2,6 +2,6 @@
return [ return [
'MainAbstractFactory' => [ 'MainAbstractFactory' => [
'Bx\Null\Factory\NullFactory' => ['cache' => ['hit'], 'is_collection_query' => true], 'Bx\Nullable\Factory\NullableFactory' => ['cache' => ['hit'], 'is_collection_query' => true],
], ],
]; ];
+3 -3
View File
@@ -1,12 +1,12 @@
<?php <?php
use Bx\Null\App\App; use Bx\Nullable\App\App;
/** /**
* @return App * @return App
* @throws null * @throws null
*/ */
function nullApp() { function nullableApp() {
$app = App::getInstance('bx.null'); $app = App::getInstance('bx.nullable');
return $app; return $app;
} }
+1 -1
View File
@@ -4,7 +4,7 @@ use Bitrix\Main\EventManager;
IncludeModuleLangFile(__FILE__); IncludeModuleLangFile(__FILE__);
class bx_null extends \CModule class bx_nullable extends \CModule
{ {
public $module = []; public $module = [];
var $MODULE_GROUP_RIGHTS = 'Y'; var $MODULE_GROUP_RIGHTS = 'Y';
+4 -4
View File
@@ -1,5 +1,5 @@
<? <?
$MESS ['bx_null_partner_name'] = 'CoreLion'; $MESS ['bx_nullable_partner_name'] = 'CoreLion';
$MESS ['bx_null_partner_uri'] = 'https://corelion.ru/'; $MESS ['bx_nullable_partner_uri'] = 'https://corelion.ru/';
$MESS ['bx_null_module_name'] = 'Bx: Null'; $MESS ['bx_nullable_module_name'] = 'Bx: Nullable';
$MESS ['bx_null_module_description'] = 'Null module'; $MESS ['bx_nullable_module_description'] = 'Nullable module';
+5 -5
View File
@@ -1,20 +1,20 @@
<?php <?php
namespace Bx\Null\AbstractFactory; namespace Bx\Nullable\AbstractFactory;
use Wt\Core\AbstractFactory\AAbstractFactory; use Wt\Core\AbstractFactory\AAbstractFactory;
use Bx\Null\Factory\NullFactory; use Bx\Nullable\Factory\NullableFactory;
class MainAbstractFactory extends AAbstractFactory class MainAbstractFactory extends AAbstractFactory
{ {
/** /**
* @return NullFactory * @return NullableFactory
*/ */
public function getNullFactory() public function getNullableFactory()
{ {
return $this->getFactoryInstance(NullFactory::class); return $this->getFactoryInstance(NullableFactory::class);
} }
} }
@@ -1,12 +1,12 @@
<?php <?php
namespace Bx\Null\Ajax; namespace Bx\Nullable\Ajax;
use Wt\Core\Ajax\AAjaxHandler; use Wt\Core\Ajax\AAjaxHandler;
class BxNull extends AAjaxHandler class BxNullable extends AAjaxHandler
{ {
public function ajaxStart() public function ajaxStart()
{ {
@@ -15,7 +15,7 @@ class BxNull extends AAjaxHandler
public function test() public function test()
{ {
$this->getResponse()->addData(['method' => 'test', 'version' => nullApp()->module()->getVersion()]); $this->getResponse()->addData(['method' => 'test', 'version' => app()::getInstance('bx.nullable')->module()->getVersion()]);
return $this->getResponse(); return $this->getResponse();
} }
} }
+7 -7
View File
@@ -1,15 +1,15 @@
<?php <?php
namespace Bx\Null\App; namespace Bx\Nullable\App;
use Bx\Null\Facade\DefaultDefines; use Bx\Nullable\Facade\DefaultDefines;
use Bx\Null\Facade\Defines; use Bx\Nullable\Facade\Defines;
use Bx\Null\Facade\DefaultServiceFacade; use Bx\Nullable\Facade\DefaultServiceFacade;
use Bx\Null\Facade\ServiceFacade; use Bx\Nullable\Facade\ServiceFacade;
use Bx\Null\Facade\DefaultFactoryFacade; use Bx\Nullable\Facade\DefaultFactoryFacade;
use Bx\Null\Facade\FactoryFacade; use Bx\Nullable\Facade\FactoryFacade;
class App extends \Wt\Core\App\App class App extends \Wt\Core\App\App
{ {
@@ -1,18 +1,18 @@
<?php <?php
namespace Bx\Null\Collection; namespace Bx\Nullable\Collection;
use Wt\Core\Collection\AEntityCollection; use Wt\Core\Collection\AEntityCollection;
use Bx\Null\Entity\NullEntity; use Bx\Nullable\Entity\NullableEntity;
class NullCollection extends AEntityCollection class NullableCollection extends AEntityCollection
{ {
/** /**
* @param $xmlId * @param $xmlId
* @return NullEntity * @return NullableEntity
*/ */
public function &getByXmlId($xmlId) public function &getByXmlId($xmlId)
{ {
@@ -22,7 +22,7 @@ class NullCollection extends AEntityCollection
/** /**
* @param $id * @param $id
* @param null $default * @param null $default
* @return NullEntity|null * @return NullableEntity|null
*/ */
public function &get($id, $default = null) public function &get($id, $default = null)
{ {
@@ -30,15 +30,15 @@ class NullCollection extends AEntityCollection
} }
/** /**
* @return NullEntity * @return NullableEntity
*/ */
public function &first() public function &first(callable $callback = null, $default = null)
{ {
return parent::first(); // TODO: Change the autogenerated stub return parent::first($callback, $default); // TODO: Change the autogenerated stub
} }
/** /**
* @return NullEntity * @return NullableEntity
*/ */
public function &last() public function &last()
{ {
@@ -46,7 +46,7 @@ class NullCollection extends AEntityCollection
} }
/** /**
* @return NullEntity * @return NullableEntity
*/ */
public function shift() public function shift()
{ {
@@ -54,7 +54,7 @@ class NullCollection extends AEntityCollection
} }
/** /**
* @return NullEntity * @return NullableEntity
*/ */
public function pop() public function pop()
{ {
@@ -62,7 +62,7 @@ class NullCollection extends AEntityCollection
} }
/** /**
* @return NullEntity[] * @return NullableEntity[]
*/ */
public function all() public function all()
{ {
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Bx\Nullable\Entity;
use Bx\Nullable\IFields\NullableFields;
use Wt\Core\Entity\AEntity;
class NullableEntity extends AEntity
{
/**
* @return NullableFields
*/
public function fields()
{
return parent::fields();
}
}
-20
View File
@@ -1,20 +0,0 @@
<?php
namespace Bx\Null\Entity;
use Bx\Null\IFields\NullFields;
use Wt\Core\Entity\AEntity;
use Wt\Core\Supports\Entity;
class NullEntity extends AEntity
{
/**
* @return NullFields
*/
public function fields()
{
return parent::fields();
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Bx\Null\Facade; namespace Bx\Nullable\Facade;
use Wt\Core\App\ADefines; use Wt\Core\App\ADefines;
+2 -2
View File
@@ -1,10 +1,10 @@
<?php <?php
namespace Bx\Null\Facade; namespace Bx\Nullable\Facade;
use Bx\Null\AbstractFactory\MainAbstractFactory; use Bx\Nullable\AbstractFactory\MainAbstractFactory;
use Wt\Core\Facade\AFacade; use Wt\Core\Facade\AFacade;
class DefaultFactoryFacade extends AFacade class DefaultFactoryFacade extends AFacade
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Bx\Null\Facade; namespace Bx\Nullable\Facade;
use Wt\Core\Facade\AFacade; use Wt\Core\Facade\AFacade;
@@ -1,44 +1,44 @@
<?php <?php
namespace Bx\Null\Factory; namespace Bx\Nullable\Factory;
use Bx\Null\Collection\NullCollection; use Bx\Nullable\Collection\NullableCollection;
use Bx\Null\Entity\NullEntity; use Bx\Nullable\Entity\NullableEntity;
use Bx\Null\ORM\NullTable; use Bx\Nullable\ORM\NullableTable;
use Wt\Core\Factory\AFactory; use Wt\Core\Factory\AFactory;
use Wt\Core\Factory\AORMFactory; use Wt\Core\Factory\AORMFactory;
class NullFactory extends AORMFactory class NullableFactory extends AORMFactory
{ {
/** /**
* @return string|NullTable * @return string|NullableTable
*/ */
protected function __getDataManagerClass() protected function __getDataManagerClass()
{ {
return NullTable::class; return NullableTable::class;
} }
public function __getEntityClass() public function __getEntityClass()
{ {
return NullEntity::class; return NullableEntity::class;
} }
public function __getCachePrefix() public function __getCachePrefix()
{ {
return 'bx_null'; return 'bx_nullable';
} }
public function __getCollectionClass() public function __getCollectionClass()
{ {
return NullCollection::class; return NullableCollection::class;
} }
/** /**
* @param $id * @param $id
* @return NullEntity * @return NullableEntity
*/ */
public function getEntityById($id) public function getEntityById($id)
{ {
@@ -51,7 +51,7 @@ class NullFactory extends AORMFactory
* @param array $select * @param array $select
* @param null $limit * @param null $limit
* @param null $offset * @param null $offset
* @return NullCollection|NullEntity[] * @return NullableCollection|NullableEntity[]
*/ */
public function getCollection($filter = [], $order = [], $select = [], $limit = null, $offset = null) public function getCollection($filter = [], $order = [], $select = [], $limit = null, $offset = null)
{ {
@@ -60,7 +60,7 @@ class NullFactory extends AORMFactory
/** /**
* @param array $arIds * @param array $arIds
* @return NullCollection|NullEntity[] * @return NullableCollection|NullableEntity[]
*/ */
public function getEntityByIds(array $arIds) public function getEntityByIds(array $arIds)
{ {
@@ -68,7 +68,7 @@ class NullFactory extends AORMFactory
} }
/** /**
* @return NullTable * @return NullableTable
*/ */
public function getDataManager() public function getDataManager()
{ {
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace Bx\Nullable\IFields;
use Wt\Core\Interfaces\IFields;
class NullableFields implements IFields
{
}
-12
View File
@@ -1,12 +0,0 @@
<?php
namespace Bx\Null\IFields;
use Wt\Core\Interfaces\IFields;
class NullFields implements IFields
{
}
@@ -1,34 +1,34 @@
<?php <?php
namespace Bx\Null\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 Wt\Core\ORM\ADataManager; use Wt\Core\ORM\ADataManager;
class NullTable extends ADataManager class NullableTable extends ADataManager
{ {
public static function getTitle() public static function getTitle()
{ {
return 'Null Title'; return 'Nullable Title';
} }
public static function getRowTitle() public static function getRowTitle()
{ {
return 'Null Row Title'; return 'Nullable Row Title';
} }
public static function getRowDescription() public static function getRowDescription()
{ {
return 'Null Row Description'; return 'Nullable Row Description';
} }
public static function getTableName() public static function getTableName()
{ {
return 'bx_null_table'; return 'bx_nullable_table';
} }
public static function getMap() public static function getMap()
+3 -3
View File
@@ -1,10 +1,10 @@
<?php <?php
namespace Bx\Null\Providers; namespace Bx\Nullable\Providers;
use Bx\Null\AbstractFactory\MainAbstractFactory; use Bx\Nullable\AbstractFactory\MainAbstractFactory;
use Wt\Core\Interfaces\IApp; use Wt\Core\Interfaces\IApp;
use Wt\Core\Interfaces\IServiceProvider; use Wt\Core\Interfaces\IServiceProvider;
@@ -16,7 +16,7 @@ class DefaultFactoryProvider implements IServiceProvider
$serviceContainer = $app->container(); $serviceContainer = $app->container();
/** /**
* @var $mainAbstractFactory MainAbstractFactory * @var MainAbstractFactory $mainAbstractFactory
*/ */
$mainAbstractFactory = $serviceContainer->make(MainAbstractFactory::class, [$config->get('MainAbstractFactory', [])]); $mainAbstractFactory = $serviceContainer->make(MainAbstractFactory::class, [$config->get('MainAbstractFactory', [])]);
$serviceContainer->singleton($app->module()->getId().':mainAbstractFactory', $mainAbstractFactory); $serviceContainer->singleton($app->module()->getId().':mainAbstractFactory', $mainAbstractFactory);
+1 -1
View File
@@ -1,7 +1,7 @@
<?php <?php
namespace Bx\Null\Providers; namespace Bx\Nullable\Providers;
use Wt\Core\Interfaces\IApp; use Wt\Core\Interfaces\IApp;