| Total Complexity | 88 | 
| Total Lines | 862 | 
| Duplicated Lines | 0 % | 
| Changes | 3 | ||
| 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  | 
            ||
| 27 | class AssetProvider implements ServiceProviderInterface  | 
            ||
| 28 | { | 
            ||
| 29 | public const SERVICE_NAME = 'assets';  | 
            ||
| 30 | |||
| 31 | private Collection $headerCollectionJSForExtensions;  | 
            ||
| 32 | private Collection $footerCollectionJSForExtensions;  | 
            ||
| 33 | private Collection $headerCollectionJS;  | 
            ||
| 34 | private Collection $headerCollectionCSS;  | 
            ||
| 35 | private Collection $footerCollectionJS;  | 
            ||
| 36 | private Collection $semanticCollectionCSS;  | 
            ||
| 37 | private Collection $semanticCollectionJS;  | 
            ||
| 38 | private Collection $footerCollectionACE;  | 
            ||
| 39 | private Collection $footerCollectionLoc;  | 
            ||
| 40 | private Collection $headerCollectionSentryJS;  | 
            ||
| 41 | private string $cssCacheDir;  | 
            ||
| 42 | private string $jsCacheDir;  | 
            ||
| 43 | private Manager $manager;  | 
            ||
| 44 | |||
| 45 | /**  | 
            ||
| 46 | * Registers assets service provider  | 
            ||
| 47 | *  | 
            ||
| 48 | * @param \Phalcon\Di\DiInterface $di  | 
            ||
| 49 | */  | 
            ||
| 50 | public function register(DiInterface $di): void  | 
            ||
| 51 |     { | 
            ||
| 52 | $di->set(  | 
            ||
| 53 | self::SERVICE_NAME,  | 
            ||
| 54 |             function () use ($di) { | 
            ||
| 55 | $assets = new AssetProvider();  | 
            ||
| 56 | $assets->initializeClassVariables();  | 
            ||
| 57 |                 $dispatcher = $di->get('dispatcher'); | 
            ||
| 58 |                 $session    = $di->get('session'); | 
            ||
| 59 | $controller = $dispatcher->getControllerName();  | 
            ||
| 60 | $action = $dispatcher->getActionName();  | 
            ||
| 61 | $moduleName = $dispatcher->getModuleName();  | 
            ||
| 62 | |||
| 63 |                 if ($action === null) { | 
            ||
| 64 | $action = 'index';  | 
            ||
| 65 | }  | 
            ||
| 66 |                 if ($session !== null && $session->has('versionHash')) { | 
            ||
| 67 |                     $version = (string)$session->get('versionHash'); | 
            ||
| 68 |                 } else { | 
            ||
| 69 |                     $version = str_replace(PHP_EOL, '', file_get_contents('/etc/version')); | 
            ||
| 70 | }  | 
            ||
| 71 | |||
| 72 | $assets->makeSentryAssets($version);  | 
            ||
| 73 | $assets->makeHeaderAssets($session, $moduleName);  | 
            ||
| 74 | |||
| 75 | // Generates Controllers assets  | 
            ||
| 76 |                 $method_name = "make{$controller}Assets"; | 
            ||
| 77 |                 if (method_exists($assets, $method_name)) { | 
            ||
| 78 | $assets->$method_name($action);  | 
            ||
| 79 | }  | 
            ||
| 80 | |||
| 81 | $assets->makeFooterAssets();  | 
            ||
| 82 | $assets->makeLocalizationAssets($di, $version);  | 
            ||
| 83 | $assets->generateFilesAndLinks($controller, $action, $version);  | 
            ||
| 84 | |||
| 85 | return $assets->manager;  | 
            ||
| 86 | }  | 
            ||
| 87 | );  | 
            ||
| 88 | }  | 
            ||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * Initialize class variables  | 
            ||
| 92 | */  | 
            ||
| 93 | public function initializeClassVariables()  | 
            ||
| 94 |     { | 
            ||
| 95 | $this->manager = new Manager();  | 
            ||
| 96 | |||
| 97 |         $this->cssCacheDir = appPath('sites/admin-cabinet/assets/css/cache'); | 
            ||
| 98 |         $this->jsCacheDir  = appPath('sites/admin-cabinet/assets/js/cache'); | 
            ||
| 99 | |||
| 100 |         $this->headerCollectionJSForExtensions = $this->manager->collection('headerJS'); | 
            ||
| 101 |         $this->headerCollectionJSForExtensions->setPrefix('assets/'); | 
            ||
| 102 |         $this->footerCollectionJSForExtensions = $this->manager->collection('footerJS'); | 
            ||
| 103 |         $this->footerCollectionJSForExtensions->setPrefix('assets/'); | 
            ||
| 104 |         $this->headerCollectionJS = $this->manager->collection('headerPBXJS'); | 
            ||
| 105 |         $this->headerCollectionJS->setPrefix('assets/'); | 
            ||
| 106 |         $this->headerCollectionCSS = $this->manager->collection('headerCSS'); | 
            ||
| 107 |         $this->headerCollectionCSS->setPrefix('assets/'); | 
            ||
| 108 |         $this->footerCollectionJS = $this->manager->collection('footerPBXJS'); | 
            ||
| 109 |         $this->footerCollectionJS->setPrefix('assets/'); | 
            ||
| 110 |         $this->headerCollectionSentryJS = $this->manager->collection('headerSentryJS'); | 
            ||
| 111 |         $this->semanticCollectionCSS    = $this->manager->collection('SemanticUICSS'); | 
            ||
| 112 |         $this->semanticCollectionCSS->setPrefix('assets/'); | 
            ||
| 113 |         $this->semanticCollectionJS = $this->manager->collection('SemanticUIJS'); | 
            ||
| 114 |         $this->semanticCollectionJS->setPrefix('assets/'); | 
            ||
| 115 |         $this->footerCollectionACE = $this->manager->collection('footerACE'); | 
            ||
| 116 |         $this->footerCollectionACE->setPrefix('assets/'); | 
            ||
| 117 |         $this->footerCollectionLoc = $this->manager->collection('footerLoc'); | 
            ||
| 118 |         $this->footerCollectionLoc->setPrefix('assets/'); | 
            ||
| 119 | }  | 
            ||
| 120 | |||
| 121 | /**  | 
            ||
| 122 | * Makes assets for the Sentry error logger  | 
            ||
| 123 | *  | 
            ||
| 124 | * @param string $version  | 
            ||
| 125 | */  | 
            ||
| 126 | private function makeSentryAssets(string $version): void  | 
            ||
| 127 |     { | 
            ||
| 128 |         if (file_exists('/tmp/sendmetrics')) { | 
            ||
| 129 | $this->headerCollectionSentryJS->addjs(  | 
            ||
| 130 | '//browser.sentry-cdn.com/5.27.0/bundle.min.js',  | 
            ||
| 131 | false,  | 
            ||
| 132 | false,  | 
            ||
| 133 | [  | 
            ||
| 134 | 'crossorigin' => 'anonymous',  | 
            ||
| 135 | 'integrity' => 'sha384-odt6g+qg66eR/WbXcAHMweT2Ab+eHnyzmeJOodbqYhP2rQdeJbPgDM/xbi5jj2tx',  | 
            ||
| 136 | ]  | 
            ||
| 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  | 
            ||
| 152 |     { | 
            ||
| 153 | $this->semanticCollectionCSS  | 
            ||
| 154 |             ->addCss('css/vendor/semantic/grid.min.css', true) | 
            ||
| 155 |             ->addCss('css/vendor/semantic/divider.min.css', true) | 
            ||
| 156 |             ->addCss('css/vendor/semantic/container.min.css', true) | 
            ||
| 157 |             ->addCss('css/vendor/semantic/header.min.css', true) | 
            ||
| 158 |             ->addCss('css/vendor/semantic/button.min.css', true) | 
            ||
| 159 |             ->addCss('css/vendor/semantic/form.min.css', true) | 
            ||
| 160 |             ->addCss('css/vendor/semantic/icon.min.css', true) | 
            ||
| 161 |             ->addCss('css/vendor/semantic/flag.min.css', true) | 
            ||
| 162 |             ->addCss('css/vendor/semantic/image.min.css', true) | 
            ||
| 163 |             ->addCss('css/vendor/semantic/input.min.css', true) | 
            ||
| 164 |             ->addCss('css/vendor/semantic/message.min.css', true) | 
            ||
| 165 |             ->addCss('css/vendor/semantic/segment.min.css', true) | 
            ||
| 166 |             ->addCss('css/vendor/semantic/site.min.css', true) | 
            ||
| 167 |             ->addCss('css/vendor/semantic/reset.min.css', true) | 
            ||
| 168 |             ->addCss('css/vendor/semantic/transition.min.css', true) | 
            ||
| 169 |             ->addCss('css/vendor/semantic/dropdown.min.css', true); | 
            ||
| 170 | |||
| 171 | $this->headerCollectionJS  | 
            ||
| 172 |             ->addJs('js/pbx/main/header.js', true) | 
            ||
| 173 |             ->addJs('js/vendor/jquery.min.js', true); | 
            ||
| 174 | |||
| 175 | $this->footerCollectionJS  | 
            ||
| 176 |             ->addJs('js/pbx/main/language-select.js', true); | 
            ||
| 177 | |||
| 178 | $this->semanticCollectionJS  | 
            ||
| 179 |             ->addJs('js/vendor/semantic/form.min.js', true) | 
            ||
| 180 |             ->addJs('js/vendor/semantic/api.min.js', true) | 
            ||
| 181 |             ->addJs('js/vendor/semantic/site.min.js', true) | 
            ||
| 182 |             ->addJs('js/vendor/semantic/popup.min.js', true) | 
            ||
| 183 |             ->addJs('js/vendor/semantic/dropdown.min.js', true) | 
            ||
| 184 |             ->addJs('js/vendor/semantic/transition.min.js', true); | 
            ||
| 185 | |||
| 186 | // Если пользователь залогинился, сформируем необходимые CSS кеши  | 
            ||
| 187 |         if ($session && $session->has('auth')) { | 
            ||
| 188 | $this->semanticCollectionCSS  | 
            ||
| 189 |                 ->addCss('css/vendor/semantic/menu.min.css', true) | 
            ||
| 190 |                 ->addCss('css/vendor/semantic/sidebar.min.css', true) | 
            ||
| 191 |                 ->addCss('css/vendor/semantic/table.min.css', true) | 
            ||
| 192 |                 ->addCss('css/vendor/semantic/loader.min.css', true) | 
            ||
| 193 |                 ->addCss('css/vendor/semantic/label.min.css', true) | 
            ||
| 194 |                 ->addCss('css/vendor/semantic/dimmer.min.css', true) | 
            ||
| 195 |                 ->addCss('css/vendor/semantic/accordion.min.css', true) | 
            ||
| 196 |                 ->addCss('css/vendor/semantic/placeholder.min.css', true) | 
            ||
| 197 |                 ->addCss('css/vendor/semantic/item.min.css', true) | 
            ||
| 198 |                 ->addCss('css/vendor/semantic/tab.min.css', true) | 
            ||
| 199 |                 ->addCss('css/vendor/semantic/checkbox.min.css', true) | 
            ||
| 200 |                 ->addCss('css/vendor/semantic/popup.min.css', true) | 
            ||
| 201 |                 ->addCss('css/vendor/semantic/toast.min.css', true); | 
            ||
| 202 | |||
| 203 | $this->semanticCollectionJS  | 
            ||
| 204 |                 ->addJs('js/vendor/semantic/accordion.min.js', true) | 
            ||
| 205 |                 ->addJs('js/vendor/semantic/dimmer.min.js', true) | 
            ||
| 206 |                 ->addJs('js/vendor/semantic/sidebar.min.js', true) | 
            ||
| 207 |                 ->addJs('js/vendor/semantic/checkbox.min.js', true) | 
            ||
| 208 |                 ->addJs('js/vendor/semantic/toast.min.js', true) | 
            ||
| 209 |                 ->addJs('js/vendor/semantic/tab.min.js', true); | 
            ||
| 210 | |||
| 211 | $this->footerCollectionJS  | 
            ||
| 212 | ->addJs(  | 
            ||
| 213 | 'js/pbx/main/config.js',  | 
            ||
| 214 | true  | 
            ||
| 215 | )  | 
            ||
| 216 | ->addJs(  | 
            ||
| 217 | 'js/pbx/main/pbxapi.js',  | 
            ||
| 218 | true  | 
            ||
| 219 | )  | 
            ||
| 220 | ->addJs(  | 
            ||
| 221 | 'js/pbx/main/connection-check-worker.js',  | 
            ||
| 222 | true  | 
            ||
| 223 | )  | 
            ||
| 224 | ->addJs(  | 
            ||
| 225 | 'js/pbx/main/semantic-localization.js',  | 
            ||
| 226 | true  | 
            ||
| 227 | )  | 
            ||
| 228 | ->addJs(  | 
            ||
| 229 | 'js/pbx/Advices/advices-worker.js',  | 
            ||
| 230 | true  | 
            ||
| 231 | )  | 
            ||
| 232 | ->addJs(  | 
            ||
| 233 | 'js/pbx/SendMetrics/send-metrics-index.js',  | 
            ||
| 234 | true  | 
            ||
| 235 | )  | 
            ||
| 236 | ->addJs(  | 
            ||
| 237 | 'js/pbx/main/ssh-console.js',  | 
            ||
| 238 | true  | 
            ||
| 239 | )  | 
            ||
| 240 | ->addJs(  | 
            ||
| 241 | 'js/pbx/main/delete-something.js',  | 
            ||
| 242 | true  | 
            ||
| 243 | )  | 
            ||
| 244 | ->addJs(  | 
            ||
| 245 | 'js/pbx/main/user-message.js',  | 
            ||
| 246 | true  | 
            ||
| 247 | )  | 
            ||
| 248 | ->addJs(  | 
            ||
| 249 | 'js/pbx/Extensions/extensions.js',  | 
            ||
| 250 | true  | 
            ||
| 251 | )  | 
            ||
| 252 | ->addJs(  | 
            ||
| 253 | 'js/pbx/PbxExtensionModules/pbx-extension-menu-addition.js',  | 
            ||
| 254 | true  | 
            ||
| 255 | )  | 
            ||
| 256 | ->addJs(  | 
            ||
| 257 | 'js/pbx/TopMenuSearch/top-menu-search.js',  | 
            ||
| 258 | true  | 
            ||
| 259 | );  | 
            ||
| 260 | |||
| 261 |             if ($moduleName === 'PBXExtension') { | 
            ||
| 262 | $this->footerCollectionJS->addJs(  | 
            ||
| 263 | 'js/pbx/PbxExtensionModules/pbx-extension-module-status.js',  | 
            ||
| 264 | true  | 
            ||
| 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  | 
            ||
| 359 | );  | 
            ||
| 360 | }  | 
            ||
| 361 | |||
| 362 | /**  | 
            ||
| 363 | * Makes assets for the CallQueues controller  | 
            ||
| 364 | *  | 
            ||
| 365 | * @param string $action  | 
            ||
| 366 | */  | 
            ||
| 367 | private function makeCallQueuesAssets(string $action)  | 
            ||
| 368 |     { | 
            ||
| 369 |         if ($action === 'index') { | 
            ||
| 370 | $this->headerCollectionCSS  | 
            ||
| 371 |                 ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); | 
            ||
| 372 | $this->footerCollectionJS  | 
            ||
| 373 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 374 |                 ->addJs('js/pbx/CallQueues/callqueues-index.js', true); | 
            ||
| 375 |         } elseif ($action === 'modify') { | 
            ||
| 376 | $this->footerCollectionJS  | 
            ||
| 377 |                 ->addJs('js/vendor/jquery.debounce-1.0.5.js', true) | 
            ||
| 378 |                 ->addJs('js/vendor/jquery.tablednd.js', true) | 
            ||
| 379 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 380 |                 ->addJs('js/pbx/CallQueues/callqueue-modify.js', true) | 
            ||
| 381 |                 ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); | 
            ||
| 382 | }  | 
            ||
| 383 | }  | 
            ||
| 384 | |||
| 385 | /**  | 
            ||
| 386 | * Makes assets for the ConferenceRooms controller  | 
            ||
| 387 | *  | 
            ||
| 388 | * @param string $action  | 
            ||
| 389 | */  | 
            ||
| 390 | private function makeConferenceRoomsAssets(string $action)  | 
            ||
| 391 |     { | 
            ||
| 392 |         if ($action === 'index') { | 
            ||
| 393 | $this->footerCollectionJS  | 
            ||
| 394 |                 ->addJs('js/pbx/ConferenceRooms/conference-rooms-index.js', true); | 
            ||
| 395 |         } elseif ($action === 'modify') { | 
            ||
| 396 | $this->footerCollectionJS  | 
            ||
| 397 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 398 |                 ->addJs('js/pbx/ConferenceRooms/conference-room-modify.js', true); | 
            ||
| 399 | }  | 
            ||
| 400 | }  | 
            ||
| 401 | |||
| 402 | /**  | 
            ||
| 403 | * Makes assets for the SystemDiagnostic controller  | 
            ||
| 404 | *  | 
            ||
| 405 | * @param string $action  | 
            ||
| 406 | */  | 
            ||
| 407 | private function makeSystemDiagnosticAssets(string $action): void  | 
            ||
| 421 | }  | 
            ||
| 422 | }  | 
            ||
| 423 | |||
| 424 | /**  | 
            ||
| 425 | * Makes assets for the SoundFiles controller  | 
            ||
| 426 | *  | 
            ||
| 427 | * @param string $action  | 
            ||
| 428 | */  | 
            ||
| 429 | private function makeSoundFilesAssets(string $action): void  | 
            ||
| 430 |     { | 
            ||
| 431 |         if ($action === 'index') { | 
            ||
| 432 | $this->headerCollectionCSS  | 
            ||
| 433 |                 ->addCss('css/vendor/range/range.css') | 
            ||
| 434 | ->addCss(  | 
            ||
| 435 | 'css/vendor/datatable/dataTables.semanticui.css',  | 
            ||
| 436 | true  | 
            ||
| 437 | );  | 
            ||
| 438 |             $this->footerCollectionJS->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 439 |                 ->addJs('js/vendor/range/range.min.js', true) | 
            ||
| 440 |                 ->addJs('js/vendor/jquery.address.min.js', true) | 
            ||
| 441 |                 ->addJs('js/pbx/SoundFiles/sound-files-index-player.js', true) | 
            ||
| 442 |                 ->addJs('js/pbx/SoundFiles/sound-files-index.js', true); | 
            ||
| 443 |         } elseif ($action === 'modify') { | 
            ||
| 444 |             $this->headerCollectionCSS->addCss('css/vendor/range/range.css'); | 
            ||
| 445 | |||
| 446 | $this->headerCollectionJS  | 
            ||
| 447 | ->addJs(  | 
            ||
| 448 | 'js/vendor/webrtc/MediaStreamRecorder.min.js',  | 
            ||
| 449 | true  | 
            ||
| 450 | )  | 
            ||
| 451 |                 ->addJs('js/vendor/webrtc/adapter-latest.min.js', true); | 
            ||
| 452 | |||
| 453 | $this->footerCollectionJS  | 
            ||
| 454 |                 ->addJs('js/vendor/range/range.min.js', true) | 
            ||
| 455 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 456 |                 ->addJs('js/vendor/resumable.js', true) | 
            ||
| 457 |                 ->addJs('js/pbx/SoundFiles/sound-file-modify-player.js', true) | 
            ||
| 458 |                 ->addJs('js/pbx/SoundFiles/sound-file-modify-upload-worker.js', true) | 
            ||
| 459 |                 ->addJs('js/pbx/SoundFiles/sound-file-modify-webkit-recorder.js', true) | 
            ||
| 460 |                 ->addJs('js/pbx/SoundFiles/sound-file-modify.js', true); | 
            ||
| 461 | }  | 
            ||
| 462 | }  | 
            ||
| 463 | |||
| 464 | /**  | 
            ||
| 465 | * Makes assets for the TimeSettings controller  | 
            ||
| 466 | *  | 
            ||
| 467 | * @param string $action  | 
            ||
| 468 | */  | 
            ||
| 469 | private function makeTimeSettingsAssets(string $action): void  | 
            ||
| 470 |     { | 
            ||
| 471 |         if ($action === 'modify') { | 
            ||
| 472 | $this->footerCollectionJS  | 
            ||
| 473 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 474 |                 ->addJs('js/pbx/TimeSettings/time-settings-worker.js', true) | 
            ||
| 475 |                 ->addJs('js/pbx/TimeSettings/time-settings-modify.js', true); | 
            ||
| 476 | }  | 
            ||
| 477 | }  | 
            ||
| 478 | |||
| 479 | /**  | 
            ||
| 480 | * Makes assets for the Update controller  | 
            ||
| 481 | *  | 
            ||
| 482 | * @param string $action  | 
            ||
| 483 | */  | 
            ||
| 484 | private function makeUpdateAssets(string $action): void  | 
            ||
| 485 |     { | 
            ||
| 486 |         if ($action === 'index') { | 
            ||
| 487 | $this->footerCollectionJS  | 
            ||
| 488 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 489 |                 ->addJs('js/vendor/resumable.js', true) | 
            ||
| 490 |                 ->addJs('js/vendor/showdown/showdown.min.js', true) | 
            ||
| 491 |                 ->addJs('js/pbx/Update/update-index.js', true); | 
            ||
| 492 | $this->semanticCollectionCSS  | 
            ||
| 493 |                 ->addCss('css/vendor/semantic/progress.min.css', true) | 
            ||
| 494 |                 ->addCss('css/vendor/semantic/modal.min.css', true); | 
            ||
| 495 | |||
| 496 | $this->semanticCollectionJS  | 
            ||
| 497 |                 ->addJs('js/vendor/semantic/progress.min.js', true) | 
            ||
| 498 |                 ->addJs('js/vendor/semantic/modal.min.js', true); | 
            ||
| 499 | }  | 
            ||
| 500 | }  | 
            ||
| 501 | |||
| 502 | /**  | 
            ||
| 503 | * Makes assets for the Session controller  | 
            ||
| 504 | *  | 
            ||
| 505 | * @param string $action  | 
            ||
| 506 | */  | 
            ||
| 507 | private function makeSessionAssets(string $action): void  | 
            ||
| 508 |     { | 
            ||
| 509 |         if ($action === 'index') { | 
            ||
| 510 | $this->footerCollectionJS  | 
            ||
| 511 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 512 |                 ->addJs('js/pbx/Session/login-form.js', true); | 
            ||
| 513 | }  | 
            ||
| 514 | }  | 
            ||
| 515 | |||
| 516 | /**  | 
            ||
| 517 | * Makes assets for the Restart controller  | 
            ||
| 518 | *  | 
            ||
| 519 | * @param string $action  | 
            ||
| 520 | */  | 
            ||
| 521 | private function makeRestartAssets(string $action): void  | 
            ||
| 522 |     { | 
            ||
| 523 |         if ($action === 'index') { | 
            ||
| 524 | $this->footerCollectionJS  | 
            ||
| 525 |                 ->addJs('js/pbx/Restart/restart-index.js', true); | 
            ||
| 526 | }  | 
            ||
| 527 | }  | 
            ||
| 528 | |||
| 529 | /**  | 
            ||
| 530 | * Makes assets for the Providers controller  | 
            ||
| 531 | *  | 
            ||
| 532 | * @param string $action  | 
            ||
| 533 | */  | 
            ||
| 534 | private function makeProvidersAssets(string $action): void  | 
            ||
| 535 |     { | 
            ||
| 536 |         if ($action === 'index') { | 
            ||
| 537 | $this->semanticCollectionCSS  | 
            ||
| 538 |                 ->addCss('css/vendor/datatable/dataTables.semanticui.css', true) | 
            ||
| 539 |                 ->addCss('css/vendor/semantic/modal.min.css', true); | 
            ||
| 540 | |||
| 541 | $this->semanticCollectionJS  | 
            ||
| 542 |                 ->addJs('js/vendor/semantic/modal.min.js', true); | 
            ||
| 543 | $this->footerCollectionJS  | 
            ||
| 544 |                 ->addJs('js/pbx/main/debugger-info.js', true) | 
            ||
| 545 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 546 |                 ->addJs('js/pbx/Providers/providers-index.js', true); | 
            ||
| 547 |         } elseif ($action === 'modifysip' || $action === 'modifyiax') { | 
            ||
| 548 | $this->footerCollectionJS  | 
            ||
| 549 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 550 |                 ->addJs('js/pbx/main/debugger-info.js', true) | 
            ||
| 551 |                 ->addJs('js/pbx/Providers/provider-modify.js', true); | 
            ||
| 552 | }  | 
            ||
| 553 | }  | 
            ||
| 554 | |||
| 555 | /**  | 
            ||
| 556 | * Makes assets for the PbxExtensionModules controller  | 
            ||
| 557 | *  | 
            ||
| 558 | * @param string $action  | 
            ||
| 559 | */  | 
            ||
| 560 | private function makePbxExtensionModulesAssets(string $action): void  | 
            ||
| 561 |     { | 
            ||
| 562 |         if ($action === 'index') { | 
            ||
| 563 |             $this->semanticCollectionJS->addJs('js/vendor/semantic/modal.min.js', true); | 
            ||
| 564 | $this->footerCollectionJS  | 
            ||
| 565 |                 ->addJs('js/pbx/Update/update-api.js', true) | 
            ||
| 566 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 567 |                 ->addJs('js/vendor/resumable.js', true) | 
            ||
| 568 | ->addJs(  | 
            ||
| 569 | 'js/pbx/PbxExtensionModules/pbx-extension-module-upgrade-status-worker.js',  | 
            ||
| 570 | true  | 
            ||
| 571 | )  | 
            ||
| 572 |                 ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-status.js', true) | 
            ||
| 573 |                 ->addJs('js/pbx/PbxExtensionModules/pbx-extension-modules-index.js', true) | 
            ||
| 574 |                 ->addJs('js/vendor/semantic/progress.min.js', true) | 
            ||
| 575 |                 ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-add-new.js', true); | 
            ||
| 576 | $this->semanticCollectionCSS  | 
            ||
| 577 |                 ->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true) | 
            ||
| 578 |                 ->addCss('css/vendor/semantic/modal.min.css', true) | 
            ||
| 579 |                 ->addCss('css/vendor/semantic/progress.min.css', true); | 
            ||
| 580 |         } elseif ($action === 'modify') { | 
            ||
| 581 | $this->footerCollectionJS  | 
            ||
| 582 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 583 |                 ->addJs('js/pbx/PbxExtensionModules/pbx-extension-module-modify.js', true); | 
            ||
| 584 | }  | 
            ||
| 585 | }  | 
            ||
| 586 | |||
| 587 | /**  | 
            ||
| 588 | * Makes assets for the OutOffWorkTime controller  | 
            ||
| 589 | *  | 
            ||
| 590 | * @param string $action  | 
            ||
| 591 | */  | 
            ||
| 592 | private function makeOutOffWorkTimeAssets(string $action): void  | 
            ||
| 593 |     { | 
            ||
| 594 |         if ($action === 'index') { | 
            ||
| 595 | $this->footerCollectionJS  | 
            ||
| 596 |                 ->addJs('js/pbx/OutOffWorkTime/out-of-work-times-index.js', true); | 
            ||
| 597 |         } elseif ($action === 'modify') { | 
            ||
| 598 |             $this->semanticCollectionCSS->addCss('css/vendor/semantic/calendar.min.css', true); | 
            ||
| 599 |             $this->semanticCollectionJS->addJs('js/vendor/semantic/calendar.min.js', true); | 
            ||
| 600 | $this->footerCollectionJS  | 
            ||
| 601 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 602 |                 ->addJs('js/pbx/OutOffWorkTime/out-of-work-time-modify.js', true) | 
            ||
| 603 |                 ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true); | 
            ||
| 604 | }  | 
            ||
| 605 | }  | 
            ||
