public function getTypes(ImportEvent $event) { $types = array_map(function ($f) { return $f['TYPE']; }, MConfig::select('TYPE')->get()->toArray()); $event->setContent(['types' => $types]); }
public function getCached(ImportEvent $event) { $data = $this->cache->get('admin-panels-cached', function () use($event) { $fresh = new ImportEvent($event->getViewEvent()); $this->dispatcher->fire(AdminEvent::IMPORT_ADMIN_DASHBOARD_PANELS, $fresh); return $fresh->getContent(); }, 300); $event->setContent($data); }
public function getSubsCount(ImportEvent $event) { $lists = MArList::all(); foreach ($lists as $list) { $list_id = $list->ar_list_id; $subs = $this->getTargetUserIds($list_id); $results[$list_id] = count($subs); } $event->setContent($results ?? []); }
public function getPages(ImportEvent $event) { $urls = []; $routes = $this->router->getRouteCollection(); /** @var RouteEx $route */ foreach ($routes as $route) { $method = $route->getMethods()[0]; $hasView = $route->getDefault('_noView') !== true; if ($method === 'GET' && $hasView) { $compiled = $route->compile(); $urls[] = $compiled->getStaticPrefix(); //$urls[$url] = !preg_match('~^/(admin|\_|first\-run|auth)~', $url); } } $event->setContent($urls); }
public function compile(ImportEvent $event) { $plugins = []; $basedir = realpath(sprintf('%s/../../../..', __DIR__)); $results = $this->cache->get('plugin-list', function () { return $this->client->getPackages(); }, 300); foreach ($results ?? [] as $package) { $plugin = $package['name']; if ($plugin !== 'minutephp/minutephp' && $plugin !== 'minutephp/framework') { $name = join(' ', array_slice(preg_split('/\\W+/', $plugin), 1)); $vendor = dirname($plugin); $official = $vendor === 'minutephp'; $type = $official ? 'official' : 'thirdparty'; $required = ['admin', 'framework']; $plugins[$type][] = ['plugin' => $plugin, 'name' => $name, 'description' => $package['description'], 'installed' => is_dir("{$basedir}/{$plugin}"), 'required' => $official && in_array($name, $required), 'src' => $package['src']]; } } $event->setContent($plugins); }
public function getHttpdConf(ImportEvent $event) { $httpd = file_get_contents(__DIR__ . '/data/apache.conf.txt'); $conf = $this->engine->render($httpd, array_merge($this->config->getPublicVars(), ['path' => realpath($this->bootLoader->getBaseDir() . '/public')])); $event->setContent(['conf' => $conf]); }