"handle" function for resetting app.

@param \Illuminate\Contracts\Container\Container $app
@param \SwooleTW\Http\Server\Sandbox $sandbox

@return \Illuminate\Contracts\Container\Container
514096
public function handle(Container $app, Sandbox $sandbox)
    {
        $view = $app->make('view');

        $closure = function () use ($app) {
            $this->container = $app;
            $this->shared['app'] = $app;
        };

        $resetView = $closure->bindTo($view, $view);
        $resetView();

        return $app;
    }
1282589
public function registerAutoPresenter(Container $app)
    {
        $app->singleton('autopresenter', function (Container $app) {
            $autoPresenter = new AutoPresenter();

            $autoPresenter->register(new AtomDecorator($autoPresenter, $app));
            $autoPresenter->register(new ArrayDecorator($autoPresenter));
            $autoPresenter->register(new PaginatorDecorator($autoPresenter));

            return $autoPresenter;
        });

        $app->alias('autopresenter', AutoPresenter::class);
    }
1303205
public function boot(Application $app)
    {
        $app->on(KernelEvents::EXCEPTION, function (GetResponseForExceptionEvent $event) {
            $e = $event->getException();
            if ($e instanceof MethodNotAllowedHttpException && $e->getHeaders()["Allow"] === "OPTIONS") {
                $event->setException(new NotFoundHttpException("No route found for \"{$event->getRequest()->getMethod()} {$event->getRequest()->getPathInfo()}\""));
            }
        });
    }
695416
protected function bindSandbox()
    {
        $this->app->singleton(Sandbox::class, function ($app) {
            return new Sandbox($app, $this->framework);
        });

        $this->app->alias(Sandbox::class, 'swoole.sandbox');
    }