| 606 | |||
| 607 | /**  | 
            ||
| 608 | * Makes assets for the OutboundRoutes controller  | 
            ||
| 609 | *  | 
            ||
| 610 | * @param string $action  | 
            ||
| 611 | */  | 
            ||
| 612 | private function makeOutboundRoutesAssets(string $action): void  | 
            ||
| 613 |     { | 
            ||
| 614 |         if ($action === 'index') { | 
            ||
| 615 | $this->footerCollectionJS  | 
            ||
| 616 |                 ->addJs('js/vendor/jquery.tablednd.min.js', true) | 
            ||
| 617 |                 ->addJs('js/pbx/OutboundRoutes/outbound-routes-index.js', true); | 
            ||
| 618 |         } elseif ($action === 'modify') { | 
            ||
| 619 |             $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) | 
            ||
| 620 |                 ->addJs('js/pbx/OutboundRoutes/outbound-route-modify.js', true); | 
            ||
| 621 | }  | 
            ||
| 622 | }  | 
            ||
| 623 | |||
| 624 | /**  | 
            ||
| 625 | * Makes assets for the Network controller  | 
            ||
| 626 | *  | 
            ||
| 627 | * @param string $action  | 
            ||
| 628 | */  | 
            ||
| 629 | private function makeNetworkAssets(string $action): void  | 
            ||
