| Total Complexity | 90 |
| Total Lines | 889 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| 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 |
||
| 32 | class AssetProvider implements ServiceProviderInterface |
||
| 33 | { |
||
| 34 | public const SERVICE_NAME = 'assets'; |
||
| 35 | |||
| 36 | private Collection $headerCollectionJSForExtensions; |
||
| 37 | private Collection $footerCollectionJSForExtensions; |
||
| 38 | private Collection $headerCollectionJS; |
||
| 39 | private Collection $headerCollectionCSS; |
||
| 40 | private Collection $footerCollectionJS; |
||
| 41 | private Collection $semanticCollectionCSS; |
||
| 42 | private Collection $semanticCollectionJS; |
||
| 43 | private Collection $footerCollectionACE; |
||
| 44 | private Collection $footerCollectionLoc; |
||
| 45 | private Collection $headerCollectionSentryJS; |
||
| 46 | private string $cssCacheDir; |
||
| 47 | private string $jsCacheDir; |
||
| 48 | private Manager $manager; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Registers assets service provider |
||
| 52 | * |
||
| 53 | * @param \Phalcon\Di\DiInterface $di |
||
| 54 | */ |
||
| 55 | public function register(DiInterface $di): void |
||
| 56 | { |
||
| 57 | $di->set( |
||
| 58 | self::SERVICE_NAME, |
||
| 59 | function () use ($di) { |
||
| 60 | $assets = new AssetProvider(); |
||
| 61 | $assets->initializeClassVariables(); |
||
| 62 | $dispatcher = $di->get('dispatcher'); |
||
| 63 | $session = $di->get('session'); |
||
| 64 | $controller = $dispatcher->getControllerName(); |
||
| 65 | $action = $dispatcher->getActionName(); |
||
| 66 | $moduleName = $dispatcher->getModuleName(); |
||
| 67 | |||
| 68 | if ($action === null) { |
||
| 69 | $action = 'index'; |
||
| 70 | } |
||
| 71 | if ($session !== null && $session->has('versionHash')) { |
||
| 72 | $version = (string)$session->get('versionHash'); |
||
| 73 | } else { |
||
| 74 | $version = str_replace(PHP_EOL, '', file_get_contents('/etc/version')); |
||
| 75 | } |
||
| 76 | |||
| 77 | $assets->makeSentryAssets($version); |
||
| 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 | $assets->generateFilesAndLinks($controller, $action, $version); |
||
| 89 | |||
| 90 | return $assets->manager; |
||
| 91 | } |
||
| 92 | ); |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Initialize class variables |
||
| 97 | */ |
||
| 98 | public function initializeClassVariables() |
||
| 99 | { |
||
| 100 | $this->manager = new Manager(); |
||
| 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 | * @param string $version |
||
| 130 | */ |
||
| 131 | private function makeSentryAssets(string $version): void |
||
| 132 | { |
||
| 133 | if (file_exists('/tmp/sendmetrics')) { |
||
| 134 | $this->headerCollectionSentryJS->addjs( |
||
| 135 | 'assets/js/vendor/sentry/bundle.min.js', |
||
| 136 | true |
||
| 137 | ); |
||
| 138 | $this->headerCollectionSentryJS->addJs( |
||
| 139 | "assets/js/pbx/main/sentry-error-logger.js?v={$version}", |
||
| 140 | true |
||
| 141 | ); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Makes assets for all controllers. Base set of scripts and styles |
||
| 147 | * |
||
| 148 | * @param $session |
||
| 149 | * @param $moduleName |
||
| 150 | */ |
||
| 151 | private function makeHeaderAssets($session, $moduleName): void |
||
| 265 | ); |
||
| 266 | } |
||
| 267 | } |
||
| 268 | } |
||
| 269 | |||
| 270 | /** |
||
| 271 | * Makes footer assets |
||
| 272 | */ |
||
| 273 | private function makeFooterAssets(): void |
||
| 274 | { |
||
| 275 | $this->headerCollectionCSS |
||
| 276 | ->addCss('css/custom.css', true); |
||
| 277 | |||
| 278 | $this->footerCollectionJS->addJs( |
||
| 279 | 'js/pbx/main/footer.js', |
||
| 280 | true |
||
| 281 | ); |
||
| 282 | } |
||
| 283 | |||
| 284 | /** |
||
| 285 | * Makes Language cache for browser JS scripts |
||
| 286 | * |
||
| 287 | * @param \Phalcon\Di\DiInterface $di |
||
| 288 | * @param string $version |
||
| 289 | */ |
||
| 290 | private function makeLocalizationAssets(DiInterface $di, string $version): void |
||
| 311 | } |
||
| 312 | |||
| 313 | /** |
||
| 314 | * Makes caches and versioned links for scripts and styles |
||
| 315 | * |
||
| 316 | * @param $controller |
||
| 317 | * @param string $action |
||
| 318 | * @param string $version |
||
| 319 | */ |
||
| 320 | private function generateFilesAndLinks($controller, string $action, string $version): void |
||
| 321 | { |
||
| 322 | //$resultCombinedName = Text::uncamelize(ucfirst($controller) . ucfirst($action), '-'); |
||
| 323 | //$resultCombinedName = strlen($resultCombinedName) !== '' ? $resultCombinedName . '-' : ''; |
||
| 324 | |||
| 325 | |||
| 326 | foreach ($this->headerCollectionJS as $resource) { |
||
| 327 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 328 | } |
||
| 329 | foreach ($this->footerCollectionJS as $resource) { |
||
| 330 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 331 | } |
||
| 332 | foreach ($this->semanticCollectionJS as $resource) { |
||
| 333 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 334 | } |
||
| 335 | foreach ($this->semanticCollectionCSS as $resource) { |
||
| 336 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 337 | } |
||
| 338 | foreach ($this->footerCollectionACE as $resource) { |
||
| 339 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 340 | } |
||
| 341 | foreach ($this->headerCollectionCSS as $resource) { |
||
| 342 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 343 | } |
||
| 344 | foreach ($this->headerCollectionJSForExtensions as $resource) { |
||
| 345 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 346 | } |
||
| 347 | foreach ($this->footerCollectionJSForExtensions as $resource) { |
||
| 348 | $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 349 | } |
||
| 350 | |||
| 351 | // $this->headerCollectionCSS->join(true); |
||
| 352 | // $this->headerCollectionCSS->setTargetPath("{$this->cssCacheDir}/{$resultCombinedName}header.min.css"); |
||
| 353 | // $this->headerCollectionCSS->setTargetUri("css/cache/{$resultCombinedName}header.min.css?v={$version}"); |
||
| 354 | |||
| 355 | // $this->headerCollectionJSForExtensions->join(true); |
||
| 356 | // $this->headerCollectionJSForExtensions->setTargetPath("{$this->jsCacheDir}/{$resultCombinedName}header.min.js"); |
||
| 357 | // $this->headerCollectionJSForExtensions->setTargetUri( |
||
| 358 | // "js/cache/{$resultCombinedName}header.min.js?v={$version}" |
||
| 359 | // ); |
||
| 360 | |||
| 361 | // $this->footerCollectionJSForExtensions->join(true); |
||
| 362 | // $this->footerCollectionJSForExtensions->setTargetPath("{$this->jsCacheDir}/{$resultCombinedName}footer.min.js"); |
||
| 363 | // $this->footerCollectionJSForExtensions->setTargetUri( |
||
| 364 | // "js/cache/{$resultCombinedName}footer.min.js?v={$version}" |
||
| 365 | // ); |
||
| 366 | |||
| 367 | |||
| 368 | // $minifier = new Minify\JS(); |
||
| 369 | // foreach ($this->footerCollectionJSForExtensions as $resource) { |
||
| 370 | // try { |
||
| 371 | // $minifier->addFile($resource->getPath()); |
||
| 372 | // } catch (Minify\Exceptions\IOException $e) { |
||
| 373 | // |
||
| 374 | // } |
||
| 375 | // |
||
| 376 | // $resource->setPath($resource->getPath() . '?v=' . $version); |
||
| 377 | // } |
||
| 378 | // $minifier->minify("{$this->jsCacheDir}/{$resultCombinedName}footer.min.js"); |
||
| 379 | } |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Makes assets for the CallQueues controller |
||
| 383 | * |
||
| 384 | * @param string $action |
||
| 385 | */ |
||
| 386 | private function makeCallQueuesAssets(string $action) |
||
| 387 | { |
||
| 388 | if ($action === 'index') { |
||
| 389 | $this->headerCollectionCSS |
||
| 390 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 391 | $this->footerCollectionJS |
||
| 392 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 393 | ->addJs('js/pbx/CallQueues/callqueues-index.js', true); |
||
| 394 | } elseif ($action === 'modify') { |
||
| 395 | $this->footerCollectionJS |
||
| 396 | ->addJs('js/vendor/jquery.debounce-1.0.5.js', true) |
||
| 397 | ->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 398 | ->addJs('js/pbx/main/form.js', true) |
||
| 399 | ->addJs('js/pbx/CallQueues/callqueue-modify.js', true) |
||
| 400 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 401 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); |
||
| 402 | } |
||
| 403 | } |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Makes assets for the ConferenceRooms controller |
||
| 407 | * |
||
| 408 | * @param string $action |
||
| 409 | */ |
||
| 410 | private function makeConferenceRoomsAssets(string $action) |
||
| 411 | { |
||
| 412 | if ($action === 'index') { |
||
| 413 | $this->footerCollectionJS |
||
| 414 | ->addJs('js/pbx/ConferenceRooms/conference-rooms-index.js', true); |
||
| 415 | } elseif ($action === 'modify') { |
||
| 416 | $this->footerCollectionJS |
||
| 417 | ->addJs('js/pbx/main/form.js', true) |
||
| 418 | ->addJs('js/pbx/ConferenceRooms/conference-room-modify.js', true); |
||
| 419 | } |
||
| 420 | } |
||
| 421 | |||
| 422 | /** |
||
| 423 | * Makes assets for the SystemDiagnostic controller |
||
| 424 | * |
||
| 425 | * @param string $action |
||
| 426 | */ |
||
| 427 | private function makeSystemDiagnosticAssets(string $action): void |
||
| 428 | { |
||
| 429 | if ($action === 'index') { |
||
| 430 | $this->footerCollectionJS |
||
| 431 | ->addJs('js/vendor/semantic/popup.min.js', true) |
||
| 432 | ->addJs('js/vendor/semantic/dropdown.min.js', true) |
||
| 433 | ->addJs('js/pbx/main/form.js', true) |
||
| 434 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index.js', true) |
||
| 435 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-showlogs.js', true) |
||
| 436 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-sysinfo.js', true) |
||
| 437 | ->addJs('js/pbx/SystemDiagnostic/system-diagnostic-index-logcapture.js', true); |
||
| 438 | $this->footerCollectionACE |
||
| 439 | ->addJs('js/vendor/ace/ace.js', true) |
||
| 440 | ->addJs('js/vendor/ace/mode-julia.js', true); |
||
| 441 | } |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Makes assets for the SoundFiles controller |
||
| 446 | * |
||
| 447 | * @param string $action |
||
| 448 | */ |
||
| 449 | private function makeSoundFilesAssets(string $action): void |
||
| 450 | { |
||
| 451 | if ($action === 'index') { |
||
| 452 | $this->headerCollectionCSS |
||
| 453 | ->addCss('css/vendor/range/range.css') |
||
| 454 | ->addCss( |
||
| 455 | 'css/vendor/datatable/dataTables.semanticui.css', |
||
| 456 | true |
||
| 457 | ); |
||
| 458 | $this->footerCollectionJS->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 459 | ->addJs('js/vendor/range/range.min.js', true) |
||
| 460 | ->addJs('js/vendor/jquery.address.min.js', true) |
||
| 461 | ->addJs('js/pbx/SoundFiles/sound-files-index-player.js', true) |
||
| 462 | ->addJs('js/pbx/SoundFiles/sound-files-index.js', true); |
||
| 463 | } elseif ($action === 'modify') { |
||
| 464 | $this->headerCollectionCSS->addCss('css/vendor/range/range.css'); |
||
| 465 | |||
| 466 | $this->headerCollectionJS |
||
| 467 | ->addJs( |
||
| 468 | 'js/vendor/webrtc/MediaStreamRecorder.min.js', |
||
| 469 | true |
||
| 470 | ) |
||
| 471 | ->addJs('js/vendor/webrtc/adapter-latest.min.js', true); |
||
| 472 | |||
| 473 | $this->footerCollectionJS |
||
| 474 | ->addJs('js/vendor/range/range.min.js', true) |
||
| 475 | ->addJs('js/pbx/main/form.js', true) |
||
| 476 | ->addJs('js/vendor/resumable.js', true) |
||
| 477 | ->addJs('js/pbx/SoundFiles/sound-file-modify-player.js', true) |
||
| 478 | ->addJs('js/pbx/SoundFiles/sound-file-modify-upload-worker.js', true) |
||
| 479 | ->addJs('js/pbx/SoundFiles/sound-file-modify-webkit-recorder.js', true) |
||
| 480 | ->addJs('js/pbx/SoundFiles/sound-file-modify.js', true); |
||
| 481 | } |
||
| 482 | } |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Makes assets for the TimeSettings controller |
||
| 486 | * |
||
| 487 | * @param string $action |
||
| 488 | */ |
||
| 489 | private function makeTimeSettingsAssets(string $action): void |
||
| 490 | { |
||
| 491 | if ($action === 'modify') { |
||
| 492 | $this->footerCollectionJS |
||
| 493 | ->addJs('js/pbx/main/form.js', true) |
||
| 494 | ->addJs('js/vendor/moment/moment-with-locales.min.js',true) |
||
| 495 | ->addJs('js/vendor/moment/moment-timezone-with-data.js', true) |
||
| 496 | ->addJs('js/pbx/TimeSettings/time-settings-worker.js', true) |
||
| 497 | ->addJs('js/pbx/TimeSettings/time-settings-modify.js', true); |
||
| 498 | } |
||
| 499 | } |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Makes assets for the Update controller |
||
| 503 | * |
||
| 504 | * @param string $action |
||
| 505 | */ |
||
| 506 | private function makeUpdateAssets(string $action): void |
||
| 507 | { |
||
| 508 | if ($action === 'index') { |
||
| 509 | $this->footerCollectionJS |
||
| 510 | ->addJs('js/pbx/main/version-compare.js', true) |
||
| 511 | ->addJs('js/pbx/main/form.js', true) |
||
| 512 | ->addJs('js/vendor/resumable.js', true) |
||
| 513 | ->addJs('js/vendor/showdown/showdown.min.js', true) |
||
| 514 | ->addJs('js/pbx/Update/update-index.js', true); |
||
| 515 | $this->semanticCollectionCSS |
||
| 516 | ->addCss('css/vendor/semantic/progress.min.css', true) |
||
| 517 | ->addCss('css/vendor/semantic/modal.min.css', true); |
||
| 518 | |||
| 519 | $this->semanticCollectionJS |
||
| 520 | ->addJs('js/vendor/semantic/progress.min.js', true) |
||
| 521 | ->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 522 | } |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * Makes assets for the Session controller |
||
| 527 | * |
||
| 528 | * @param string $action |
||
| 529 | */ |
||
| 530 | private function makeSessionAssets(string $action): void |
||
| 531 | { |
||
| 532 | if ($action === 'index') { |
||
| 533 | $this->footerCollectionJS |
||
| 534 | ->addJs('js/pbx/main/form.js', true) |
||
| 535 | ->addJs('js/pbx/Session/login-form.js', true); |
||
| 536 | } |
||
| 537 | } |
||
| 538 | |||
| 539 | /** |
||
| 540 | * Makes assets for the Restart controller |
||
| 541 | * |
||
| 542 | * @param string $action |
||
| 543 | */ |
||
| 544 | private function makeRestartAssets(string $action): void |
||
| 545 | { |
||
| 546 | if ($action === 'index') { |
||
| 547 | $this->footerCollectionJS |
||
| 548 | ->addJs('js/pbx/Restart/restart-index.js', true); |
||
| 549 | } |
||
| 550 | } |
||
| 551 | |||
| 552 | /** |
||
| 553 | * Makes assets for the Providers controller |
||
| 554 | * |
||
| 555 | * @param string $action |
||
| 556 | */ |
||
| 557 | private function makeProvidersAssets(string $action): void |
||
| 558 | { |
||
| 559 | if ($action === 'index') { |
||
| 560 | $this->semanticCollectionCSS |
||
| 561 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true) |
||
| 562 | ->addCss('css/vendor/semantic/modal.min.css', true); |
||
| 563 | |||
| 564 | $this->semanticCollectionJS |
||
| 565 | ->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 566 | $this->footerCollectionJS |
||
| 567 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 568 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 569 | ->addJs('js/pbx/Providers/providers-index.js', true); |
||
| 570 | } elseif ($action === 'modifysip' || $action === 'modifyiax') { |
||
| 571 | $this->footerCollectionJS |
||
| 572 | ->addJs('js/pbx/main/form.js', true) |
||
| 573 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 574 | ->addJs('js/pbx/Providers/provider-modify-status-worker.js', true) |
||
| 575 | ->addJs('js/pbx/Providers/provider-modify.js', true); |
||
| 576 | } |
||
| 577 | } |
||
| 578 | |||
| 579 | /** |
||
| 580 | * Makes assets for the PbxExtensionModules controller |
||
| 581 | * |
||
| 582 | * @param string $action |
||
| 583 | */ |
||
| 584 | private function makePbxExtensionModulesAssets(string $action): void |
||
| 585 | { |
||
| 586 | if ($action === 'index') { |
||
| 587 | $this->semanticCollectionJS->addJs('js/vendor/semantic/modal.min.js', true); |
||
| 588 | $this->footerCollectionJS |
||
| 589 | ->addJs('js/pbx/Update/update-api.js', true) |
||
| 590 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 591 | ->addJs('js/vendor/resumable.js', true) |
||
| 592 | ->addJs( |
||
| 593 | 'js/pbx/PbxExtensionModules/pbx-extension-module-upgrade-status-worker.js', |
||
| 594 | true |
||
| 595 | ) |
||
| 596 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-status.js', true) |
||
| 597 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-modules-index.js', true) |
||
| 598 | ->addJs('js/vendor/semantic/progress.min.js', true) |
||
| 599 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-add-new.js', true); |
||
| 600 | $this->semanticCollectionCSS |
||
| 601 | ->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true) |
||
| 602 | ->addCss('css/vendor/semantic/modal.min.css', true) |
||
| 603 | ->addCss('css/vendor/semantic/progress.min.css', true); |
||
| 604 | } elseif ($action === 'modify') { |
||
| 605 | $this->footerCollectionJS |
||
| 606 | ->addJs('js/pbx/main/form.js', true) |
||
| 607 | ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-modify.js', true); |
||
| 608 | } |
||
| 609 | } |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Makes assets for the OutOffWorkTime controller |
||
| 613 | * |
||
| 614 | * @param string $action |
||
| 615 | */ |
||
| 616 | private function makeOutOffWorkTimeAssets(string $action): void |
||
| 617 | { |
||
| 618 | if ($action === 'index') { |
||
| 619 | $this->footerCollectionJS |
||
| 620 | ->addJs('js/pbx/OutOffWorkTime/out-of-work-times-index.js', true); |
||
| 621 | } elseif ($action === 'modify') { |
||
| 622 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/calendar.min.css', true); |
||
| 623 | $this->semanticCollectionJS->addJs('js/vendor/semantic/calendar.min.js', true); |
||
| 624 | $this->footerCollectionJS |
||
| 625 | ->addJs('js/pbx/main/form.js', true) |
||
| 626 | ->addJs('js/pbx/OutOffWorkTime/out-of-work-time-modify.js', true) |
||
| 627 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 628 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); |
||
| 629 | } |
||
| 630 | } |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Makes assets for the OutboundRoutes controller |
||
| 634 | * |
||
| 635 | * @param string $action |
||
| 636 | */ |
||
| 637 | private function makeOutboundRoutesAssets(string $action): void |
||
| 638 | { |
||
| 639 | if ($action === 'index') { |
||
| 640 | $this->footerCollectionJS |
||
| 641 | ->addJs('js/vendor/jquery.tablednd.min.js', true) |
||
| 642 | ->addJs('js/pbx/OutboundRoutes/outbound-routes-index.js', true); |
||
| 643 | } elseif ($action === 'modify') { |
||
| 644 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 645 | ->addJs('js/pbx/OutboundRoutes/outbound-route-modify.js', true); |
||
| 646 | } |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Makes assets for the Network controller |
||
| 651 | * |
||
| 652 | * @param string $action |
||
| 653 | */ |
||
| 654 | private function makeNetworkAssets(string $action): void |
||
| 655 | { |
||
| 656 | if ($action === 'modify') { |
||
| 657 | $this->footerCollectionJS |
||
| 658 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 659 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 660 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 661 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 662 | ->addJs('js/pbx/main/form.js', true) |
||
| 663 | ->addJs('js/pbx/Network/network-modify.js', true); |
||
| 664 | } |
||
| 665 | } |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Makes assets for the MailSettings controller |
||
| 669 | * |
||
| 670 | * @param string $action |
||
| 671 | */ |
||
| 672 | private function makeMailSettingsAssets(string $action): void |
||
| 673 | { |
||
| 674 | if ($action === 'modify') { |
||
| 675 | $this->footerCollectionJS |
||
| 676 | ->addJs('js/pbx/main/form.js', true) |
||
| 677 | ->addJs('js/pbx/MailSettings/mail-settings-modify.js', true); |
||
| 678 | } |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * Makes assets for the Licensing controller |
||
| 683 | * |
||
| 684 | * @param string $action |
||
| 685 | */ |
||
| 686 | private function makeLicensingAssets(string $action): void |
||
| 687 | { |
||
| 688 | if ($action === 'modify') { |
||
| 689 | $this->footerCollectionJS |
||
| 690 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 691 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 692 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 693 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 694 | ->addJs('js/pbx/main/form.js', true) |
||
| 695 | ->addJs('js/pbx/Licensing/licensing-modify.js', true); |
||
| 696 | } |
||
| 697 | } |
||
| 698 | |||
| 699 | /** |
||
| 700 | * Makes assets for the IvrMenu controller |
||
| 701 | * |
||
| 702 | * @param string $action |
||
| 703 | */ |
||
| 704 | private function makeIvrMenuAssets(string $action): void |
||
| 705 | { |
||
| 706 | if ($action === 'index') { |
||
| 707 | $this->headerCollectionCSS |
||
| 708 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 709 | $this->footerCollectionJS |
||
| 710 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 711 | ->addJs('js/pbx/IvrMenu/ivrmenu-index.js', true); |
||
| 712 | } elseif ($action === 'modify') { |
||
| 713 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 714 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 715 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true) |
||
| 716 | ->addJs('js/pbx/IvrMenu/ivrmenu-modify.js', true); |
||
| 717 | } |
||
| 718 | } |
||
| 719 | |||
| 720 | /** |
||
| 721 | * Makes assets for the IncomingRoutes controller |
||
| 722 | * |
||
| 723 | * @param string $action |
||
| 724 | */ |
||
| 725 | private function makeIncomingRoutesAssets(string $action): void |
||
| 726 | { |
||
| 727 | if ($action === 'index') { |
||
| 728 | $this->footerCollectionJS->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 729 | ->addJs('js/pbx/main/form.js', true) |
||
| 730 | ->addJs('js/pbx/IncomingRoutes/incoming-route-index.js', true); |
||
| 731 | } elseif ($action === 'modify') { |
||
| 732 | $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) |
||
| 733 | ->addJs('js/pbx/IncomingRoutes/incoming-route-modify.js', true); |
||
| 734 | } |
||
| 735 | } |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Makes assets for the GeneralSettings controller |
||
| 739 | * |
||
| 740 | * @param string $action |
||
| 741 | */ |
||
| 742 | private function makeGeneralSettingsAssets(string $action): void |
||
| 743 | { |
||
| 744 | if ($action === 'modify') { |
||
| 745 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/progress.min.css', true); |
||
| 746 | $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); |
||
| 747 | $this->footerCollectionJS |
||
| 748 | ->addJs('js/vendor/jquery.address.min.js', true) |
||
| 749 | ->addJs('js/vendor/jquery.tablednd.js', true) |
||
| 750 | ->addJs('js/pbx/SoundFiles/sound-files-selector.js', true) |
||
| 751 | ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true) |
||
| 752 | ->addJs('js/pbx/main/form.js', true) |
||
| 753 | ->addJs('js/pbx/main/password-score.js', true) |
||
| 754 | ->addJs( |
||
| 755 | 'js/pbx/GeneralSettings/general-settings-modify.js', |
||
| 756 | true |
||
| 757 | ); |
||
| 758 | } |
||
| 759 | } |
||
| 760 | |||
| 761 | /** |
||
| 762 | * Makes assets for the Firewall controller |
||
| 763 | * |
||
| 764 | * @param string $action |
||
| 765 | */ |
||
| 766 | private function makeFirewallAssets(string $action): void |
||
| 767 | { |
||
| 768 | if ($action === 'index') { |
||
| 769 | $this->footerCollectionJS |
||
| 770 | ->addJs('js/pbx/Firewall/firewall-index.js', true); |
||
| 771 | } elseif ($action === 'modify') { |
||
| 772 | $this->footerCollectionJS |
||
| 773 | ->addJs('js/pbx/main/form.js', true) |
||
| 774 | ->addJs('js/pbx/Firewall/firewall-modify.js', true); |
||
| 775 | } |
||
| 776 | } |
||
| 777 | |||
| 778 | /** |
||
| 779 | * Makes assets for the Fail2Ban controller |
||
| 780 | * |
||
| 781 | * @param string $action |
||
| 782 | */ |
||
| 783 | private function makeFail2BanAssets(string $action): void |
||
| 784 | { |
||
| 785 | if ($action === 'index') { |
||
| 786 | $this->footerCollectionJS |
||
| 787 | ->addJs('js/pbx/main/form.js', true) |
||
| 788 | ->addJs('js/pbx/Fail2Ban/fail-to-ban-index.js', true); |
||
| 789 | } |
||
| 790 | } |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Makes assets for the Extensions controller |
||
| 794 | * |
||
| 795 | * @param string $action |
||
| 796 | */ |
||
| 797 | private function makeExtensionsAssets(string $action): void |
||
| 798 | { |
||
| 799 | if ($action === 'index') { |
||
| 800 | $this->headerCollectionCSS->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true); |
||
| 801 | |||
| 802 | $this->footerCollectionJS |
||
| 803 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 804 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 805 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 806 | ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) |
||
| 807 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 808 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 809 | ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) |
||
| 810 | ->addJs('js/pbx/Extensions/extensions-index.js', true) |
||
| 811 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 812 | ->addJs('js/vendor/clipboard/clipboard.js', true); |
||
| 813 | } elseif ($action === 'modify') { |
||
| 814 | $this->semanticCollectionCSS->addCss('css/vendor/semantic/card.min.css', true); |
||
| 815 | $this->footerCollectionJS |
||
| 816 | ->addJs('js/vendor/inputmask/inputmask.js', true) |
||
| 817 | ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) |
||
| 818 | ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) |
||
| 819 | ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) |
||
| 820 | ->addJs('js/vendor/inputmask/init.js', true) |
||
| 821 | ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) |
||
| 822 | ->addJs('js/pbx/main/form.js', true) |
||
| 823 | ->addJs('js/pbx/main/debugger-info.js', true) |
||
| 824 | ->addJs('js/pbx/Extensions/extension-modify.js', true); |
||
| 825 | } |
||
| 826 | } |
||
| 827 | |||
| 828 | /** |
||
| 829 | * Makes assets for the DialplanApplications controller |
||
| 830 | * |
||
| 831 | * @param string $action |
||
| 832 | */ |
||
| 833 | private function makeDialplanApplicationsAssets(string $action): void |
||
| 834 | { |
||
| 835 | if ($action === 'index') { |
||
| 836 | $this->headerCollectionCSS |
||
| 837 | ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); |
||
| 838 | $this->footerCollectionJS |
||
| 839 | ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) |
||
| 840 | ->addJs('js/pbx/DialplanApplications/dialplan-applications-index.js', true); |
||
| 841 | } elseif ($action === 'modify') { |
||
| 842 | $this->footerCollectionACE |
||
| 843 | ->addJs('js/vendor/ace/ace.js', true) |
||
| 844 | ->addJs('js/vendor/ace/mode-php.js', true) |
||
| 845 | ->addJs('js/vendor/ace/mode-julia.js', true); |
||
| 846 | $this->footerCollectionJS |
||
| 847 | ->addJs('js/pbx/main/form.js', true) |
||
| 848 | ->addJs('js/pbx/DialplanApplications/dialplan-applications-modify.js', true); |
||
| 849 | } |
||
| 850 | } |
||
| 851 | |||
| 852 | /** |
||
| 853 | * Makes assets for the CustomFiles controller |
||
| 854 | * |
||
| 855 | * @param string $action |
||
| 856 | */ |
||
| 857 | private function makeCustomFilesAssets(string $action): void |
||
| 872 | } |
||
| 873 | } |
||
| 874 | |||
| 875 | /** |
||
| 876 | * Makes assets for the CallDetailRecords controller |
||
| 877 | * |
||
| 878 | * @param string $action |
||
| 879 | */ |
||
| 880 | private function makeCallDetailRecordsAssets(string $action): void |
||
| 881 | { |
||
| 882 | if ($action === 'index') { |
||
| 883 | $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); |
||
| 884 | |||
| 885 | $this->semanticCollectionCSS |
||
| 886 | ->addCss('css/vendor/range/range.min.css', true) |
||
| 904 | ); |
||
| 905 | } |
||
| 906 | } |
||
| 907 | |||
| 908 | /** |
||
| 909 | * Makes assets for the AsteriskManagers controller |
||
| 910 | * |
||
| 911 | * @param string $action |
||
| 912 | */ |
||
| 913 | private function makeAsteriskManagersAssets(string $action): void |
||
| 921 | } |
||
| 922 | } |
||
| 923 | |||
| 924 | |||
| 925 | } |