@@ -82,7 +82,41 @@ public function write($module, $table, $tables, $filename)
8282 }
8383
8484 /**
85- * @public function renderPermissionsHandler
85+ * @public function render
86+ * @param null
87+ *
88+ * @return bool|string
89+ */
90+ public function renderClass ()
91+ {
92+ $ pc = Modulebuilder \Files \CreatePhpCode::getInstance ();
93+ $ xc = Modulebuilder \Files \CreateXoopsCode::getInstance ();
94+ $ module = $ this ->getModule ();
95+ $ filename = $ this ->getFileName ();
96+ $ moduleDirname = $ module ->getVar ('mod_dirname ' );
97+ $ namespace = $ pc ->getPhpCodeNamespace (['XoopsModules ' , $ moduleDirname ]);
98+ $ content = $ this ->getHeaderFilesComments ($ module , null , $ namespace );
99+ $ content .= $ pc ->getPhpCodeUseNamespace (['XoopsModules ' , $ moduleDirname ]);
100+ $ content .= $ pc ->getPhpCodeDefined ();
101+ $ content .= $ pc ->getPhpCodeCommentMultiLine (['Class Object ' => $ this ->className ]);
102+ $ cCl = $ pc ->getPhpCodeCommentMultiLine (['Constructor ' => '' , '' => '' , '@param ' => 'null ' ], "\t" );
103+ $ constr = '' ;
104+ $ cCl .= $ pc ->getPhpCodeFunction ('__construct ' , '' , $ constr , 'public ' , false , "\t" );
105+ $ arrGetInstance = ['@static function ' => '&getInstance ' , '' => '' , '@param ' => 'null ' ];
106+ $ cCl .= $ pc ->getPhpCodeCommentMultiLine ($ arrGetInstance , "\t" );
107+ $ getInstance = $ pc ->getPhpCodeVariableClass ('static ' , 'instance ' , 'false ' , "\t\t" );
108+ $ instance = $ xc ->getXcEqualsOperator ('$instance ' , 'new self() ' , null , "\t\t\t" );
109+ $ getInstance .= $ pc ->getPhpCodeConditions ('!$instance ' , '' , '' , $ instance , false , "\t\t" );
110+ $ cCl .= $ pc ->getPhpCodeFunction ('getInstance ' , '' , $ getInstance , 'public static ' , false , "\t" );
111+ $ content .= $ pc ->getPhpCodeClass ($ this ->className , $ cCl , '\XoopsObject ' );
112+
113+ $ this ->create ($ moduleDirname , 'class ' , $ filename , $ content , _AM_MODULEBUILDER_FILE_CREATED , _AM_MODULEBUILDER_FILE_NOTCREATED );
114+
115+ return $ this ->renderFile ();
116+ }
117+
118+ /**
119+ * @public function getGlobalPerms
86120 * @param null
87121 *
88122 * @return bool|string
@@ -146,42 +180,6 @@ public function getGlobalPerms($permId)
146180 return $ functions ;
147181 }
148182
149- /**
150- * @public function render
151- * @param null
152- *
153- * @return bool|string
154- */
155- public function renderClass ()
156- {
157- $ pc = Modulebuilder \Files \CreatePhpCode::getInstance ();
158- $ xc = Modulebuilder \Files \CreateXoopsCode::getInstance ();
159- $ module = $ this ->getModule ();
160- $ filename = $ this ->getFileName ();
161- $ moduleDirname = $ module ->getVar ('mod_dirname ' );
162- $ namespace = $ pc ->getPhpCodeNamespace (['XoopsModules ' , $ moduleDirname ]);
163- $ content = $ this ->getHeaderFilesComments ($ module , null , $ namespace );
164- $ content .= $ pc ->getPhpCodeUseNamespace (['XoopsModules ' , $ moduleDirname ]);
165- $ content .= $ pc ->getPhpCodeDefined ();
166- $ content .= $ pc ->getPhpCodeCommentMultiLine (['Class Object ' => $ this ->className ]);
167- $ cCl = $ pc ->getPhpCodeCommentMultiLine (['Constructor ' => '' , '' => '' , '@param ' => 'null ' ], "\t" );
168- $ constr = '' ;
169- $ cCl .= $ pc ->getPhpCodeFunction ('__construct ' , '' , $ constr , 'public ' , false , "\t" );
170- $ arrGetInstance = ['@static function ' => '&getInstance ' , '' => '' , '@param ' => 'null ' ];
171- $ cCl .= $ pc ->getPhpCodeCommentMultiLine ($ arrGetInstance , "\t" );
172- $ getInstance = $ pc ->getPhpCodeVariableClass ('static ' , 'instance ' , 'false ' , "\t\t" );
173- $ instance = $ xc ->getXcEqualsOperator ('$instance ' , 'new self() ' , null , "\t\t\t" );
174- $ getInstance .= $ pc ->getPhpCodeConditions ('!$instance ' , '' , '' , $ instance , false , "\t\t" );
175- $ cCl .= $ pc ->getPhpCodeFunction ('getInstance ' , '' , $ getInstance , 'public static ' , false , "\t" );
176- $ content .= $ pc ->getPhpCodeClass ($ this ->className , $ cCl , '\XoopsObject ' );
177-
178- $ this ->create ($ moduleDirname , 'class ' , $ filename , $ content , _AM_MODULEBUILDER_FILE_CREATED , _AM_MODULEBUILDER_FILE_NOTCREATED );
179-
180-
181-
182- return $ this ->renderFile ();
183- }
184-
185183 /**
186184 * @public function renderPermissionsHandler
187185 * @param null
@@ -213,6 +211,12 @@ public function renderPermissionsHandler()
213211 return $ this ->renderFile ();
214212 }
215213
214+ /**
215+ * @public function renderConstantsInterface
216+ * @param null
217+ *
218+ * @return bool|string
219+ */
216220 public function renderConstantsInterface ()
217221 {
218222 $ pc = Modulebuilder \Files \CreatePhpCode::getInstance ();
0 commit comments