| 630 |     { | 
            ||
| 631 |         if ($action === 'modify') { | 
            ||
| 632 | $this->footerCollectionJS  | 
            ||
| 633 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 634 |                 ->addJs('js/pbx/Network/network-modify.js', true); | 
            ||
| 635 | }  | 
            ||
| 636 | }  | 
            ||
| 637 | |||
| 638 | /**  | 
            ||
| 639 | * Makes assets for the MailSettings controller  | 
            ||
| 640 | *  | 
            ||
| 641 | * @param string $action  | 
            ||
| 642 | */  | 
            ||
| 643 | private function makeMailSettingsAssets(string $action): void  | 
            ||
| 644 |     { | 
            ||
| 645 |         if ($action === 'modify') { | 
            ||
| 646 | $this->footerCollectionJS  | 
            ||
| 647 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 648 |                 ->addJs('js/pbx/MailSettings/mail-settings-modify.js', true); | 
            ||
| 649 | }  | 
            ||
| 650 | }  | 
            ||
| 651 | |||
| 652 | /**  | 
            ||
| 653 | * Makes assets for the Licensing controller  | 
            ||
| 654 | *  | 
            ||
| 655 | * @param string $action  | 
            ||
| 656 | */  | 
            ||
| 657 | private function makeLicensingAssets(string $action): void  | 
            ||