451480
public function handle(EventInterface $event)
    {

        try {
            // load the application server and the naming directory instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // deploy the applications for all containers
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\ContainerConfigurationInterface $containerNode */
            foreach ($applicationServer->getSystemConfiguration()->getContainers() as $containerNode) {
                // load the container instance to deploy the applications for
                /** @var \AppserverIo\Psr\ApplicationServer\ContainerInterface $container */
                $container = $namingDirectory->search(
                    sprintf(
                        'php:services/%s/%s',
                        $applicationServer->runlevelToString(ApplicationServerInterface::NETWORK),
                        $containerNode->getName()
                    )
                );

                // iterate over all applications and shut them down
                /** @var \AppserverIo\Psr\Application\ApplicationInterface $application */
                foreach ($container->getApplications() as $application) {
                    $application->stop();
                }
            }

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
312065
public function register(Container $app)
    {
        $routerContainer = new RouterContainer();
        $app[Map::class] = $routerContainer->getMap();
        $app[RuleIterator::class] = $routerContainer->getRuleIterator();
    }
453972
protected function instantiateUploadAdapters(Container $app)
    {
        /** @var Settings $settings */
        $settings = $app->make(Settings::class);

        $settings->getMimeTypesConfiguration()
            ->each(function ($mimetype) use ($app, $settings) {
                $adapter = Arr::get($mimetype, 'adapter', $mimetype);

                // Skip if already bound.
                if ($app->bound("flagrow.upload-adapter.$adapter")) {
                    return;
                }

                $app->bind("flagrow.upload-adapter.$adapter", function () use ($settings, $adapter) {
                    switch ($adapter) {
                        case 'aws-s3':
                            if (class_exists(S3Client::class)) {
                                return $this->awsS3($settings);
                            }
                        case 'ovh-svfs':
                            if (class_exists(OVHClient::class)) {
                                return $this->ovh($settings);
                            }
                        case 'imgur':
                            return $this->imgur($settings);

                        default:
                            return $this->local($settings);
                    }
                });
            });
    }
21844
public function register(Container $app)
    {
        $app["cache.service"] = function(Container $app) {
            $handlerClass = ucfirst($app["config.service"]["cache.handler"]);

            return new \SlaxWeb\Cache\Manager(
                $app["cache{$handlerClass}Handler.service"]
            );
        };

        $app["cacheFileHandler.service"] = function(Container $app) {
            return new \SlaxWeb\Cache\Handler\File(
                $app["config.service"]["cache.location"],
                $app["config.service"]["cache.maxAge"]
            );
        };
    }
840014
public function register(Container $app)
    {
        $app["serializer.namingStrategy"] = "CamelCase";
        $app["serializer.namingStrategy.separator"] = "_";
        $app["serializer.namingStrategy.lowerCase"] = true;

        $app["serializer.propertyNamingStrategy"] = new PropertyNamingStrategyService();
        $app["serializer.builder"] = new BuilderService();
        $app["serializer"] = function (Container $app) {
            return $app["serializer.builder"]->build();
        };
    }
712603
public function run(Application $app)
    {
        $this->trigger(self::EVENT_BEFORE_RUN);
        if (count($this->_afterCallbacks) > 0) {
            $this->runCommandInForeground($app);
        } else {
            $this->runCommandInBackground($app);
        }
        $this->trigger(self::EVENT_AFTER_RUN);
    }
8320
public static function setSandbox($sandbox)
    {
        if ($sandbox == true) {
            static::setEnvironment(Environment::SANDBOX);
        } else {
            static::setEnvironment(Environment::PRODUCTION);
        }
    }
172566
public function boot(Application $app)
    {
        // Register Monolog error handler for fatal errors here because Symfony's handler overrides it
        $monologErrorHandler = new MonologErrorHandler($app['log']);

        $monologErrorHandler->registerErrorHandler();
        $monologErrorHandler->registerFatalHandler();
    }
146541
public static function start($app)
    	{
    		// Here, we will go ahead and "boot" the application for usage. This simply
    		// calls the boot method on all of the service providers so they get all
    		// their work done and are ready to handle interacting with dev input.
    		$app->boot();

    		$artisan = require __DIR__ . '/start.php';

    		$artisan->setAutoExit(false);

    		// If the event dispatcher is set on the application, we will fire an event
    		// with the Artisan instance to provide each listener the opportunity to
    		// register their commands on this application before it gets started.
    		if (isset($app['events'])) {
    			$app['events']->fire('artisan.start', array($artisan));
    		}

    		return $artisan;
    	}
692943
public function execute(Sandbox $sandbox)
  {
    $language = new ExpressionLanguage($sandbox);
    Container::getLogger()->info("Evaluating expression: " . $language->compile($this->expression));
    try {
      if ($return = $language->evaluate($this->expression)) {
        Container::getLogger()->debug(__CLASS__ . ": Expression PASSED: $return");
        return $return;
      }
    }
    catch (\Exception $e) {
      Container::getLogger()->warning($e->getMessage());
    }
    Container::getLogger()->debug(__CLASS__ . ": Expression FAILED.");

    // Execute the on fail behaviour.
    throw new DependencyException($this);
  }
416486
protected function requireAuthorization(Application $app)
    {
        /** @var ResourceServer $server */
        $server = $app[ResourceServer::class];
        try {
            $server->isValidRequest(false);
        } catch(OAuthException $e) {
            return new JsonResponse(
                [
                    'error' => $e->errorType,
                    'message' => $e->getMessage(),
                ],
                $e->httpStatusCode,
                $e->getHttpHeaders()
            );
        }
        return null;
    }
196594
public function extend(Container $app)
    {
        foreach ($this->getEnabledExtensions() as $extension) {
            $extension->extend($app);
        }
    }
1301950
function removeApp(container) {
  var elem = new Elem(container).elem(0);

  if (!elem.length) {
    console.error('No valid element to remove the app from was given! (removeApp)');

    return;
  }

  container = elem[0];

  var _container = container,
      DwayneRootBlock = _container.DwayneRootBlock;


  if (!(DwayneRootBlock instanceof Block)) {
    console.error('No app registered inside the given element! (removeApp)');

    return;
  }

  DwayneRootBlock.$$.remove();
  elem.removeAttr('dwayne-root');

  delete container.DwayneRootBlock;
}