1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\System\Module; |
9: | |
10: | use Aurora\Api; |
11: | use Illuminate\Support\Str; |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | abstract class AbstractModule |
21: | { |
22: | |
23: | |
24: | |
25: | protected $sPath; |
26: | |
27: | |
28: | |
29: | |
30: | protected $sVersion; |
31: | |
32: | |
33: | |
34: | |
35: | protected $aManagersCache = []; |
36: | |
37: | |
38: | |
39: | |
40: | protected $aParameters; |
41: | |
42: | |
43: | |
44: | |
45: | protected $aObjects = []; |
46: | |
47: | |
48: | |
49: | |
50: | public $oHttp; |
51: | |
52: | |
53: | |
54: | |
55: | protected $aConfig; |
56: | |
57: | |
58: | |
59: | |
60: | |
61: | protected $oModuleSettings = null; |
62: | |
63: | |
64: | |
65: | |
66: | |
67: | protected $aSettingsMap = []; |
68: | |
69: | |
70: | |
71: | |
72: | |
73: | public static $Delimiter = '::'; |
74: | |
75: | |
76: | |
77: | |
78: | |
79: | protected $bInitialized = false; |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | protected $aRequireModules = []; |
86: | |
87: | |
88: | |
89: | |
90: | |
91: | protected $aSkipedEvents = []; |
92: | |
93: | |
94: | |
95: | |
96: | |
97: | public $aErrors = []; |
98: | |
99: | |
100: | |
101: | |
102: | |
103: | public $aAdditionalEntityFieldsToEdit = []; |
104: | |
105: | |
106: | |
107: | |
108: | |
109: | protected $oModuleManager = null; |
110: | |
111: | |
112: | |
113: | |
114: | |
115: | protected $bIsPermanent = false; |
116: | |
117: | protected $aDeniedMethodsByWebApi = [ |
118: | 'init', |
119: | 'initialize', |
120: | 'loadModuleSettings', |
121: | 'saveModuleConfig', |
122: | 'getConfig', |
123: | 'CallMethod' |
124: | ]; |
125: | |
126: | |
127: | |
128: | |
129: | |
130: | protected $aLang; |
131: | |
132: | |
133: | |
134: | |
135: | public function __construct($sPath, $sVersion = '1.0') |
136: | { |
137: | $this->sVersion = (string) $sVersion; |
138: | |
139: | $this->sPath = $sPath . self::GetName(); |
140: | $this->aParameters = []; |
141: | $this->oHttp = \MailSo\Base\Http::SingletonInstance(); |
142: | $this->oModuleManager = \Aurora\System\Api::GetModuleManager(); |
143: | } |
144: | |
145: | |
146: | |
147: | |
148: | |
149: | abstract public function init(); |
150: | |
151: | |
152: | |
153: | |
154: | |
155: | |
156: | |
157: | |
158: | public static function createInstance($sPath, $sVersion = '1.0') |
159: | { |
160: | |
161: | return new static($sPath, $sVersion); |
162: | } |
163: | |
164: | |
165: | |
166: | |
167: | |
168: | public static function getInstance() |
169: | { |
170: | return \Aurora\System\Api::GetModule(self::GetName()); |
171: | } |
172: | |
173: | |
174: | |
175: | |
176: | |
177: | public static function Decorator() |
178: | { |
179: | return \Aurora\System\Api::GetModuleDecorator(self::GetName()); |
180: | } |
181: | |
182: | |
183: | |
184: | |
185: | |
186: | public function __invoke() |
187: | { |
188: | return \Aurora\System\Api::GetModuleDecorator(self::GetName()); |
189: | } |
190: | |
191: | public static function __callStatic($name, $arguments) |
192: | { |
193: | if (Str::startsWith($name, '_')) { |
194: | $moduleInstance = self::Decorator(); |
195: | $name = substr($name, 1); |
196: | return call_user_func_array([$moduleInstance, $name], $arguments); |
197: | } |
198: | } |
199: | |
200: | |
201: | |
202: | |
203: | |
204: | |
205: | protected function SetModuleManager(Manager $oModuleManager) |
206: | { |
207: | return $this->oModuleManager = $oModuleManager; |
208: | } |
209: | |
210: | |
211: | |
212: | |
213: | |
214: | protected function GetModuleManager() |
215: | { |
216: | return $this->oModuleManager; |
217: | } |
218: | |
219: | |
220: | |
221: | |
222: | |
223: | protected function GetModuleSettings() |
224: | { |
225: | return $this->oModuleSettings; |
226: | } |
227: | |
228: | |
229: | |
230: | |
231: | |
232: | public function RequireModule($sModule) |
233: | { |
234: | if (!in_array($sModule, $this->aRequireModules)) { |
235: | $this->aRequireModules[] = $sModule; |
236: | } |
237: | } |
238: | |
239: | |
240: | |
241: | |
242: | |
243: | public function GetRequireModules() |
244: | { |
245: | return $this->aRequireModules; |
246: | } |
247: | |
248: | |
249: | |
250: | |
251: | |
252: | public function isPermanent() |
253: | { |
254: | return $this->bIsPermanent; |
255: | } |
256: | |
257: | |
258: | |
259: | |
260: | |
261: | public function isValid() |
262: | { |
263: | return true; |
264: | } |
265: | |
266: | |
267: | |
268: | |
269: | |
270: | |
271: | protected function isAllowedModule() |
272: | { |
273: | return $this->isPermanent() || $this->oModuleManager->IsAllowedModule(self::GetName()); |
274: | } |
275: | |
276: | |
277: | |
278: | |
279: | |
280: | |
281: | protected function isInitialized() |
282: | { |
283: | return (bool) $this->bInitialized; |
284: | } |
285: | |
286: | |
287: | |
288: | |
289: | |
290: | public function initialize() |
291: | { |
292: | $mResult = true; |
293: | if (!$this->isInitialized()) { |
294: | $this->bInitialized = true; |
295: | $this->loadModuleSettings(); |
296: | $this->init(); |
297: | } |
298: | |
299: | return $mResult; |
300: | } |
301: | |
302: | |
303: | |
304: | |
305: | |
306: | final public static function getNamespace() |
307: | { |
308: | return \substr_replace(static::class, '', -7); |
309: | } |
310: | |
311: | |
312: | |
313: | |
314: | |
315: | public function loadModuleSettings() |
316: | { |
317: | if (!isset($this->oModuleSettings)) { |
318: | $this->oModuleSettings =& $this->GetModuleManager()->GetModuleSettings(self::GetName()); |
319: | $this->oModuleSettings->Load(); |
320: | } |
321: | return $this->oModuleSettings; |
322: | } |
323: | |
324: | |
325: | |
326: | |
327: | |
328: | |
329: | public function saveModuleConfig() |
330: | { |
331: | $bResult = false; |
332: | |
333: | if (isset($this->oModuleSettings)) { |
334: | $bResult = $this->oModuleSettings->Save(); |
335: | } |
336: | |
337: | return $bResult; |
338: | } |
339: | |
340: | |
341: | |
342: | |
343: | |
344: | |
345: | |
346: | public function getConfig($sName, $mDefaultValue = null) |
347: | { |
348: | $mResult = $mDefaultValue; |
349: | if (isset($this->oModuleSettings)) { |
350: | $mResult = $this->oModuleSettings->GetValue($sName, $mDefaultValue); |
351: | } |
352: | |
353: | return $mResult; |
354: | } |
355: | |
356: | |
357: | |
358: | |
359: | |
360: | |
361: | |
362: | |
363: | |
364: | public function setConfig($sName, $sValue = null) |
365: | { |
366: | $bResult = false; |
367: | |
368: | if (isset($this->oModuleSettings)) { |
369: | $bResult = $this->oModuleSettings->SetValue($sName, $sValue); |
370: | } |
371: | |
372: | return $bResult; |
373: | } |
374: | |
375: | |
376: | |
377: | |
378: | |
379: | |
380: | public function denyMethodsCallByWebApi($aMethods) |
381: | { |
382: | foreach ($aMethods as $sMethodName) { |
383: | $this->denyMethodCallByWebApi($sMethodName); |
384: | } |
385: | } |
386: | |
387: | |
388: | |
389: | |
390: | |
391: | |
392: | public function denyMethodCallByWebApi($sMethodName) |
393: | { |
394: | if (!in_array($sMethodName, $this->aDeniedMethodsByWebApi)) { |
395: | $this->aDeniedMethodsByWebApi[] = $sMethodName; |
396: | } |
397: | } |
398: | |
399: | |
400: | |
401: | |
402: | |
403: | |
404: | protected function isDeniedMethodByWebApi($sMethodName) |
405: | { |
406: | return in_array($sMethodName, array_values($this->aDeniedMethodsByWebApi)); |
407: | } |
408: | |
409: | |
410: | |
411: | |
412: | |
413: | |
414: | protected function isEventCallback($sMethod) |
415: | { |
416: | return in_array($sMethod, $this->getEventsCallbacks()); |
417: | } |
418: | |
419: | |
420: | |
421: | |
422: | |
423: | protected function getEventsCallbacks() |
424: | { |
425: | $aEventsValues = array(); |
426: | $aEvents = $this->GetModuleManager()->getEvents(); |
427: | foreach (array_values($aEvents) as $aEvent) { |
428: | foreach ($aEvent as $aEv) { |
429: | if ($aEv[0]::GetName() === self::GetName()) { |
430: | $aEventsValues[] = $aEv[1]; |
431: | } |
432: | } |
433: | } |
434: | |
435: | return $aEventsValues; |
436: | } |
437: | |
438: | |
439: | |
440: | |
441: | |
442: | |
443: | |
444: | public function subscribeEvent($sEvent, $fCallback, $iPriority = 100) |
445: | { |
446: | $this->GetModuleManager()->subscribeEvent($sEvent, $fCallback, $iPriority); |
447: | } |
448: | |
449: | |
450: | |
451: | |
452: | |
453: | |
454: | public function broadcastEvent($sEvent, &$aArguments = [], &$mResult = null) |
455: | { |
456: | if (!in_array($sEvent, $this->aSkipedEvents)) { |
457: | return $this->GetModuleManager()->broadcastEvent( |
458: | self::GetName(), |
459: | $sEvent, |
460: | $aArguments, |
461: | $mResult |
462: | ); |
463: | } else { |
464: | $this->removeEventFromSkiped($sEvent); |
465: | } |
466: | } |
467: | |
468: | |
469: | |
470: | |
471: | |
472: | public function skipEvent($sEvent) |
473: | { |
474: | if (!in_array($sEvent, $this->aSkipedEvents)) { |
475: | $this->aSkipedEvents[] = $sEvent; |
476: | } |
477: | } |
478: | |
479: | |
480: | |
481: | |
482: | |
483: | public function removeEventFromSkiped($sEvent) |
484: | { |
485: | $this->aSkipedEvents = array_diff( |
486: | $this->aSkipedEvents, |
487: | array($sEvent) |
488: | ); |
489: | } |
490: | |
491: | |
492: | |
493: | |
494: | |
495: | |
496: | |
497: | public function includeTemplate($sParsedTemplateID, $sParsedPlace, $sTemplateFileName, $sModuleName = '') |
498: | { |
499: | if (0 < strlen($sParsedTemplateID) && 0 < strlen($sParsedPlace) && file_exists($this->GetPath().'/'.$sTemplateFileName)) { |
500: | $this->GetModuleManager()->includeTemplate( |
501: | $sParsedTemplateID, |
502: | $sParsedPlace, |
503: | $this->GetPath().'/'.$sTemplateFileName, |
504: | $sModuleName |
505: | ); |
506: | } |
507: | } |
508: | |
509: | |
510: | |
511: | |
512: | |
513: | |
514: | public function extendObject($sType, $aMap) |
515: | { |
516: | $this->GetModuleManager()->extendObject(self::GetName(), $sType, $aMap); |
517: | } |
518: | |
519: | |
520: | |
521: | |
522: | |
523: | |
524: | public function getExtendedObject($sType) |
525: | { |
526: | return $this->GetModuleManager()->getExtendedObject($sType); |
527: | } |
528: | |
529: | |
530: | |
531: | |
532: | |
533: | |
534: | public function issetObject($sType) |
535: | { |
536: | return $this->GetModuleManager()->issetObject($sType); |
537: | } |
538: | |
539: | |
540: | |
541: | |
542: | final public function SetPath($sPath) |
543: | { |
544: | $this->sPath = $sPath; |
545: | } |
546: | |
547: | |
548: | |
549: | |
550: | final public function GetHash() |
551: | { |
552: | return ''; |
553: | } |
554: | |
555: | |
556: | |
557: | |
558: | final public static function GetName() |
559: | { |
560: | return substr(strrchr(static::getNamespace(), "\\"), 1); |
561: | } |
562: | |
563: | |
564: | |
565: | |
566: | final public function GetPath() |
567: | { |
568: | return $this->sPath; |
569: | } |
570: | |
571: | |
572: | |
573: | |
574: | public function GetVersion() |
575: | { |
576: | return $this->sVersion; |
577: | } |
578: | |
579: | |
580: | |
581: | |
582: | final public function GetFullName() |
583: | { |
584: | return self::GetName().'-'.$this->sVersion; |
585: | } |
586: | |
587: | |
588: | |
589: | |
590: | |
591: | |
592: | final public function AddEntry($sName, $mCallbak) |
593: | { |
594: | \Aurora\System\Router::getInstance()->register( |
595: | self::GetName(), |
596: | $sName, |
597: | [$this, $mCallbak] |
598: | ); |
599: | } |
600: | |
601: | |
602: | |
603: | |
604: | |
605: | final public function AddEntries($aEntries) |
606: | { |
607: | foreach ($aEntries as $sName => $mCallbak) { |
608: | $this->AddEntry($sName, $mCallbak); |
609: | } |
610: | } |
611: | |
612: | |
613: | |
614: | |
615: | |
616: | |
617: | final public function HasEntry($sName) |
618: | { |
619: | return \Aurora\System\Router::getInstance()->hasRoute($sName); |
620: | } |
621: | |
622: | |
623: | |
624: | |
625: | |
626: | final public function RemoveEntry($sName) |
627: | { |
628: | return \Aurora\System\Router::getInstance()->removeRoute($sName); |
629: | } |
630: | |
631: | |
632: | |
633: | |
634: | |
635: | final public function RemoveEntries($aEntries) |
636: | { |
637: | foreach ($aEntries as $sName) { |
638: | $this->RemoveEntry($sName); |
639: | } |
640: | } |
641: | |
642: | |
643: | |
644: | |
645: | |
646: | |
647: | protected function isEntryCallback($mCallbak) |
648: | { |
649: | return \Aurora\System\Router::getInstance()->hasCallback($mCallbak); |
650: | } |
651: | |
652: | |
653: | |
654: | |
655: | |
656: | |
657: | final public function GetEntryCallback($sName) |
658: | { |
659: | return \Aurora\System\Router::getInstance()->getCallback($sName); |
660: | } |
661: | |
662: | |
663: | |
664: | |
665: | |
666: | |
667: | |
668: | final public function DefaultResponse($sMethod, $mResult = false) |
669: | { |
670: | return \Aurora\System\Managers\Response::DefaultResponse(self::GetName(), $sMethod, $mResult); |
671: | } |
672: | |
673: | |
674: | |
675: | |
676: | |
677: | |
678: | final public function TrueResponse($sMethod) |
679: | { |
680: | return $this->DefaultResponse($sMethod, true); |
681: | } |
682: | |
683: | |
684: | |
685: | |
686: | |
687: | |
688: | |
689: | |
690: | |
691: | final public function FalseResponse($sMethod, $iErrorCode = null, $sErrorMessage = null, $aAdditionalParams = null, $sModule = null) |
692: | { |
693: | return \Aurora\System\Managers\Response::FalseResponse($sMethod, $iErrorCode, $sErrorMessage, $aAdditionalParams, $sModule); |
694: | } |
695: | |
696: | |
697: | |
698: | |
699: | |
700: | |
701: | |
702: | |
703: | final public function ExceptionResponse($sActionName, $oException, $aAdditionalParams = null) |
704: | { |
705: | return \Aurora\System\Managers\Response::ExceptionResponse($sActionName, $oException, $aAdditionalParams); |
706: | } |
707: | |
708: | |
709: | |
710: | |
711: | |
712: | |
713: | |
714: | |
715: | protected function prepareMethodArguments($sMethodName, &$aArguments, $bWebApi) |
716: | { |
717: | $aMethodArgs = array(); |
718: | $oReflector = new \ReflectionMethod($this, $sMethodName); |
719: | $aReflectionParameters = $oReflector->getParameters(); |
720: | if ($bWebApi) { |
721: | foreach ($aReflectionParameters as $oParam) { |
722: | $sParamName = $oParam->getName(); |
723: | $iParamPosition = $oParam->getPosition(); |
724: | $bIsArgumentGiven = array_key_exists($sParamName, $aArguments); |
725: | if (!$bIsArgumentGiven && !$oParam->isDefaultValueAvailable()) { |
726: | $aMethodArgs[$iParamPosition] = null; |
727: | } else { |
728: | $aMethodArgs[$iParamPosition] = $bIsArgumentGiven ? |
729: | $aArguments[$sParamName] : $oParam->getDefaultValue(); |
730: | } |
731: | } |
732: | } else { |
733: | $aTempArguments = array(); |
734: | $aMethodArgs = $aArguments; |
735: | foreach ($aReflectionParameters as $oParam) { |
736: | $sParamName = $oParam->getName(); |
737: | $iParamPosition = $oParam->getPosition(); |
738: | $mArgumentValue = null; |
739: | if (isset($aArguments[$iParamPosition])) { |
740: | $mArgumentValue = $aArguments[$iParamPosition]; |
741: | } elseif ($oParam->isDefaultValueAvailable()) { |
742: | $mArgumentValue = $oParam->getDefaultValue(); |
743: | } |
744: | $aTempArguments[$sParamName] = $mArgumentValue; |
745: | } |
746: | $aArguments = $aTempArguments; |
747: | } |
748: | |
749: | return $aMethodArgs; |
750: | } |
751: | |
752: | |
753: | |
754: | |
755: | |
756: | |
757: | protected function isCallbackMethod($sMethod) |
758: | { |
759: | return ($this->isEntryCallback($sMethod) || $this->isEventCallback($sMethod)); |
760: | } |
761: | |
762: | protected function canCallMethod($sMethod, $bWebApi) |
763: | { |
764: | return !($bWebApi && ($this->isCallbackMethod($sMethod) || $this->isDeniedMethodByWebApi($sMethod))) && $this->isAllowedModule(); |
765: | } |
766: | |
767: | |
768: | |
769: | |
770: | |
771: | |
772: | |
773: | |
774: | final public function CallMethod($sMethod, $aArguments = array(), $bWebApi = false) |
775: | { |
776: | $mResult = false; |
777: | try { |
778: | if (!method_exists($this, $sMethod)) { |
779: | throw new \Aurora\System\Exceptions\ApiException( |
780: | \Aurora\System\Notifications::MethodNotFound |
781: | ); |
782: | } elseif (!$this->canCallMethod($sMethod, $bWebApi)) { |
783: | throw new \Aurora\System\Exceptions\ApiException( |
784: | \Aurora\System\Notifications::MethodAccessDenied |
785: | ); |
786: | } else { |
787: | if ($bWebApi && !isset($aArguments['UserId'])) { |
788: | $aArguments['UserId'] = \Aurora\System\Api::getAuthenticatedUserId(); |
789: | } |
790: | |
791: | |
792: | $aMethodArgs = $this->prepareMethodArguments($sMethod, $aArguments, $bWebApi); |
793: | |
794: | $bEventResult = $this->broadcastEvent( |
795: | $sMethod . AbstractModule::$Delimiter . 'before', |
796: | $aArguments, |
797: | $mResult |
798: | ); |
799: | |
800: | |
801: | $aMethodArgs = $this->prepareMethodArguments($sMethod, $aArguments, true); |
802: | |
803: | if (!$bEventResult) { |
804: | try { |
805: | $oReflector = new \ReflectionMethod($this, $sMethod); |
806: | if (!$oReflector->isPublic()) { |
807: | throw new \Aurora\System\Exceptions\ApiException( |
808: | \Aurora\System\Notifications::MethodNotFound |
809: | ); |
810: | } |
811: | $mMethodResult = call_user_func_array( |
812: | array($this, $sMethod), |
813: | $aMethodArgs |
814: | ); |
815: | if (is_array($mMethodResult) && is_array($mResult)) { |
816: | $mResult = array_merge($mMethodResult, $mResult); |
817: | } elseif ($mMethodResult !== null) { |
818: | $mResult = $mMethodResult; |
819: | } |
820: | } catch (\Exception $oException) { |
821: | if ($oException instanceof \Illuminate\Database\QueryException) { |
822: | |
823: | |
824: | |
825: | |
826: | |
827: | Api::LogException($oException); |
828: | $mResult = false; |
829: | } elseif (!($oException instanceof \Aurora\System\Exceptions\ApiException)) { |
830: | throw new \Aurora\System\Exceptions\ApiException( |
831: | $oException->getCode(), |
832: | $oException, |
833: | $oException->getMessage() |
834: | ); |
835: | } else { |
836: | throw $oException; |
837: | } |
838: | |
839: | $this->GetModuleManager()->AddResult( |
840: | self::GetName(), |
841: | $sMethod, |
842: | $aArguments, |
843: | $mResult, |
844: | $oException->getCode() |
845: | ); |
846: | } |
847: | } |
848: | |
849: | $this->broadcastEvent( |
850: | $sMethod . AbstractModule::$Delimiter . 'after', |
851: | $aArguments, |
852: | $mResult |
853: | ); |
854: | |
855: | $this->GetModuleManager()->AddResult( |
856: | self::GetName(), |
857: | $sMethod, |
858: | $aArguments, |
859: | $mResult |
860: | ); |
861: | } |
862: | } catch (\Exception $oException) { |
863: | throw new \Aurora\System\Exceptions\ApiException( |
864: | $oException->getCode(), |
865: | $oException, |
866: | $oException->getMessage(), |
867: | [], |
868: | $this |
869: | ); |
870: | } |
871: | |
872: | return $mResult; |
873: | } |
874: | |
875: | |
876: | |
877: | |
878: | |
879: | |
880: | public function GetSettings() |
881: | { |
882: | return null; |
883: | } |
884: | |
885: | protected function getLangsData($sLang) |
886: | { |
887: | $mResult = false; |
888: | $sLangFile = $this->GetPath().'/i18n/' . $sLang . '.ini'; |
889: | $sLangFile = @\file_exists($sLangFile) ? $sLangFile : ''; |
890: | |
891: | if (0 < \strlen($sLangFile)) { |
892: | $aLang = \Aurora\System\Api::convertIniToLang($sLangFile); |
893: | if (\is_array($aLang)) { |
894: | $mResult = $aLang; |
895: | } |
896: | } |
897: | return $mResult; |
898: | } |
899: | |
900: | |
901: | |
902: | |
903: | |
904: | |
905: | |
906: | |
907: | |
908: | public function i18N($sData, $aParams = null, $iPluralCount = null, $sUUID = null) |
909: | { |
910: | static $sLanguage = null; |
911: | if (is_null($sLanguage)) { |
912: | if ($sUUID) { |
913: | $oCoreDecorator = \Aurora\Modules\Core\Module::Decorator(); |
914: | $oUser = $oCoreDecorator ? $oCoreDecorator->GetUserByUUID($sUUID) : null; |
915: | if ($oUser instanceof \Aurora\Modules\Core\Models\User) { |
916: | $sLanguage = $oUser->Language; |
917: | } |
918: | } |
919: | if (empty($sLanguage)) { |
920: | $sLanguage = \Aurora\System\Api::GetLanguage(); |
921: | } |
922: | } |
923: | |
924: | if (is_null($this->aLang)) { |
925: | if (isset(\Aurora\System\Api::$aClientI18N[self::GetName()][$sLanguage])) { |
926: | $aLang = \Aurora\System\Api::$aClientI18N[self::GetName()][$sLanguage]; |
927: | } else { |
928: | \Aurora\System\Api::$aClientI18N[self::GetName()][$sLanguage] = false; |
929: | |
930: | $this->aLang = $this->getLangsData($sLanguage); |
931: | if (!$this->aLang) { |
932: | $this->aLang = $this->getLangsData('English'); |
933: | } |
934: | |
935: | if (\is_array($this->aLang)) { |
936: | \Aurora\System\Api::$aClientI18N[self::GetName()][$sLanguage] = $this->aLang; |
937: | } |
938: | } |
939: | if (!isset($this->aLang[$sData])) { |
940: | $this->aLang = $this->getLangsData('English'); |
941: | } |
942: | } |
943: | |
944: | return isset($iPluralCount) ? \Aurora\System\Api::processTranslateParams($this->aLang, $sData, $aParams, \Aurora\System\Api::getPlural($sLanguage, $iPluralCount)) : |
945: | \Aurora\System\Api::processTranslateParams($this->aLang, $sData, $aParams); |
946: | } |
947: | |
948: | |
949: | |
950: | |
951: | |
952: | protected function updateEnabledForEntity(&$oEntity, $bEnabled = true) |
953: | { |
954: | if ($bEnabled) { |
955: | $oEntity->enableModule(self::GetName()); |
956: | } else { |
957: | $oEntity->disableModule(self::GetName()); |
958: | } |
959: | } |
960: | |
961: | |
962: | |
963: | |
964: | |
965: | |
966: | protected function isEnabledForEntity(&$oEntity) |
967: | { |
968: | return !$oEntity->isModuleDisabled(self::GetName()); |
969: | } |
970: | |
971: | |
972: | |
973: | |
974: | |
975: | public function GetErrors() |
976: | { |
977: | return is_array($this->aErrors) ? (object) $this->aErrors : []; |
978: | } |
979: | |
980: | |
981: | |
982: | |
983: | |
984: | public function GetErrorMessageByCode($iErrorCode) |
985: | { |
986: | return is_array($this->aErrors) && isset($this->aErrors[(int) $iErrorCode]) ? $this->aErrors[(int) $iErrorCode] : ''; |
987: | } |
988: | |
989: | |
990: | |
991: | |
992: | |
993: | public function GetAdditionalEntityFieldsToEdit() |
994: | { |
995: | return is_array($this->aAdditionalEntityFieldsToEdit) ? $this->aAdditionalEntityFieldsToEdit : []; |
996: | } |
997: | } |
998: | |