| 658 |     { | 
            ||
| 659 |         if ($action === 'modify') { | 
            ||
| 660 | $this->footerCollectionJS  | 
            ||
| 661 |                 ->addJs('js/vendor/inputmask/inputmask.js', true) | 
            ||
| 662 |                 ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) | 
            ||
| 663 |                 ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) | 
            ||
| 664 |                 ->addJs('js/vendor/inputmask/init.js', true) | 
            ||
| 665 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 666 |                 ->addJs('js/pbx/Licensing/licensing-modify.js', true); | 
            ||
| 667 | }  | 
            ||
| 668 | }  | 
            ||
| 669 | |||
| 670 | /**  | 
            ||
| 671 | * Makes assets for the IvrMenu controller  | 
            ||
| 672 | *  | 
            ||
| 673 | * @param string $action  | 
            ||
| 674 | */  | 
            ||
| 675 | private function makeIvrMenuAssets(string $action): void  | 
            ||
| 676 |     { | 
            ||
| 677 |         if ($action === 'index') { | 
            ||
| 678 | $this->headerCollectionCSS  | 
            ||
| 679 |                 ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); | 
            ||
| 680 | $this->footerCollectionJS  | 
            ||
| 681 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 682 |                 ->addJs('js/pbx/IvrMenu/ivrmenu-index.js', true); | 
            ||
| 683 |         } elseif ($action === 'modify') { | 
            ||
| 684 |             $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) | 
            ||
