startStopAllProcessesAction

@param Request $request
@param string $start 1 to start, 0 to stop it
@param string $key The key to retrieve a Supervisor object
@return \Symfony\Component\HttpFoundation\RedirectResponse|Response
@throws \Exception
176911
public function startStopAllProcessesAction(Request $request, $start, $key)
    {
        $supervisor = $this->get('supervisor.manager')->getSupervisorByKey($key);

        if (!$supervisor) {
            throw new \Exception('Supervisor not found');
        }

        $processesInfo = true;
        if ($start == "1") {
            $processesInfo = $supervisor->startAllProcesses(false);
        } elseif ($start == "0") {
            $processesInfo = $supervisor->stopAllProcesses(false);
        }

        if ($request->isXmlHttpRequest()) {
            $res = json_encode([
                'processesInfo' => $processesInfo
            ]);

            return new Response($res, 200, [
                'Content-Type' => 'application/json',
                'Cache-Control' => 'no-store',
            ]);
        }

        return $this->redirect($this->generateUrl('supervisor'));
    }
587968
protected function handle(Request $request)
    {
        try {
            list($routeInformation, $parameters) = $this->findRoute($request);

            return (new Pipeline($this->container))
                ->through($routeInformation['middlewares'])
                ->send($request)
                ->then(function (Request $request) use ($routeInformation, $parameters) {
                    if ($routeInformation['action'] instanceof Closure) {
                        return call_user_func_array($routeInformation['action'], $parameters);
                    }

                    list($controller, $action) = $routeInformation['action'];
                    $controllerInstance = new $controller;

                    if ($controllerInstance instanceof KeeperBaseController) {
                        $controllerInstance->setContainer($this->container);
                        $controllerInstance->setRequest($request);
                    }

                    return call_user_func_array([$controllerInstance, $action], $parameters);
                });

        } catch (Throwable $exception) {
            if ($this->exceptionHandler) {
                return $this->exceptionHandler->handle($exception, $request);
            }

            return new Response((string)$exception, 500);
        }
    }
530173
public function run(Request $request, Response $response)
    {
        $this["logger.service"]("System")->info("Beginning process for request.", [$request]);

        $this->setRequestProperties($request);

        $result = $this["hooks.service"]->exec(
            "application.dispatch.before",
            $request,
            $response,
            $this
        );
        if ($result === "exit"
            || (is_array($result) && in_array("exit", $result))) {
            return;
        }

        // record the time before execution
        $start = microtime(true);

        // dispatch request
        try {
            $this["routeDispatcher.service"]->dispatch($request, $response, $this);
        } catch (RouteNotFoundException $routeNotFound) {
            $this["logger.service"]("System")->error("No Route found for Request");
            $this["logger.service"]("System")->debug(
                "No Route Found Debug Information",
                ["exception" => $routeNotFound]
            );

            $response->setStatusCode(404);
            $response->setContent($this->load404Page());
            throw $routeNotFound;
        }

        $this["logger.service"]("System")->info(
            "Request has finished processing, Response is ready to be sent to "
            . "caller."
        );

        $this["hooks.service"]->exec("application.dispatch.after");

        // record the time after execution
        $end = microtime(true);
        $this["logger.service"]("System")->debug(
            "Time taken to finish Request processing",
            [
                "start"     =>  $start,
                "end"       =>  $end,
                "elapsed"   =>  $end - $start,
                "uri"       =>  $request->getRequestUri()
            ]
        );
    }
1207213
protected function startSession(Request $request)
    {
        $session = parent::startSession($request);

        $locale = DashboardLanguageFacade::getDashboardLanguage();

        app()->setLocale($locale);

        Event::fire(new SessionStarted($session));

        return $session;
    }
394649
public function destroy(Request $request, $key)
    {
        $this->getFormRequestInstance();

        $model = $this->findFirstByKey($key);

        if (!$model) {
            if ($request->wantsJson()) {
                return $this->validNotFoundJsonResponse();
            }
            abort(404);
        }

        DB::beginTransaction();

        try {
            $this->repository->delete($model);
        } catch (\Exception $e) {
            DB::rollback();

            $message = $this->destroyFailedMessage($key, $e->getMessage());
            throw new ResourceControllerException($message);
        }

        DB::commit();

        $message = $this->destroySuccessfulMessage($key);

        if ($request->wantsJson()) {
            $data = [
                $model
            ];

            return $this->validSuccessJsonResponse($message, $data);
        }

        return redirect()->route($this->getRedirectionRoute())
            ->with($this->infoFlashMessageKey, $message);
    }
171131
protected function startSession(Request $request)
    {
        $this->gc();
        $this->session->setId($request->getCookies()->get($this->session->getName()));
        $this->sessionHandler->open(null, $this->session->getName());
        $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId()));

        if ($sessionVars === false) {
            $sessionVars = [];
        }

        $this->session->start($sessionVars);
    }
