Exemple #1
0
 def boot(self, view: View, event: Event):
     view.share({
         'show_if': self._show_if,
         'env': os.getenv,
         'DEBUG': application.DEBUG
     })
     event.subscribe(UserSignedUp)
    def boot(self, view: View, request: Request):
        """Add helper functions to Masonite."""
        builtins.view = view.render
        builtins.request = request.helper
        builtins.auth = request.user
        builtins.container = self.app.helper
        builtins.env = os.getenv
        builtins.resolve = self.app.resolve
        builtins.route = request.route
        if self.app.has(MailManager):
            builtins.mail_helper = self.app.make(MailManager).helper
        builtins.dd = DD(self.app).dump

        view.share({
            'request': request.helper,
            'auth': request.user,
            'request_method': set_request_method,
            'route': request.route,
            'back': back,
            'sign': sign,
            'unsign': unsign,
            'decrypt': decrypt,
            'encrypt': encrypt,
            'config': config,
            'optional': optional,
            'dd': builtins.dd,
            'hidden': hidden,
            'exists': view.exists,
            'cookie': request.get_cookie,
            'url':
            lambda name, params={}: request.route(name, params, full=True),
            'old': old
        })
Exemple #3
0
 def boot(self, manager: UploadManager, view: View):
     self.app.bind('Upload',
                   manager.driver(self.app.make('StorageConfig').DRIVER))
     self.app.swap(Upload,
                   manager.driver(self.app.make('StorageConfig').DRIVER))
     view.share({
         'static': static,
     })
Exemple #4
0
    def boot(self, request: Request, view: View, session: SessionManager):
        self.app.bind('Session',
                      session.driver(self.app.make('SessionConfig').DRIVER))
        self.app.swap(Session,
                      session.driver(self.app.make('SessionConfig').DRIVER))
        request.session = self.app.make('Session')

        view.share({'session': self.app.make('Session').helper})
Exemple #5
0
    def boot(self, view: View):
        """Add custom helper functions to Masonite."""

        builtins.return_with_errors = return_with_errors
        builtins.error_response = error_json_response
        builtins.success_response = success_json_response
        builtins.abort_404 = abort_404
        builtins.abort_403 = abort_403

        view.share({"mix": mix})
Exemple #6
0
    def boot(self, view: View, request: Request):
        """Add helper functions to Masonite."""
        builtins.view = view.render
        builtins.request = request.helper
        builtins.auth = request.user
        builtins.container = self.app.helper
        builtins.env = os.getenv
        builtins.resolve = self.app.resolve
        builtins.route = request.route
        if self.app.has(MailManager):
            builtins.mail_helper = self.app.make(MailManager).helper
        builtins.dd = DD(self.app).dump

        view.share({
            'request': request.helper,
            'auth': request.user,
            'request_method': set_request_method,
            'route': request.route,
            'back': back
        })
 def boot(self, request: Request, view: View):
     state = AppState()
     view.share({"state": state.get(request)})
Exemple #8
0
 def boot(self, view: View):
     """Boots services required by the container."""
     self.view = view
     view.share({'component': self.helper})
 def boot(self, view: View):
     view.share({'hashid': hashid})
    def boot(self, validator: Validator, view: View):
        validator.extend(ValidationFactory().registry)

        view.share({'bag': MessageBag.view_helper})
 def boot(self, view: View):
     view.share({
         "len": len,
     })