| 685 |                 ->addJs('js/pbx/SoundFiles/one-button-sound-player.js', true) | 
            ||
| 686 |                 ->addJs('js/pbx/IvrMenu/ivrmenu-modify.js', true); | 
            ||
| 687 | }  | 
            ||
| 688 | }  | 
            ||
| 689 | |||
| 690 | /**  | 
            ||
| 691 | * Makes assets for the IncomingRoutes controller  | 
            ||
| 692 | *  | 
            ||
| 693 | * @param string $action  | 
            ||
| 694 | */  | 
            ||
| 695 | private function makeIncomingRoutesAssets(string $action): void  | 
            ||
| 696 |     { | 
            ||
| 697 |         if ($action === 'index') { | 
            ||
| 698 |             $this->footerCollectionJS->addJs('js/vendor/jquery.tablednd.js', true) | 
            ||
| 699 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 700 |                 ->addJs('js/pbx/IncomingRoutes/incoming-route-index.js', true); | 
            ||
| 701 |         } elseif ($action === 'modify') { | 
            ||
| 702 |             $this->footerCollectionJS->addJs('js/pbx/main/form.js', true) | 
            ||
| 703 |                 ->addJs('js/pbx/IncomingRoutes/incoming-route-modify.js', true); | 
            ||
| 704 | }  | 
            ||
| 705 | }  | 
            ||