1099744
public function edit(Request $request, $key)
    {
        if ($request->wantsJson()) {
            return $this->validNotFoundJsonResponse();
        }

        $model = $this->findFirstByKey($key);

        if (!$model) {
            abort(404);
        }

        $view = $this->getViewLocation(__FUNCTION__);
        $this->checkViewExists($view);

        return response()->view($view, compact('model'));
    }
950282
public function startJob(ExecuteJobRequest $request)
    {
        $this->worker->setState(Worker::BUSY);

        $requestId = $request->getRequestId();
        $action    = $request->getAction();
        if (!$this->worker->hasAction($action)) {
            $this->getLogger()->debug('Action '.$action.' not found.');
            $this->sendToWorkerHandler(new ActionNotFound($requestId, $action));

            return;
        }

        $this->getLogger()->debug('Sending new request ('.$requestId.') to action '.$action);
        $this->serviceStream->send($request);
    }
974870
public function run(Request $request)
    {
        $this->container = $this->container ?: new Container;
        
        try {
            if (! is_string($this->action['uses'])) {
                return $this->runCallable($request);
            }
            
            list($class, $method) = explode('@', $this->action['uses']);
            $cl = new ClassLoader;
            $cl->addPsr4($this->getAppNamespace(), app('path'));
            $file = $cl->findFile($class);
            $cmd = 'php -l ' . $file;
            
            if (strpos(exec($cmd, $output), 'No syntax errors detected') === false) {
                $route = array_get($this->action, 'as', $this->action['uses']);
                $error = head(array_filter($output));
                
                throw new SyntaxErrorException($route, $error);
            }
            
            set_error_handler([$this, 'error']);
            
            if ($this->customDispatcherIsBound()) {
                return $this->runWithCustomDispatcher($request);
            }
            
            return $this->runController($request);
        } catch (HttpResponseException $e) {
            return $e->getResponse();
        }
    }
768375
public function begin($request, $endpoint, $method, $reference)
    {
        $this->startTimestamp = microtime(true);

        $this->lastEvent = $this->eventFactory->create($request, $endpoint, $method, $reference);

        return $this->adapter->save($this->lastEvent);
    }
1299111
public function run( Request $request )
	{
		try
		{
			if ( !is_string( $this->action['uses'] ) )
				return $this->runCallable( $request );

			return $this->runController( $request );
		}
		catch ( HttpResponseException $e )
		{
			return $e->getResponse();
		}
	}
1363854
public function start(Request $request, AuthenticationException $authException = null)
    {
        //The URL have to be completed by the current request uri,
        // because Cas Server need to know where redirect user after authentication.
        return new RedirectResponse($this->cas->getUri().$request->getUri());
    }
1301179
public function lRange($key, $start = null, $stop = null) {
        if (null === $start) {
            $start = 0;
        }
        if (null === $stop) {
            $stop = -1;
        }
        return $this->_redis->lRange($key, $start, $stop);
    }
392749
public function execute(Request $request)
    {
        $command = $request->input('command');

        if ($command === '') {
            $command = 'list';
        }

        $output= new BufferedOutput;

        Artisan::handle(new StringInput($command.self::NON_INTERACTIVE), $output);
        $results = $output->fetch();

        return view('gae-support-l5::artisan', compact(['command', 'results']));
    }
771467
public function executeAction(Request $request)
    {
        /**
         * @var FormInterface $form
         */
        $form = $this
            ->formFactory
            ->create('stripe_view');

        $form->handleRequest($request);
        $redirect = $this
            ->redirectionRoutes
            ->getRedirectionRoute('success');

        try {
            if (!$form->isValid()) {
                throw new PaymentException();
            }

            $data = $form->getData();
            $paymentMethod = $this->createStripeMethod($data);
            $this
                ->stripeManager
                ->processPayment($paymentMethod, $data['amount']);
        } catch (Exception $e) {

            /**
             * Must redirect to fail route.
             */
            $redirect = $this
                ->redirectionRoutes
                ->getRedirectionRoute('failure');
        }

        $redirectUrl = $this
            ->urlGenerator
            ->generate(
                $redirect->getRoute(),
                $redirect->getRouteAttributes(
                    $this->paymentBridge->getOrderId()
                )
            );

        return new RedirectResponse($redirectUrl);
    }
482555
public function launch(Request $request, Response $response)
    {
        if (count($this->routes) === 0) {
            throw new \RuntimeException("No routes defined");
        }

        $this->uri = $request->httpRequest->getPath();

        if ($this->uri = null) {
            $this->uri = "/";
        }

        $request->on('end', function () use (&$request, &$response) {
            $this->matchRoutes($request, $response);  
        });

        $request->on('error', function ($error) use (&$request, &$response) {
            $this->emit('error', [$request, $response, $error]);
        });

        $request->parseData();
    }
572758
public function overflow($key, $start = null, $stop = null)
    {
        return $this->_getClient()->lTrim($key, $start, $stop);
    }