From 814993936e9015280275e087538c1eaa889d8c44 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 20 Nov 2024 15:34:22 +0300 Subject: [PATCH] Splitting registration methods --- src/bind.inc.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/bind.inc.php b/src/bind.inc.php index 3eef75a..7fd6939 100644 --- a/src/bind.inc.php +++ b/src/bind.inc.php @@ -48,14 +48,36 @@ class BindEclLitePlugin implements \bhl_bind\BindPlugin return ''; } + function codegenRegisterDecls(\Twig\Environment $twig) + { + $sliced = \bhl_bind\slice_units($this->units, 20); + + $code = ''; + + foreach($sliced as $idx => $units) + { + $code .= "public static void Register_Ecslite_$idx(Types types)\n"; + $code .= "{\n"; + + foreach($units as $u) + { + if($u->object->hasToken('bhl_ecslite_component')) + $code .= $twig->render('bind_ecslite.twig', ['unit' => $u->object]); + } + $code .= "\n}\n"; + } + + return $code; + } + function codegenRegister(\Twig\Environment $twig) { + $sliced = \bhl_bind\slice_units($this->units, 20); + $code = ''; - foreach($this->units as $u) - { - if($u->object->hasToken('bhl_ecslite_component')) - $code .= $twig->render('bind_ecslite.twig', ['unit' => $u->object]); - } + foreach($sliced as $idx => $units) + $code .= "Register_Ecslite_$idx(types);\n"; + return $code; } }