| 706 | |||
| 707 | /**  | 
            ||
| 708 | * Makes assets for the GeneralSettings controller  | 
            ||
| 709 | *  | 
            ||
| 710 | * @param string $action  | 
            ||
| 711 | */  | 
            ||
| 712 | private function makeGeneralSettingsAssets(string $action): void  | 
            ||
| 713 |     { | 
            ||
| 714 |         if ($action === 'modify') { | 
            ||
| 715 |             $this->semanticCollectionCSS->addCss('css/vendor/semantic/progress.min.css', true); | 
            ||
| 716 |             $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); | 
            ||
| 717 | $this->footerCollectionJS  | 
            ||
| 718 |                 ->addJs('js/vendor/jquery.address.min.js', true) | 
            ||
| 719 |                 ->addJs('js/vendor/jquery.tablednd.js', true) | 
            ||
| 720 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 721 |                 ->addJs('js/pbx/main/password-score.js', true) | 
            ||
| 722 | ->addJs(  | 
            ||
| 723 | 'js/pbx/GeneralSettings/general-settings-modify.js',  | 
            ||
| 724 | true  | 
            ||
| 725 | );  | 
            ||
| 726 | }  | 
            ||
| 727 | }  | 
            ||
| 728 | |||
| 729 | /**  | 
            ||
| 730 | * Makes assets for the Firewall controller  | 
            ||
| 731 | *  | 
            ||
| 732 | * @param string $action  | 
            ||
| 733 | */  | 
            ||
