def register_database(self): from masoniteorm.query import QueryBuilder self.application.bind( "builder", QueryBuilder(connection_details=config("database.databases")), ) self.application.bind("migrations.location", "databases/migrations") self.application.bind("seeds.location", "databases/seeds") self.application.bind("resolver", config("database.db"))
def apply_filters(self, group): if group: return self.filter_by_groups(group) # return unfiltered routes if user set both config options. if config("js_routes.filters.except") and config("js_routes.filters.only"): return self.routes if config("js_routes.filters.except"): return self.except_routes() if config("js_routes.filters.only"): return self.only_routes() return self.routes
def register_configurations(self): # load configuration self.application.bind("config.location", "config") configuration = Configuration(self.application) configuration.load() self.application.bind("config", configuration) key = config("application.key") self.application.bind("key", key) self.application.bind("sign", Sign(key)) # set locations self.application.bind("resources.location", "resources/") self.application.bind("controllers.location", "app/controllers") self.application.bind("jobs.location", "app/jobs") self.application.bind("providers.location", "app/providers") self.application.bind("mailables.location", "app/mailables") self.application.bind("listeners.location", "app/listeners") self.application.bind("validation.location", "app/validation") self.application.bind("notifications.location", "app/notifications") self.application.bind("events.location", "app/events") self.application.bind("tasks.location", "app/tasks") self.application.bind("models.location", "app/models") self.application.bind("observers.location", "app/models/observers") self.application.bind("policies.location", "app/policies") self.application.bind("commands.location", "app/commands") self.application.bind("middlewares.location", "app/middlewares") self.application.bind("server.runner", "masonite.commands.ServeCommand.main")
def register_configurations(self): # load configuration self.application.bind("config.location", "tests/integrations/config") configuration = Configuration(self.application) configuration.load() self.application.bind("config", configuration) key = config("application.key") self.application.bind("key", key) self.application.bind("sign", Sign(key)) # set locations self.application.bind("controllers.location", "tests/integrations/controllers") self.application.bind("jobs.location", "tests/integrations/jobs") self.application.bind("providers.location", "tests/integrations/providers") self.application.bind("mailables.location", "tests/integrations/mailables") self.application.bind("listeners.location", "tests/integrations/listeners") self.application.bind("validation.location", "tests/integrations/validation") self.application.bind("notifications.location", "tests/integrations/notifications") self.application.bind("events.location", "tests/integrations/events") self.application.bind("tasks.location", "tests/integrations/tasks") self.application.bind("server.runner", "masonite.commands.ServeCommand.main")
def __init__(self, group=None): self.base_domain = "" self.base_port = None self.base_protocol = "http" self.base_url = config("application.app_url").rstrip("/") self.parse_base_url() self.group = group self.routes = self.get_named_routes()
def filter_by_groups(self, group): """Filters routes by group""" groups = config("js_routes.filters.groups", {}) if isinstance(group, list): filters = [] for group_name in group: filters += groups.get(group_name, []) return self.filter_routes(filters) else: groups_filters = groups.get(group, []) if groups_filters: return self.filter_routes(groups_filters) return self.routes
from masonite.foundation import Application, Kernel from masonite.utils.location import base_path from masonite.configuration import config from Kernel import Kernel as ApplicationKernel """Start The Application Instance.""" application = Application(base_path()) """Now Bind important providers needed to make the framework work.""" application.register_providers(Kernel, ApplicationKernel) """Now Bind important application specific providers needed to make the application work.""" application.add_providers(*config("providers.providers"))
def only_routes(self): return self.filter_routes(config("js_routes.filters.only"))
def except_routes(self): return self.filter_routes(config("js_routes.filters.except"), False)
def build(self): return (self.subject("Reset Password").from_( config("mail.from_address")).view("auth.mailables.reset_password", {"token": self.token}))