public function testHelpersFacade() { $this->assertInstanceOf(\Clarity\Support\Auth\Auth::class, auth()); $this->assertInstanceOf(\Phalcon\Config::class, config()); $this->assertInstanceOf(\Phalcon\Mvc\Dispatcher::class, dispatcher()); $this->assertInstanceOf(\Phalcon\Filter::class, filter()); $this->assertInstanceOf(\Phalcon\Flash\Direct::class, flash()->direct()); $this->assertInstanceOf(\Phalcon\Flash\Session::class, flash()->session()); $this->assertInstanceOf(\League\Flysystem\Filesystem::class, flysystem()); $this->assertInstanceOf(\League\Flysystem\MountManager::class, flysystem_manager()); $this->assertInstanceOf(\Clarity\Support\Redirect\Redirect::class, redirect()); $this->assertInstanceOf(\Clarity\Support\Phalcon\Http\Request::class, request()); $this->assertInstanceOf(\Phalcon\Http\Response::class, response()); $this->assertInstanceOf(\Phalcon\Mvc\Router::class, route()); $this->assertInstanceOf(\Phalcon\Security::class, security()); $this->assertInstanceOf(\Phalcon\Tag::class, tag()); $this->assertInstanceOf(\Phalcon\Mvc\Url::class, url()); $this->assertInstanceOf(\Phalcon\Mvc\View::class, view()); # getting an error, will check later on $this->assertInstanceOf(\Monolog\Logger::class, logger()); # adapter base functions // $this->assertInstanceOf(, cache()); // $this->assertInstanceOf(, db()); // $this->assertInstanceOf(, queue()); // $this->assertInstanceOf(, session()); $this->assertContains(url()->getBaseUri() . 'auth/login', route('showLoginForm')); $this->assertInstanceOf(\Phalcon\Mvc\View::class, view('welcome')); }
/** * Get the filesystem manager. * * @return mixed */ protected function getFlysystem() { return flysystem_manager($this->getSandboxPath()); }
/** * {@inheritdoc} */ public function slash() { $app_filesystem = flysystem_manager($this->getAppPath()); $raw_module = $this->getModuleName(false); $module = $this->getModuleName(); # check if module exists, throw error if it doesn't exists if ($app_filesystem->has($module) === false) { $this->error("Module [{$module}] not found"); return; } $this->info('Crafting Route Group...'); $route = $this->getRouteName(); # check route file if exists, throw error if exists if ($app_filesystem->has($module . '/' . $route)) { $this->error(" Route [{$this->input->getArgument('name')}] " . "already exists in your Module [{$this->input->getArgument('module')}]"); return; } # get the route stub and stubify the {routeName} # based on argument route name $buff = stubify($this->getRouteStub(), ['namespace' => path_to_namespace(str_replace($this->getBasePath(), '', $this->getNamespace())), 'routeName' => $this->getRouteName(false), 'routeFunctions' => $this->getRouteFunctions()]); # now write the content based on $route path $module_filesystem = flysystem_manager($this->getModulePath()); $module_filesystem->put($route, $buff); $this->info(' ' . $route . ' created!'); }
/** * {@inheritdoc} */ public function slash() { $app_filesystem = flysystem_manager($this->getAppPath()); $public_filesystem = flysystem_manager($this->getPublicPath()); # get the module name $module = $this->getModuleName(); $this->info('Crafting Module...'); $controller_buff = $this->getContentByStub($this->getBaseControllerStub()); $router_buff = $this->getContentByStub($this->getBaseRouteStub()); $routes_buff = $this->getContentByStub($this->getRoutesStub()); $public_buff = stubify($this->getPublicStub(), ['module' => '\'' . $module . '\'']); # their possible path $base_controller = "{$module}/controllers/Controller.php"; $base_router = "{$module}/routes/RouteGroup.php"; $routes_file = "{$module}/routes.php"; $public_file = $module . '.php'; # now save the stubbed content into the their path if ($app_filesystem->has($base_controller) === false) { $this->info(' Base Controller created!'); $app_filesystem->put($base_controller, $controller_buff); } else { $this->error(' Base Controller already exists!'); } if ($app_filesystem->has($base_router) === false) { $this->info(' Router Group created!'); $app_filesystem->put($base_router, $router_buff); } else { $this->error(' Route Group already exists!'); } if ($app_filesystem->has($routes_file) === false) { $this->info(' Routes file created!'); $app_filesystem->put($routes_file, $routes_buff); } else { $this->error(' Routes file already exists!'); } if ($public_filesystem->has($public_file) === false) { $this->info(' Public Index created!'); $public_filesystem->put($public_file, $public_buff); } else { $this->error(' Public Index already exists!'); } $this->callDumpAutoload(); }
/** * {@inheritdoc} */ public function slash() { $app_filesystem = flysystem_manager($this->getAppPath()); $module = $this->getModuleName(); # check if module exists, throw error if it doesn't exists if ($app_filesystem->has($module) === false) { $this->error("Module [{$module}] not found"); return; } $this->info('Crafting Controller...'); $controller = $this->getControllerName(); # check controller file if exists, throw error if exists if ($app_filesystem->has($module . '/' . $controller)) { $this->error(" Controller [{$this->input->getArgument('name')}] " . "already exists in your Module [{$this->input->getArgument('module')}]"); return; } # get the controller stub and stubify the {controllerName} # based on argument controller name $buff = stubify($this->getControllerStub(), ['namespace' => path_to_namespace(str_replace($this->getBasePath(), '', $this->getNamespace())), 'controllerName' => $this->getControllerName(false), 'controllerFunctions' => $this->getControllerFunctions()]); # now write the content based on $controller path $module_filesystem = flysystem_manager($this->getModulePath()); $module_filesystem->put($controller, $buff); $this->info(' ' . $controller . ' created!'); $this->callDumpAutoload(); }
/** * {@inheritdoc} */ public function slash() { $app_filesystem = flysystem_manager($this->getAppPath()); $public_filesystem = flysystem_manager($this->getPublicPath()); # get the module name $raw_module = $this->getModuleName(false); $module = $this->getModuleName(); $this->info('Crafting Module...'); $controller_buff = $this->getContentByStub($this->getBaseControllerStub(), 'Controllers'); $routes_group_buff = $this->getContentByStub($this->getBaseRouteStub(), 'Routes'); $routes_buff = $this->getContentByStub($this->getRoutesStub()); $public_buff = stubify($this->getPublicStub(), ['module' => '\'' . $raw_module . '\'']); $base_route_provider_buff = $this->getContentByStub($this->getBaseRouteProviderStub(), 'Providers'); $base_route_provider_buff = stubify($base_route_provider_buff, ['raw_module' => $raw_module, 'module' => $module]); # their possible path $base_controller = "{$module}/Controllers/Controller.php"; $base_routes = "{$module}/Routes/RouteGroup.php"; $routes_file = "{$module}/Routes.php"; $public_file = $raw_module . '.php'; $base_route_provider = "{$module}/Providers/RouterServiceProvider.php"; # now save the stubbed content into the their path if ($app_filesystem->has($base_controller) === false) { $this->info(' Base Controller created!'); $app_filesystem->put($base_controller, $controller_buff); } else { $this->error(' Base Controller already exists!'); } if ($app_filesystem->has($base_routes) === false) { $app_filesystem->put($base_routes, $routes_group_buff); $this->info(' Route Group created!'); } else { $this->error(' Route Group already exists!'); } if ($app_filesystem->has($routes_file) === false) { $app_filesystem->put($routes_file, $routes_buff); $this->info(' Routes file created!'); } else { $this->error(' Routes file already exists!'); } if ($public_filesystem->has($public_file) === false) { $public_filesystem->put($public_file, $public_buff); $this->info(' Public file created!'); } else { $this->error(' Public Index already exists!'); } if ($app_filesystem->has($base_route_provider) === false) { $app_filesystem->put($base_route_provider, $base_route_provider_buff); $this->info(' Route Service created!'); } else { $this->error(' Route Service already exists!'); } $this->getOutput()->writeln("\n" . ' <comment>Append route service inside [config/app.php]: </comment>' . path_to_namespace(str_replace($this->getBasePath(), '', $this->getNamespace()) . '/Providers/RouterServiceProvider') . '::class'); }