| 734 | private function makeFirewallAssets(string $action): void  | 
            ||
| 735 |     { | 
            ||
| 736 |         if ($action === 'index') { | 
            ||
| 737 | $this->footerCollectionJS  | 
            ||
| 738 |                 ->addJs('js/pbx/Firewall/firewall-index.js', true); | 
            ||
| 739 |         } elseif ($action === 'modify') { | 
            ||
| 740 | $this->footerCollectionJS  | 
            ||
| 741 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 742 |                 ->addJs('js/pbx/Firewall/firewall-modify.js', true); | 
            ||
| 743 | }  | 
            ||
| 744 | }  | 
            ||
| 745 | |||
| 746 | /**  | 
            ||
| 747 | * Makes assets for the Fail2Ban controller  | 
            ||
| 748 | *  | 
            ||
| 749 | * @param string $action  | 
            ||
| 750 | */  | 
            ||
| 751 | private function makeFail2BanAssets(string $action): void  | 
            ||
| 752 |     { | 
            ||
| 753 |         if ($action === 'index') { | 
            ||
| 754 | $this->footerCollectionJS  | 
            ||
| 755 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 756 |                 ->addJs('js/pbx/Fail2Ban/fail-to-ban-index.js', true); | 
            ||
| 757 | }  | 
            ||
| 758 | }  | 
            ||
| 759 | |||
| 760 | /**  | 
            ||
| 761 | * Makes assets for the Extensions controller  | 
            ||
| 762 | *  | 
            ||
| 763 | * @param string $action  | 
            ||
| 764 | */  | 
            ||
| 765 | private function makeExtensionsAssets(string $action): void  | 
            ||
