Redirect callback

If a special redirect key is provided, change the
redirection URL target

@param Event $event Event
@return void
@throws \Exception
439725
public function beforeRedirect(Event $event)
    {
        $subject = $event->getSubject();

        $redirects = $this->_action()->redirectConfig();
        if (empty($redirects)) {
            return;
        }

        foreach ($redirects as $redirect) {
            if (!$this->_getKey($subject, $redirect['reader'], $redirect['key'])) {
                continue;
            }

            $subject->url = $this->_getUrl($subject, $redirect['url']);
            break;
        }
    }
724543
public static function setPermissionsChmod(Event $event)
	{
		$http_user = self::getHttpdUser($event);
		foreach (self::getWritableDirs($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'dir');
		}
		foreach (self::getWritableFiles($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
		}
	}
516117
public function onComplete(CompleteEvent $event)
    {
        $response = $event->getResponse();

        if (substr($response->getStatusCode(), 0, 1) != '3' ||
            !$response->hasHeader('Location')
        ) {
            return;
        }

        $redirectCount = 0;
        $redirectRequest = $event->getRequest();
        $redirectResponse = $response;
        $max = $redirectRequest->getConfig()->getPath('redirect/max') ?: 5;

        do {
            if (++$redirectCount > $max) {
                throw new TooManyRedirectsException(
                    "Will not follow more than {$redirectCount} redirects",
                    $redirectRequest
                );
            }
            $redirectRequest = $this->createRedirectRequest($redirectRequest, $redirectResponse);
            $redirectResponse = $event->getClient()->send($redirectRequest);
        } while (substr($redirectResponse->getStatusCode(), 0, 1) == '3' &&
            $redirectResponse->hasHeader('Location')
        );

        if ($redirectResponse !== $response) {
            $event->intercept($redirectResponse);
        }
    }
1187332
public function onComplete(CompleteEvent $event)
    {
        $response = $event->getResponse();

        if (substr($response->getStatusCode(), 0, 1) != '3'
            || !$response->hasHeader('Location')
        ) {
            return;
        }

        $request = $event->getRequest();
        $config = $request->getConfig();

        // Increment the redirect and initialize the redirect state.
        if ($redirectCount = $config['redirect_count']) {
            $config['redirect_count'] = ++$redirectCount;
        } else {
            $config['redirect_scheme'] = $request->getScheme();
            $config['redirect_count'] = $redirectCount = 1;
        }

        $max = $config->getPath('redirect/max') ?: 5;

        if ($redirectCount > $max) {
            throw new TooManyRedirectsException(
                "Will not follow more than {$redirectCount} redirects",
                $request
            );
        }

        $this->modifyRedirectRequest($request, $response);
        $event->retry();
    }
286351
public function onRequestCreate(Event $event)
    {
        $event['request']->setAuth($this->username, $this->password, $this->scheme);
    }
842167
public function join(Event $event)
    {
        $this->authorize('join', Event::class);
        $event->addUser(User::findOrfail(Auth::id()));

        return redirect()->route('laralum::events.index')
            ->with('success', __('laralum_events::general.joined_event', ['id' => $event->id]));
    }
519201
public function send(Event $event)
    {
        $message = $this->getEventMessage($event);
        $this->flush($message);
    }
338624
protected function start(Event $event): void
    {
        // if sendOutputTo or appendOutputTo have been specified
        if (!$event->nullOutput()) {
            // if sendOutputTo then truncate the log file if it exists
            if (!$event->shouldAppendOutput) {
                $f = @\fopen($event->output, 'r+');
                if (false !== $f) {
                    \ftruncate($f, 0);
                    \fclose($f);
                }
            }
            // Create an instance of the Logger specific to the event
            $event->logger = $this->loggerFactory->create(
                [
                    // Logging streams
                    'info' => $event->output,
                ]
            );
        }

        $this->consoleLogger
            ->debug("Invoke Event's ping before.");

        $this->pingBefore($event);

        // Running the before-callbacks
        $event->outputStream = ($this->invoke($event->beforeCallbacks()));
        $event->start();
    }
137386
public function onEndRequest($event)
    {
        if (!$this->_ended) {
            $this->_ended = true;
            $this->raiseEvent('endRequest', $event);
        }
    }
698904
final protected function apply(DomainEvent $event) : void
    {
        $this->handleEventInAggregate($event);
        parent::raise($event);
    }
451026
public function onBeforeSend(Event $event)
    {
        global $logger;
        $req        = $event['request'];
        $options    = $this->_options;
        $algorithms = array(
            'sha1',
            'sha256',
            'sha512'
        );

        if(empty($options['key']))
            $options['key'] = $this->_app->getConfiguration()->getSharedKey();
        if(empty($options['secret']))
            $options['secret'] = $this->_app->getConfiguration()->getSecretKey();

        if (!isset($options['key']) || !is_string($options['key']))
            throw new \Exception("options.key must be a String");
        if (isset($options['algorithm']) && !is_string($options['algorithm']))
            throw new \Exception("options.algorithm must be a String");
        if (isset($options['headers']) && !is_array($options['headers']))
            throw new \Exception("options.headers must be an array of Strings");

        $reqDate = $this->_rfc1123();
        if ($req->getHeader('date') === null) {
            $req->setHeader('Date', $reqDate); 
        }

        if (!isset($options['headers'])) {
            $options['headers'] = array(); 
        } 
        
        if (!in_array('Date', $options['headers'])) {
            $options['headers'][]= 'Date'; 
        }
        if (!in_array('X-Hmac-Nonce', $options['headers'])) {
            $options['headers'][]= 'X-Hmac-Nonce'; 
        }
        $req->setHeader('X-HMAC-Date', $reqDate); 
        $req->setHeader('X-HMAC-Nonce', 'Thohn2Mohd2zugoo');

        $headersToSign = array();
        foreach($options['headers'] as $hdr) {
            $headersToSign[$hdr] = $req->getHeader($hdr); 
        } 
        
        if (!isset($options['algorithm']))
            $options['algorithm'] = 'sha512';
        $options['algorithm'] = strtolower($options['algorithm']);

        if (!in_array($options['algorithm'], $algorithms))
            throw new \Exception($options['algorithm']." is not supported");

        $canonicalRepresentation = HmacUtils::createCanonicalRepresentation($req->getMethod(), $headersToSign, $req->getUrl());
        $signature = HmacUtils::computeSignature($canonicalRepresentation, $options['secret'], $options['algorithm']);
        //$logger->debug('Canonical Representation ', array($canonicalRepresentation, $signature)); 
        $req->setHeader('Authorization', $options['algorithm'].' '.$options['key'].' '.$signature);
    }
31123
public function onRequestException(Event $event)
    {
        if (!$event['exception'] instanceof CurlException) {
            return;
        }

        $request = $event['request'];
        if (!$this->canCache->canCacheRequest($request)) {
            return;
        }

        if ($response = $this->storage->fetch($request)) {
            $response->setHeader('Age', time() - strtotime($response->getDate() ? : 'now'));
            if (!$this->canResponseSatisfyFailedRequest($request, $response)) {
                return;
            }
            $request->getParams()->set('cache.hit', 'error');
            $request->setResponse($response);
            $this->addResponseHeaders($request, $response);
            $event->stopPropagation();
        }
    }
983732
public function handleHandleHttpRequestEvent(HandleHttpRequestEvent $event) {
        $event->setResponse(
            $this->requestHandler->handle($event->getRequest())
        );
    }
31907
public function handle($event)
    {
        if ($event instanceof RouteMatched) {
            $this->handleLaravelRoute($event);
        }

        if ($event instanceof GzeroRouteMatched) {
            $this->handleRoute($event);
        }
    }
1228526
public static function setPermissionsSetfacl(Event $event)
	{
		$http_user = self::getHttpdUser($event);
		foreach (self::getWritableDirs($event) as $path) {
			self::SetfaclPermissionsSetter($event, $http_user, $path);
		}
		foreach (self::getWritableFiles($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
		}
	}
964306
public function onDispatchDirect(Event $event)
    {
        $object = $event->getParam('object');
        $method = $event->getParam('rpc')->getMethod();

        // Check ACL
        if ($object instanceof \JaztecAcl\Direct\AuthorizedDirectObject) {
            if (!$object->checkAcl($method)) {
                $event->stopPropagation(true);

                return $object->notAllowed();
            }
        }
    }
356939
public function handleAddToUrl(AddToUrlEvent $event)
    {
        /** @var Frontend $frontendAdapter */
        $frontendAdapter = $this->framework->getAdapter(Frontend::class);

        $event->setUrl($frontendAdapter->addToUrl($event->getSuffix(), $event->isIgnoreParams()));
    }