| Total Complexity | 81 |
| Total Lines | 819 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 0 |
Complex classes like AssetProvider often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use AssetProvider, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 31 | class AssetProvider implements ServiceProviderInterface |
||
| 32 | { |
||
| 33 | public const SERVICE_NAME = 'assets'; |
||
| 34 | |||
| 35 | private Collection $headerCollectionJSForExtensions; |
||
| 36 | private Collection $footerCollectionJSForExtensions; |
||
| 37 | private Collection $headerCollectionJS; |
||
| 38 | private Collection $headerCollectionCSS; |
||
| 39 | private Collection $footerCollectionJS; |
||
| 40 | private Collection $semanticCollectionCSS; |
||
| 41 | private Collection $semanticCollectionJS; |
||
| 42 | private Collection $footerCollectionACE; |
||
| 43 | private Collection $footerCollectionLoc; |
||
| 44 | private Collection $headerCollectionSentryJS; |
||
| 45 | private string $cssCacheDir; |
||
| 46 | private string $jsCacheDir; |
||
| 47 | private Manager $manager; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Registers assets service provider |
||
| 51 | * |
||
| 52 | * @param \Phalcon\Di\DiInterface $di |
||
| 53 | */ |
||
| 54 | public function register(DiInterface $di): void |
||
| 55 | { |
||
| 56 | $di->set( |
||
| 57 | self::SERVICE_NAME, |
||
| 58 | function () use ($di) { |
||
| 59 | $session = $di->get('session'); |
||
| 60 | if ($session !== null && $session->has('versionHash')) { |
||
| 61 | $version = (string)$session->get('versionHash'); |
||
| 62 | } else { |
||
| 63 | $version = str_replace(PHP_EOL, '', file_get_contents('/etc/version')); |
||
| 64 | } |
||
| 65 | |||
| 66 | $assets = new AssetProvider(); |
||
| 67 | $assets->initializeClassVariables($version); |
||
| 68 | $dispatcher = $di->get('dispatcher'); |
||
| 69 | $controller = $dispatcher->getControllerName(); |
||
| 70 | $action = $dispatcher->getActionName(); |
||
| 71 | $moduleName = $dispatcher->getModuleName(); |
||
| 72 | |||
| 73 | if ($action === null) { |
||
| 74 | $action = 'index'; |
||
| 75 | } |
||
| 76 | |||
| 77 | $assets->makeSentryAssets(); |
||
| 78 | $assets->makeHeaderAssets($session, $moduleName); |
||
| 79 | |||
| 80 | // Generates Controllers assets |
||
| 81 | $method_name = "make{$controller}Assets"; |
||
| 82 | if (method_exists($assets, $method_name)) { |
||
| 83 | $assets->$method_name($action); |
||
| 84 | } |
||
| 85 | |||
| 86 | $assets->makeFooterAssets(); |
||
| 87 | $assets->makeLocalizationAssets($di, $version); |
||
| 88 | |||
| 89 | return $assets->manager; |
||
| 90 | } |
||
| 91 | ); |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Initialize class variables |
||
| 96 | */ |
||
| 97 | public function initializeClassVariables(string $version) |
||
| 98 | { |
||
| 99 | $this->manager = new Manager(); |
||
| 100 | $this->manager->setVersion($version); |
||
| 101 | |||
| 102 | $this->cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache'); |
||
| 103 | $this->jsCacheDir = appPath('sites/admin-cabinet/assets/js/cache'); |
||
| 104 | |||
| 105 | $this->headerCollectionJSForExtensions = $this->manager->collection('headerJS'); |
||
| 106 | $this->headerCollectionJSForExtensions->setPrefix('assets/'); |
||
| 107 | $this->footerCollectionJSForExtensions = $this->manager->collection('footerJS'); |
||
| 108 | $this->footerCollectionJSForExtensions->setPrefix('assets/'); |
||
| 109 | $this->headerCollectionJS = $this->manager->collection('headerPBXJS'); |
||
| 110 | $this->headerCollectionJS->setPrefix('assets/'); |
||
| 111 | $this->headerCollectionCSS = $this->manager->collection('headerCSS'); |
||
| 112 | $this->headerCollectionCSS->setPrefix('assets/'); |
||
| 113 | $this->footerCollectionJS = $this->manager->collection('footerPBXJS'); |
||
| 114 | $this->footerCollectionJS->setPrefix('assets/'); |
||
| 115 | $this->headerCollectionSentryJS = $this->manager->collection('headerSentryJS'); |
||
| 116 | $this->semanticCollectionCSS = $this->manager->collection('SemanticUICSS'); |
||
| 117 | $this->semanticCollectionCSS->setPrefix('assets/'); |
||
| 118 | $this->semanticCollectionJS = $this->manager->collection('SemanticUIJS'); |
||
| 119 | $this->semanticCollectionJS->setPrefix('assets/'); |
||
| 120 | $this->footerCollectionACE = $this->manager->collection('footerACE'); |
||
| 121 | $this->footerCollectionACE->setPrefix('assets/'); |
||
| 122 | $this->footerCollectionLoc = $this->manager->collection('footerLoc'); |
||
| 123 | $this->footerCollectionLoc->setPrefix('assets/'); |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * Makes assets for the Sentry error logger |
||
| 128 | * |
||
| 129 | */ |
||
| 130 | private function makeSentryAssets(): void |
||
| 131 | { |
||
| 132 | if (file_exists('/tmp/sendmetrics')) { |
||
| 133 | $this->headerCollectionSentryJS->addjs( |
||
| 134 | 'assets/js/vendor/sentry/bundle.min.js', |
||
| 135 | true |
||
| 136 | ); |
||
| 137 | $this->headerCollectionSentryJS->addJs( |
||
| 138 | "assets/js/pbx/main/sentry-error-logger.js", |
||
| 139 | true |
||
| 140 | ); |
||
| 141 | } |
||
| 142 | } |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Makes assets for all controllers. Base set of scripts and styles |
||
| 146 | * |
||
| 147 | * @param $session |
||
| 148 | * @param $moduleName |
||
| 149 | */ |
||
| 150 | private function makeHeaderAssets($session, $moduleName): void |
||
| 264 | ); |
||
| 265 | } |
||
| 266 | } |
||
| 267 | } |
||
| 268 | |||
| 269 | /** |
||
| 270 | * Makes footer assets |
||
| 271 | */ |
||
| 272 | private function makeFooterAssets(): void |
||
| 273 | { |
||
| 274 | $this->headerCollectionCSS |
||
| 275 | ->addCss('css/custom.css', true); |
||
| 276 | |||
| 277 | $this->footerCollectionJS->addJs( |
||
| 278 | 'js/pbx/main/footer.js', |
||
| 279 | true |
||
| 280 | ); |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * Makes Language cache for browser JS scripts |
||
| 285 | * |
||
| 286 | * @param \Phalcon\Di\DiInterface $di |
||
| 287 | * @param string $version |
||
| 288 | */ |
||
| 289 | private function makeLocalizationAssets(DiInterface $di, string $version): void |
||
| 290 | { |
||
| 291 | $language = $di->getShared('language'); |
||
| 292 | $fileName = "{$this->jsCacheDir}/localization-{$language}-{$version}.min.js"; |
||
| 293 | if ( ! file_exists($fileName)) { |
||
| 294 | $arrStr = []; |
||
| 295 | foreach ($di->getShared('messages') as $key => $value) { |
||
| 296 | $arrStr[$key] = str_replace( |
||
| 297 | "'", |
||
| 298 | "\\'", |
||
| 299 | str_replace(["\n", ' '], '', $value) |
||
| 300 | ); |
||
| 301 | } |
||
| 302 | $scriptArray = json_encode($arrStr); |
||
| 303 | file_put_contents($fileName, "globalTranslate = {$scriptArray}"); |
||
| 304 | } |
||
| 305 | |||
| 306 | $langJSFile = "js/cache/localization-{$language}-{$version}.min.js"; |
||
| 307 | $this->footerCollectionLoc->addJs($langJSFile, true); |
||
| 308 | } |
||
| 309 | |||
| 310 | /** |
||
| 311 | * Makes assets for the CallQueues controller |
||
| 312 | * |
||
| 313 | * @param string $action |
||
| 314 | */ |
||
| 315 | private function makeCallQueuesAssets(string $action) |
||
| 316 | { |
||
| 317 | if ($action === 'index') { |
||
| 318 | $this->headerCollectionCSS |
||
| 319 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 320 | $this->footerCollectionJS |
||
| 321 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 322 | ->addJs('js/pbx/CallQueues/callqueues-index.js', true); |
||
| 323 | } elseif ($action === 'modify') { |
||
| 324 | $this->footerCollectionJS |
||
| 325 | ->addJs('js/vendor/jquery.debounce-1.0.5.js', true) |
||
| 326 | ->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 327 | ->addJs('js/pbx/main/form.js', true) |
||
| 328 | ->addJs('js/pbx/CallQueues/callqueue-modify.js', true) |
||
| 329 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 330 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); |
||
| 331 | } |
||
| 332 | } |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Makes assets for the ConferenceRooms controller |
||
| 336 | * |
||
| 337 | * @param string $action |
||
| 338 | */ |
||
| 339 | private function makeConferenceRoomsAssets(string $action) |
||
| 340 | { |
||
| 341 | if ($action === 'index') { |
||
| 342 | $this->footerCollectionJS |
||
| 343 | ->addJs('js/pbx/ConferenceRooms/conference-rooms-index.js', true); |
||
| 344 | } elseif ($action === 'modify') { |
||
| 345 | $this->footerCollectionJS |
||
| 346 | ->addJs('js/pbx/main/form.js', true) |
||
| 347 | ->addJs('js/pbx/ConferenceRooms/conference-room-modify.js', true); |
||
| 348 | } |
||
| 349 | } |
||
| 350 | |||
| 351 | /** |
||
| 352 | * Makes assets for the SystemDiagnostic controller |
||
| 353 | * |
||
| 354 | * @param string $action |
||
| 355 | */ |
||
| 356 | private function makeSystemDiagnosticAssets(string $action): void |
||
| 357 | { |
||
| 358 | if ($action === 'index') { |
||
| 359 | $this->footerCollectionJS |
||
| 360 | ->addJs('js/vendor/semantic/popup.min.js', true) |
||
| 361 | ->addJs('js/vendor/semantic/dropdown.min.js', true) |
||
| 362 | ->addJs('js/pbx/main/form.js', true) |
||
| 363 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index.js', true) |
||
| 364 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-showlogs.js', true) |
||
| 365 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-sysinfo.js', true) |
||
| 366 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-logcapture.js', true); |
||
| 367 | $this->footerCollectionACE |
||
| 368 | ->addJs('js/vendor/ace/ace.js', true) |
||
| 369 | ->addJs('js/vendor/ace/mode-julia.js', true); |
||
| 370 | } |
||
| 371 | } |
||
| 372 | |||
| 373 | /** |
||
| 374 | * Makes assets for the SoundFiles controller |
||
| 375 | * |
||
| 376 | * @param string $action |
||
| 377 | */ |
||
| 378 | private function makeSoundFilesAssets(string $action): void |
||
| 379 | { |
||
| 380 | if ($action === 'index') { |
||
| 381 | $this->headerCollectionCSS |
||
| 382 | ->addCss('css/vendor/range/range.css') |
||
| 383 | ->addCss( |
||
| 384 | 'css/vendor/datatable/dataTables.semanticui.css', |
||
| 385 | true |
||
| 386 | ); |
||
| 387 | $this->footerCollectionJS->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 388 | ->addJs('js/vendor/range/range.min.js', true) |
||
| 389 | ->addJs('js/vendor/jquery.address.min.js', true) |
||
| 390 | ->addJs('js/pbx/SoundFiles/sound-files-index-player.js', true) |
||
| 391 | ->addJs('js/pbx/SoundFiles/sound-files-index.js', true); |
||
| 392 | } elseif ($action === 'modify') { |
||
| 393 | $this->headerCollectionCSS->addCss('css/vendor/range/range.css'); |
||
| 394 | |||
| 395 | $this->headerCollectionJS |
||
| 396 | ->addJs( |
||
| 397 | 'js/vendor/webrtc/MediaStreamRecorder.min.js', |
||
| 398 | true |
||
| 399 | ) |
||
| 400 | ->addJs('js/vendor/webrtc/adapter-latest.min.js', true); |
||
| 401 | |||
| 402 | $this->footerCollectionJS |
||
| 403 | ->addJs('js/vendor/range/range.min.js', true) |
||
| 404 | ->addJs('js/pbx/main/form.js', true) |
||
| 405 | ->addJs('js/vendor/resumable.js', true) |
||
| 406 | ->addJs('js/pbx/SoundFiles/sound-file-modify-player.js', true) |
||
| 407 | ->addJs('js/pbx/SoundFiles/sound-file-modify-upload-worker.js', true) |
||
| 408 | ->addJs('js/pbx/SoundFiles/sound-file-modify-webkit-recorder.js', true) |
||
| 409 | ->addJs('js/pbx/SoundFiles/sound-file-modify.js', true); |
||
| 410 | } |
||
| 411 | } |
||
| 412 | |||
| 413 | /** |
||
| 414 | * Makes assets for the TimeSettings controller |
||
| 415 | * |
||
| 416 | * @param string $action |
||
| 417 | */ |
||
| 418 | private function makeTimeSettingsAssets(string $action): void |
||
| 419 | { |
||
| 420 | if ($action === 'modify') { |
||
| 421 | $this->footerCollectionJS |
||
| 422 | ->addJs('js/pbx/main/form.js', true) |
||
| 423 | ->addJs('js/vendor/moment/moment-with-locales.min.js',true) |
||
| 424 | ->addJs('js/vendor/moment/moment-timezone-with-data.js', true) |
||
| 425 | ->addJs('js/pbx/TimeSettings/time-settings-worker.js', true) |
||
| 426 | ->addJs('js/pbx/TimeSettings/time-settings-modify.js', true); |
||
| 427 | } |
||
| 428 | } |
||
| 429 | |||
| 430 | /** |
||
| 431 | * Makes assets for the Update controller |
||
| 432 | * |
||
| 433 | * @param string $action |
||
| 434 | */ |
||
| 435 | private function makeUpdateAssets(string $action): void |
||
| 436 | { |
||
| 437 | if ($action === 'index') { |
||
| 438 | $this->footerCollectionJS |
||
| 439 | ->addJs('js/pbx/main/version-compare.js', true) |
||
| 440 | ->addJs('js/pbx/main/form.js', true) |
||
| 441 | ->addJs('js/vendor/resumable.js', true) |
||
| 442 | ->addJs('js/vendor/showdown/showdown.min.js', true) |
||
| 443 | ->addJs('js/pbx/Update/update-index.js', true); |
||
| 444 | $this->semanticCollectionCSS |
||
| 445 | ->addCss('css/vendor/semantic/progress.min.css', true) |
||
| 446 | ->addCss('css/vendor/semantic/modal.min.css', true); |
||
| 447 | |||
| 448 | $this->semanticCollectionJS |
||
| 449 | ->addJs('js/vendor/semantic/progress.min.js', true) |
||
| 450 | ->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 451 | } |
||
| 452 | } |
||
| 453 | |||
| 454 | /** |
||
| 455 | * Makes assets for the Session controller |
||
| 456 | * |
||
| 457 | * @param string $action |
||
| 458 | */ |
||
| 459 | private function makeSessionAssets(string $action): void |
||
| 460 | { |
||
| 461 | if ($action === 'index') { |
||
| 462 | $this->footerCollectionJS |
||
| 463 | ->addJs('js/pbx/main/form.js', true) |
||
| 464 | ->addJs('js/pbx/Session/login-form.js', true); |
||
| 465 | } |
||
| 466 | } |
||
| 467 | |||
| 468 | /** |
||
| 469 | * Makes assets for the Restart controller |
||
| 470 | * |
||
| 471 | * @param string $action |
||
| 472 | */ |
||
| 473 | private function makeRestartAssets(string $action): void |
||
| 474 | { |
||
| 475 | if ($action === 'index') { |
||
| 476 | $this->footerCollectionJS |
||
| 477 | ->addJs('js/pbx/Restart/restart-index.js', true); |
||
| 478 | } |
||
| 479 | } |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Makes assets for the Providers controller |
||
| 483 | * |
||
| 484 | * @param string $action |
||
| 485 | */ |
||
| 486 | private function makeProvidersAssets(string $action): void |
||
| 487 | { |
||
| 488 | if ($action === 'index') { |
||
| 489 | $this->semanticCollectionCSS |
||
| 490 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true) |
||
| 491 | ->addCss('css/vendor/semantic/modal.min.css', true); |
||
| 492 | |||
| 493 | $this->semanticCollectionJS |
||
| 494 | ->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 495 | $this->footerCollectionJS |
||
| 496 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 497 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 498 | ->addJs('js/pbx/Providers/providers-index.js', true); |
||
| 499 | } elseif ($action === 'modifysip' || $action === 'modifyiax') { |
||
| 500 | $this->footerCollectionJS |
||
| 501 | ->addJs('js/pbx/main/form.js', true) |
||
| 502 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 503 | ->addJs('js/pbx/Providers/provider-modify-status-worker.js', true) |
||
| 504 | ->addJs('js/pbx/Providers/provider-modify.js', true); |
||
| 505 | } |
||
| 506 | } |
||
| 507 | |||
| 508 | /** |
||
| 509 | * Makes assets for the PbxExtensionModules controller |
||
| 510 | * |
||
| 511 | * @param string $action |
||
| 512 | */ |
||
| 513 | private function makePbxExtensionModulesAssets(string $action): void |
||
| 514 | { |
||
| 515 | if ($action === 'index') { |
||
| 516 | $this->semanticCollectionJS->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 517 | $this->footerCollectionJS |
||
| 518 | ->addJs('js/pbx/Update/update-api.js', true) |
||
| 519 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 520 | ->addJs('js/vendor/resumable.js', true) |
||
| 521 | ->addJs( |
||
| 522 | 'js/pbx/PbxExtensionModules/pbx-extension-module-upgrade-status-worker.js', |
||
| 523 | true |
||
| 524 | ) |
||
| 525 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-status.js', true) |
||
| 526 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-modules-index.js', true) |
||
| 527 | ->addJs('js/vendor/semantic/progress.min.js', true) |
||
| 528 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-add-new.js', true); |
||
| 529 | $this->semanticCollectionCSS |
||
| 530 | ->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true) |
||
| 531 | ->addCss('css/vendor/semantic/modal.min.css', true) |
||
| 532 | ->addCss('css/vendor/semantic/progress.min.css', true); |
||
| 533 | } elseif ($action === 'modify') { |
||
| 534 | $this->footerCollectionJS |
||
| 535 | ->addJs('js/pbx/main/form.js', true) |
||
| 536 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-modify.js', true); |
||
| 537 | } |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Makes assets for the OutOffWorkTime controller |
||
| 542 | * |
||
| 543 | * @param string $action |
||
| 544 | */ |
||
| 545 | private function makeOutOffWorkTimeAssets(string $action): void |
||
| 546 | { |
||
| 547 | if ($action === 'index') { |
||
| 548 | $this->footerCollectionJS |
||
| 549 | ->addJs('js/pbx/OutOffWorkTime/out-of-work-times-index.js', true); |
||
| 550 | } elseif ($action === 'modify') { |
||
| 551 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/calendar.min.css', true); |
||
| 552 | $this->semanticCollectionJS->addJs('js/vendor/semantic/calendar.min.js', true); |
||
| 553 | $this->footerCollectionJS |
||
| 554 | ->addJs('js/pbx/main/form.js', true) |
||
| 555 | ->addJs('js/pbx/OutOffWorkTime/out-of-work-time-modify.js', true) |
||
| 556 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 557 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); |
||
| 558 | } |
||
| 559 | } |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Makes assets for the OutboundRoutes controller |
||
| 563 | * |
||
| 564 | * @param string $action |
||
| 565 | */ |
||
| 566 | private function makeOutboundRoutesAssets(string $action): void |
||
| 567 | { |
||
| 568 | if ($action === 'index') { |
||
| 569 | $this->footerCollectionJS |
||
| 570 | ->addJs('js/vendor/jquery.tablednd.min.js', true) |
||
| 571 | ->addJs('js/pbx/OutboundRoutes/outbound-routes-index.js', true); |
||
| 572 | } elseif ($action === 'modify') { |
||
| 573 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 574 | ->addJs('js/pbx/OutboundRoutes/outbound-route-modify.js', true); |
||
| 575 | } |
||
| 576 | } |
||
| 577 | |||
| 578 | /** |
||
| 579 | * Makes assets for the Network controller |
||
| 580 | * |
||
| 581 | * @param string $action |
||
| 582 | */ |
||
| 583 | private function makeNetworkAssets(string $action): void |
||
| 584 | { |
||
| 585 | if ($action === 'modify') { |
||
| 586 | $this->footerCollectionJS |
||
| 587 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 588 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 589 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 590 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 591 | ->addJs('js/pbx/main/form.js', true) |
||
| 592 | ->addJs('js/pbx/Network/network-modify.js', true); |
||
| 593 | } |
||
| 594 | } |
||
| 595 | |||
| 596 | /** |
||
| 597 | * Makes assets for the MailSettings controller |
||
| 598 | * |
||
| 599 | * @param string $action |
||
| 600 | */ |
||
| 601 | private function makeMailSettingsAssets(string $action): void |
||
| 602 | { |
||
| 603 | if ($action === 'modify') { |
||
| 604 | $this->footerCollectionJS |
||
| 605 | ->addJs('js/pbx/main/form.js', true) |
||
| 606 | ->addJs('js/pbx/MailSettings/mail-settings-modify.js', true); |
||
| 607 | } |
||
| 608 | } |
||
| 609 | |||
| 610 | /** |
||
| 611 | * Makes assets for the Licensing controller |
||
| 612 | * |
||
| 613 | * @param string $action |
||
| 614 | */ |
||
| 615 | private function makeLicensingAssets(string $action): void |
||
| 616 | { |
||
| 617 | if ($action === 'modify') { |
||
| 618 | $this->footerCollectionJS |
||
| 619 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 620 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 621 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 622 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 623 | ->addJs('js/pbx/main/form.js', true) |
||
| 624 | ->addJs('js/pbx/Licensing/licensing-modify.js', true); |
||
| 625 | } |
||
| 626 | } |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Makes assets for the IvrMenu controller |
||
| 630 | * |
||
| 631 | * @param string $action |
||
| 632 | */ |
||
| 633 | private function makeIvrMenuAssets(string $action): void |
||
| 634 | { |
||
| 635 | if ($action === 'index') { |
||
| 636 | $this->headerCollectionCSS |
||
| 637 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 638 | $this->footerCollectionJS |
||
| 639 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 640 | ->addJs('js/pbx/IvrMenu/ivrmenu-index.js', true); |
||
| 641 | } elseif ($action === 'modify') { |
||
| 642 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 643 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 644 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true) |
||
| 645 | ->addJs('js/pbx/IvrMenu/ivrmenu-modify.js', true); |
||
| 646 | } |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Makes assets for the IncomingRoutes controller |
||
| 651 | * |
||
| 652 | * @param string $action |
||
| 653 | */ |
||
| 654 | private function makeIncomingRoutesAssets(string $action): void |
||
| 655 | { |
||
| 656 | if ($action === 'index') { |
||
| 657 | $this->footerCollectionJS->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 658 | ->addJs('js/pbx/main/form.js', true) |
||
| 659 | ->addJs('js/pbx/IncomingRoutes/incoming-route-index.js', true); |
||
| 660 | } elseif ($action === 'modify') { |
||
| 661 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 662 | ->addJs('js/pbx/IncomingRoutes/incoming-route-modify.js', true); |
||
| 663 | } |
||
| 664 | } |
||
| 665 | |||
| 666 | /** |
||
| 667 | * Makes assets for the GeneralSettings controller |
||
| 668 | * |
||
| 669 | * @param string $action |
||
| 670 | */ |
||
| 671 | private function makeGeneralSettingsAssets(string $action): void |
||
| 672 | { |
||
| 673 | if ($action === 'modify') { |
||
| 674 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/progress.min.css', true); |
||
| 675 | $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); |
||
| 676 | $this->footerCollectionJS |
||
| 677 | ->addJs('js/vendor/jquery.address.min.js', true) |
||
| 678 | ->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 679 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 680 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true) |
||
| 681 | ->addJs('js/pbx/main/form.js', true) |
||
| 682 | ->addJs('js/pbx/main/password-score.js', true) |
||
| 683 | ->addJs( |
||
| 684 | 'js/pbx/GeneralSettings/general-settings-modify.js', |
||
| 685 | true |
||
| 686 | ); |
||
| 687 | } |
||
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * Makes assets for the Firewall controller |
||
| 692 | * |
||
| 693 | * @param string $action |
||
| 694 | */ |
||
| 695 | private function makeFirewallAssets(string $action): void |
||
| 696 | { |
||
| 697 | if ($action === 'index') { |
||
| 698 | $this->footerCollectionJS |
||
| 699 | ->addJs('js/pbx/Firewall/firewall-index.js', true); |
||
| 700 | } elseif ($action === 'modify') { |
||
| 701 | $this->footerCollectionJS |
||
| 702 | ->addJs('js/pbx/main/form.js', true) |
||
| 703 | ->addJs('js/pbx/Firewall/firewall-modify.js', true); |
||
| 704 | } |
||
| 705 | } |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Makes assets for the Fail2Ban controller |
||
| 709 | * |
||
| 710 | * @param string $action |
||
| 711 | */ |
||
| 712 | private function makeFail2BanAssets(string $action): void |
||
| 713 | { |
||
| 714 | if ($action === 'index') { |
||
| 715 | $this->footerCollectionJS |
||
| 716 | ->addJs('js/pbx/main/form.js', true) |
||
| 717 | ->addJs('js/pbx/Fail2Ban/fail-to-ban-index.js', true); |
||
| 718 | } |
||
| 719 | } |
||
| 720 | |||
| 721 | /** |
||
| 722 | * Makes assets for the Extensions controller |
||
| 723 | * |
||
| 724 | * @param string $action |
||
| 725 | */ |
||
| 726 | private function makeExtensionsAssets(string $action): void |
||
| 727 | { |
||
| 728 | if ($action === 'index') { |
||
| 729 | $this->headerCollectionCSS->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true); |
||
| 730 | |||
| 731 | $this->footerCollectionJS |
||
| 732 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 733 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 734 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 735 | ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) |
||
| 736 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 737 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 738 | ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) |
||
| 739 | ->addJs('js/pbx/Extensions/extensions-index.js', true) |
||
| 740 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 741 | ->addJs('js/vendor/clipboard/clipboard.js', true); |
||
| 742 | } elseif ($action === 'modify') { |
||
| 743 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/card.min.css', true); |
||
| 744 | $this->footerCollectionJS |
||
| 745 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 746 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 747 | ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) |
||
| 748 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 749 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 750 | ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) |
||
| 751 | ->addJs('js/pbx/main/form.js', true) |
||
| 752 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 753 | ->addJs('js/pbx/Extensions/extension-modify.js', true); |
||
| 754 | } |
||
| 755 | } |
||
| 756 | |||
| 757 | /** |
||
| 758 | * Makes assets for the DialplanApplications controller |
||
| 759 | * |
||
| 760 | * @param string $action |
||
| 761 | */ |
||
| 762 | private function makeDialplanApplicationsAssets(string $action): void |
||
| 763 | { |
||
| 764 | if ($action === 'index') { |
||
| 765 | $this->headerCollectionCSS |
||
| 766 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 767 | $this->footerCollectionJS |
||
| 768 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 769 | ->addJs('js/pbx/DialplanApplications/dialplan-applications-index.js', true); |
||
| 770 | } elseif ($action === 'modify') { |
||
| 771 | $this->footerCollectionACE |
||
| 772 | ->addJs('js/vendor/ace/ace.js', true) |
||
| 773 | ->addJs('js/vendor/ace/mode-php.js', true) |
||
| 774 | ->addJs('js/vendor/ace/mode-julia.js', true); |
||
| 775 | $this->footerCollectionJS |
||
| 776 | ->addJs('js/pbx/main/form.js', true) |
||
| 777 | ->addJs('js/pbx/DialplanApplications/dialplan-applications-modify.js', true); |
||
| 778 | } |
||
| 779 | } |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Makes assets for the CustomFiles controller |
||
| 783 | * |
||
| 784 | * @param string $action |
||
| 785 | */ |
||
| 786 | private function makeCustomFilesAssets(string $action): void |
||
| 801 | } |
||
| 802 | } |
||
| 803 | |||
| 804 | /** |
||
| 805 | * Makes assets for the CallDetailRecords controller |
||
| 806 | * |
||
| 807 | * @param string $action |
||
| 808 | */ |
||
| 809 | private function makeCallDetailRecordsAssets(string $action): void |
||
| 810 | { |
||
| 811 | if ($action === 'index') { |
||
| 812 | $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); |
||
| 813 | |||
| 814 | $this->semanticCollectionCSS |
||
| 815 | ->addCss('css/vendor/range/range.min.css', true) |
||
| 816 | ->addCss('css/vendor/datatable/scroller.dataTables.min.css', true) |
||
| 817 | ->addCss('css/vendor/datepicker/daterangepicker.css', true) |
||
| 833 | ); |
||
| 834 | } |
||
| 835 | } |
||
| 836 | |||
| 837 | /** |
||
| 838 | * Makes assets for the AsteriskManagers controller |
||
| 839 | * |
||
| 840 | * @param string $action |
||
| 841 | */ |
||
| 842 | private function makeAsteriskManagersAssets(string $action): void |
||
| 850 | } |
||
| 851 | } |
||
| 852 | |||
| 853 | |||
| 854 | } |