| 766 |     { | 
            ||
| 767 |         if ($action === 'index') { | 
            ||
| 768 |             $this->headerCollectionCSS->addCss('css/vendor/datatable/dataTables.semanticui.min.css', true); | 
            ||
| 769 | |||
| 770 | $this->footerCollectionJS  | 
            ||
| 771 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 772 |                 ->addJs('js/vendor/inputmask/inputmask.js', true) | 
            ||
| 773 |                 ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) | 
            ||
| 774 |                 ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) | 
            ||
| 775 |                 ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) | 
            ||
| 776 |                 ->addJs('js/vendor/inputmask/init.js', true) | 
            ||
| 777 |                 ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) | 
            ||
| 778 |                 ->addJs('js/pbx/Extensions/extensions-index.js', true) | 
            ||
| 779 |                 ->addJs('js/pbx/main/debugger-info.js', true) | 
            ||
| 780 |                 ->addJs('js/vendor/clipboard/clipboard.js', true); | 
            ||
| 781 |         } elseif ($action === 'modify') { | 
            ||
| 782 |             $this->semanticCollectionCSS->addCss('css/vendor/semantic/card.min.css', true); | 
            ||
| 783 | $this->footerCollectionJS  | 
            ||
| 784 |                 ->addJs('js/vendor/inputmask/inputmask.js', true) | 
            ||
| 785 |                 ->addJs('js/vendor/inputmask/jquery.inputmask.js', true) | 
            ||
| 786 |                 ->addJs('js/vendor/inputmask/jquery.inputmask-multi.js', true) | 
            ||
| 787 |                 ->addJs('js/vendor/inputmask/bindings/inputmask.binding.js', true) | 
            ||
| 788 |                 ->addJs('js/vendor/inputmask/init.js', true) | 
            ||
| 789 |                 ->addJs('js/pbx/Extensions/input-mask-patterns.js', true) | 
            ||
| 790 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 791 |                 ->addJs('js/pbx/main/debugger-info.js', true) | 
            ||
| 792 |                 ->addJs('js/pbx/Extensions/extension-modify.js', true); | 
            ||
| 793 | }  | 
            ||
| 794 | }  | 
            ||
| 795 | |||
| 796 | /**  | 
            ||
| 797 | * Makes assets for the DialplanApplications controller  | 
            ||
| 798 | *  | 
            ||
| 799 | * @param string $action  | 
            ||
| 800 | */  | 
            ||
| 801 | private function makeDialplanApplicationsAssets(string $action): void  | 
            ||
| 802 |     { | 
            ||
| 803 |         if ($action === 'index') { | 
            ||
| 804 | $this->headerCollectionCSS  | 
            ||
| 805 |                 ->addCss('css/vendor/datatable/dataTables.semanticui.css', true); | 
            ||
| 806 | $this->footerCollectionJS  | 
            ||
| 807 |                 ->addJs('js/vendor/datatable/dataTables.semanticui.js', true) | 
            ||
| 808 |                 ->addJs('js/pbx/DialplanApplications/dialplan-applications-index.js', true); | 
            ||
| 809 |         } elseif ($action === 'modify') { | 
            ||
| 810 | $this->footerCollectionACE  | 
            ||
| 811 |                 ->addJs('js/vendor/ace/ace.js', true) | 
            ||
| 812 |                 ->addJs('js/vendor/ace/mode-php.js', true) | 
            ||
| 813 |                 ->addJs('js/vendor/ace/mode-julia.js', true); | 
            ||
| 814 | $this->footerCollectionJS  | 
            ||
| 815 |                 ->addJs('js/pbx/main/form.js', true) | 
            ||
| 816 |                 ->addJs('js/pbx/DialplanApplications/dialplan-applications-modify.js', true); | 
            ||
| 817 | }  | 
            ||
| 818 | }  | 
            ||
| 819 | |||
| 820 | /**  | 
            ||
| 821 | * Makes assets for the CustomFiles controller  | 
            ||
| 822 | *  | 
            ||
| 823 | * @param string $action  | 
            ||
| 824 | */  | 
            ||
| 825 | private function makeCustomFilesAssets(string $action): void  | 
            ||
| 840 | }  | 
            ||
| 841 | }  | 
            ||
| 842 | |||
| 843 | /**  | 
            ||
| 844 | * Makes assets for the CallDetailRecords controller  | 
            ||
| 845 | *  | 
            ||
| 846 | * @param string $action  | 
            ||
| 847 | */  | 
            ||
| 848 | private function makeCallDetailRecordsAssets(string $action): void  | 
            ||
| 849 |     { | 
            ||
| 850 |         if ($action === 'index') { | 
            ||
| 851 |             $this->semanticCollectionJS->addJs('js/vendor/semantic/progress.min.js', true); | 
            ||
| 852 | |||
| 872 | );  | 
            ||
| 873 | }  | 
            ||
| 874 | }  | 
            ||
| 875 | |||
| 876 | /**  | 
            ||
| 877 | * Makes assets for the AsteriskManagers controller  | 
            ||
| 878 | *  | 
            ||
| 879 | * @param string $action  | 
            ||
| 880 | */  | 
            ||
| 881 | private function makeAsteriskManagersAssets(string $action): void  | 
            ||
| 889 | }  | 
            ||
| 890 | }  | 
            ||
| 891 | |||
| 892 | |||
| 893 | }  |