*
* @see \Laminas\Router\RouteInterface::assemble()
*
* @param array $params
* @param array $options
* @return mixed
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public function assemble(array $params = [], array $options = [])
{
if (! isset($options['name'])) {
throw new Exception\InvalidArgumentException('Missing "name" option');
}
$names = explode('/', $options['name'], 2);
$route = $this->routes->get($names[0]);
if (! $route) {
throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $names[0]));
}
if (isset($names[1])) {
if (! $route instanceof TreeRouteStack) {
throw new Exception\RuntimeException(sprintf(
'Route with name "%s" does not have child routes',
$names[0]
));
}
$options['name'] = $names[1];
} else {
unset($options['name']);
}
if (isset($options['only_return_path']) && $options['only_return_path']) {
return $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options);
}
if (! isset($options['uri'])) {
$uri = new HttpUri();
Arguments
"Route with name "listing" not found"
$options['has_child'] = isset($options['name']);
if (isset($options['translator']) && ! isset($options['locale']) && isset($params['locale'])) {
$options['locale'] = $params['locale'];
}
$path = $this->route->assemble($params, $options);
$params = array_diff_key($params, array_flip($this->route->getAssembledParams()));
if (! isset($options['name'])) {
if (! $this->mayTerminate) {
throw new Exception\RuntimeException('Part route may not terminate');
} else {
return $path;
}
}
unset($options['has_child']);
$options['only_return_path'] = true;
return $path . parent::assemble($params, $options);
}
/**
* getAssembledParams(): defined by RouteInterface interface.
*
* @see RouteInterface::getAssembledParams
*
* @return array
*/
public function getAssembledParams()
{
// Part routes may not occur as base route of other part routes, so we
// don't have to return anything here.
return [];
}
}
Arguments
array:1 [
"page" => 1
]
array:3 [
"name" => "listing"
"uri" => Laminas\Uri\Http {#1188}
"only_return_path" => true
]
$route = $this->routes->get($names[0]);
if (! $route) {
throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $names[0]));
}
if (isset($names[1])) {
if (! $route instanceof TreeRouteStack) {
throw new Exception\RuntimeException(sprintf(
'Route with name "%s" does not have child routes',
$names[0]
));
}
$options['name'] = $names[1];
} else {
unset($options['name']);
}
if (isset($options['only_return_path']) && $options['only_return_path']) {
return $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options);
}
if (! isset($options['uri'])) {
$uri = new HttpUri();
if (isset($options['force_canonical']) && $options['force_canonical']) {
if ($this->requestUri === null) {
throw new Exception\RuntimeException('Request URI has not been set');
}
$uri->setScheme($this->requestUri->getScheme())
->setHost($this->requestUri->getHost())
->setPort($this->requestUri->getPort());
}
$options['uri'] = $uri;
} else {
$uri = $options['uri'];
}
Arguments
array:1 [
"page" => 1
]
array:3 [
"name" => "listing"
"uri" => Laminas\Uri\Http {#1188}
"only_return_path" => true
]
$options['has_child'] = isset($options['name']);
if (isset($options['translator']) && ! isset($options['locale']) && isset($params['locale'])) {
$options['locale'] = $params['locale'];
}
$path = $this->route->assemble($params, $options);
$params = array_diff_key($params, array_flip($this->route->getAssembledParams()));
if (! isset($options['name'])) {
if (! $this->mayTerminate) {
throw new Exception\RuntimeException('Part route may not terminate');
} else {
return $path;
}
}
unset($options['has_child']);
$options['only_return_path'] = true;
return $path . parent::assemble($params, $options);
}
/**
* getAssembledParams(): defined by RouteInterface interface.
*
* @see RouteInterface::getAssembledParams
*
* @return array
*/
public function getAssembledParams()
{
// Part routes may not occur as base route of other part routes, so we
// don't have to return anything here.
return [];
}
}
Arguments
array:1 [
"page" => 1
]
array:3 [
"name" => "listing"
"uri" => Laminas\Uri\Http {#1188}
"only_return_path" => true
]
if (! isset($options['uri'])) {
$uri = new HttpUri();
if (isset($options['force_canonical']) && $options['force_canonical']) {
if ($this->requestUri === null) {
throw new Exception\RuntimeException('Request URI has not been set');
}
$uri->setScheme($this->requestUri->getScheme())
->setHost($this->requestUri->getHost())
->setPort($this->requestUri->getPort());
}
$options['uri'] = $uri;
} else {
$uri = $options['uri'];
}
$path = $this->baseUrl . $route->assemble(array_merge($this->defaultParams, $params), $options);
if (isset($options['query'])) {
$uri->setQuery($options['query']);
}
if (isset($options['fragment'])) {
$uri->setFragment($options['fragment']);
}
if (
(isset($options['force_canonical'])
&& $options['force_canonical'])
|| $uri->getHost() !== null
|| $uri->getScheme() !== null
) {
if (($uri->getHost() === null || $uri->getScheme() === null) && $this->requestUri === null) {
throw new Exception\RuntimeException('Request URI has not been set');
}
if ($uri->getHost() === null) {
Arguments
array:1 [
"page" => 1
]
array:3 [
"name" => "public/listing"
"uri" => Laminas\Uri\Http {#1188}
"only_return_path" => true
]
}
if ($reuseMatchedParams && $this->routeMatch !== null) {
$routeMatchParams = $this->routeMatch->getParams();
if (isset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) {
$routeMatchParams['controller'] = $routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER];
unset($routeMatchParams[ModuleRouteListener::ORIGINAL_CONTROLLER]);
}
if (isset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE])) {
unset($routeMatchParams[ModuleRouteListener::MODULE_NAMESPACE]);
}
$params = array_merge($routeMatchParams, $params);
}
$options['name'] = $name;
return (string) $this->router->assemble($params, $options);
}
/**
* Set the router to use for assembling.
*
* @param RouteStackInterface $router
* @return Url
* @throws Exception\InvalidArgumentException For invalid router types.
* @psalm-suppress RedundantConditionGivenDocblockType, DocblockTypeContradiction
*/
public function setRouter($router)
{
if (! $router instanceof RouteStackInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a %s instance; received %s',
__METHOD__,
RouteStackInterface::class,
is_object($router) ? $router::class : gettype($router)
));
}
Arguments
array:1 [
"page" => 1
]
array:2 [
"name" => "public/listing"
"uri" => Laminas\Uri\Http {#1188}
]
$pageBuilder = $this->sm()->get('CommandArgBuilder\Factory\PageBuilder')->setCrudObj($crudObj);
$pageBuilder->addCommandArgProcessor($this->sm()->get('Tut\Repository\PDOMySQL\CommandArgProcessor\SkillLevel'))
->addCommandArgProcessor($this->sm()->get('Tut\Repository\PDOMySQL\CommandArgProcessor\Action')->setDefaultAction('newest')->setInclusions(['oldest','newest']))
;
$pageBuilder2=$pageBuilder->spawn();
$pageBuilder2->addCommandArgProcessor($this->sm()->get('Tut\Repository\PDOMySQL\CommandArgProcessor\DragoartCategory')->useBaseUrl(false));
$pageBuilder->processCommandArg();
$cacheCheck = $this->sm()->get('Cacher\Service\CacheCheck');
$cacher=$cacheCheck->getCacher();
//check if we need to display a cannonical link
$uriParser = $this->sm()->get('Nitro\Http\Url\UriParser');
$realUrl=$this->vhm()->get('url')('tut/public/listing', $routeArgs);
$uriParser->setRealUri($realUrl);
if (!$uriParser->doesRealUriAndRequestedUriMatch()):
$this->sm()->get('Application\Aggregator\LayoutVars')->addVars(['display_canonical_link' => $uriParser->getUriWithPathAndHost()]);
endif;
$cacheKey=$pageBuilder->getCachingKey().$page.'_'.(int)$xmlRequest;
if(!$cacheCheck->setKey('tut_listing', $cacheKey)->isCached()):
$crudStmt->addPostCrudStmtExecuteEvent($this->sm()->get('Image\Repository\PostCrudStmtExecuteEvent\ImageInjector'));
$crudStmt->addPostCrudStmtExecuteEvent($this->sm()->get('User\Repository\PostCrudStmtExecuteEvent\UserInjector')->injectAvatar(true));
$pageBuilder->getCommandArgBuilder()->setBaseUrl($this->url()->fromRoute('tut/public/listing', []));
Arguments
"tut/public/listing"
array:1 [
"page" => 1
]
*/
public function onDispatch(MvcEvent $e)
{
$routeMatch = $e->getRouteMatch();
if (! $routeMatch) {
/**
* @todo Determine requirements for when route match is missing.
* Potentially allow pulling directly from request metadata?
*/
throw new DomainException('Missing route matches; unsure how to retrieve action');
}
$action = $routeMatch->getParam('action', 'not-found');
$method = static::getMethodFromAction($action);
if (! method_exists($this, $method)) {
$method = 'notFoundAction';
}
$actionResponse = $this->$method();
$e->setResult($actionResponse);
return $actionResponse;
}
}
}
final protected function setAdmin(\User\Lib\Admin $admin){
$this->admin=$admin;
return $this;
}
final protected function isAdmin(){
return (isset($this->admin) && is_object($this->admin))?true:false;
}
final protected function isMember(){
return (isset($this->member) && is_object($this->member))?true:false;
}
final public function onDispatch(MvcEvent $e)
{
$this->dispatchEvent = $e;
$this->dispatchEvent($e);
return parent::onDispatch($e); // TODO: Change the autogenerated stub
}
//override if needed: called to delegate a service to createRealService method
public function di(ContainerInterface $c){
// do nothing
}
//override if needed: called to inject Dependency Injection
public function getService()
{
//do nothing
}
//override if needed: called when the controller is being dispatched
public function dispatchEvent(MvcEvent $e){
//do nothing
}
Arguments
Laminas\Mvc\MvcEvent {#431}
}
if ($this->sharedManager) {
foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
$listOfListenersByPriority[$priority][] = $listeners;
}
}
// Sort by priority in reverse order
krsort($listOfListenersByPriority);
// Initial value of stop propagation flag should be false
$event->stopPropagation(false);
// Execute listeners
$responses = new ResponseCollection();
foreach ($listOfListenersByPriority as $listOfListeners) {
foreach ($listOfListeners as $listeners) {
foreach ($listeners as $listener) {
$response = $listener($event);
$responses->push($response);
// If the event was asked to stop propagating, do so
if ($event->propagationIsStopped()) {
$responses->setStopped(true);
return $responses;
}
// If the result causes our validation callback to return true,
// stop propagation
if ($callback && $callback($response)) {
$responses->setStopped(true);
return $responses;
}
}
}
}
return $responses;
}
Arguments
Laminas\Mvc\MvcEvent {#431}
$event->setParams($argv);
}
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function triggerEvent(EventInterface $event)
{
return $this->triggerListeners($event);
}
/**
* @inheritDoc
*/
public function triggerEventUntil(callable $callback, EventInterface $event)
{
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function attach($eventName, callable $listener, $priority = 1)
{
if (! is_string($eventName)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string for the event; received %s',
__METHOD__,
is_object($eventName) ? $eventName::class : gettype($eventName)
));
}
$this->events[$eventName][(int) $priority][0][] = $listener;
return $listener;
}
/**
Arguments
Laminas\Mvc\MvcEvent {#431}
Closure($test): bool {#1068 …4}
* @events dispatch.pre, dispatch.post
* @param Request $request
* @param null|Response $response
* @return Response|mixed
*/
public function dispatch(Request $request, Response $response = null)
{
$this->request = $request;
if (! $response) {
$response = new HttpResponse();
}
$this->response = $response;
$e = $this->getEvent();
$e->setName(MvcEvent::EVENT_DISPATCH);
$e->setRequest($request);
$e->setResponse($response);
$e->setTarget($this);
$result = $this->getEventManager()->triggerEventUntil(static fn($test): bool => $test instanceof Response, $e);
if ($result->stopped()) {
return $result->last();
}
return $e->getResult();
}
/**
* Get request object
*
* @return Request
*/
public function getRequest()
{
if (! $this->request) {
$this->request = new HttpRequest();
}
return $this->request;
Arguments
Closure($test): bool {#1068 …4}
Laminas\Mvc\MvcEvent {#431}
);
return $this->complete($return, $e);
} catch (Throwable $exception) {
$return = $this->marshalBadControllerEvent($controllerName, $e, $application, $exception);
return $this->complete($return, $e);
} catch (Exception $exception) { // @TODO clean up once PHP 7 requirement is enforced
$return = $this->marshalBadControllerEvent($controllerName, $e, $application, $exception);
return $this->complete($return, $e);
}
if ($controller instanceof InjectApplicationEventInterface) {
$controller->setEvent($e);
}
$request = $e->getRequest();
$response = $application->getResponse();
$caughtException = null;
try {
$return = $controller->dispatch($request, $response);
} catch (Throwable $ex) {
$caughtException = $ex;
} catch (Exception $ex) { // @TODO clean up once PHP 7 requirement is enforced
$caughtException = $ex;
}
if ($caughtException !== null) {
$e->setName(MvcEvent::EVENT_DISPATCH_ERROR);
$e->setError($application::ERROR_EXCEPTION);
$e->setController($controllerName);
$e->setControllerClass($controller::class);
$e->setParam('exception', $caughtException);
$return = $application->getEventManager()->triggerEvent($e)->last();
if (! $return) {
$return = $e->getResult();
}
}
return $this->complete($return, $e);
Arguments
Laminas\Http\PhpEnvironment\Request {#408}
Laminas\Http\PhpEnvironment\Response {#418}
}
if ($this->sharedManager) {
foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
$listOfListenersByPriority[$priority][] = $listeners;
}
}
// Sort by priority in reverse order
krsort($listOfListenersByPriority);
// Initial value of stop propagation flag should be false
$event->stopPropagation(false);
// Execute listeners
$responses = new ResponseCollection();
foreach ($listOfListenersByPriority as $listOfListeners) {
foreach ($listOfListeners as $listeners) {
foreach ($listeners as $listener) {
$response = $listener($event);
$responses->push($response);
// If the event was asked to stop propagating, do so
if ($event->propagationIsStopped()) {
$responses->setStopped(true);
return $responses;
}
// If the result causes our validation callback to return true,
// stop propagation
if ($callback && $callback($response)) {
$responses->setStopped(true);
return $responses;
}
}
}
}
return $responses;
}
Arguments
Laminas\Mvc\MvcEvent {#431}
$event->setParams($argv);
}
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function triggerEvent(EventInterface $event)
{
return $this->triggerListeners($event);
}
/**
* @inheritDoc
*/
public function triggerEventUntil(callable $callback, EventInterface $event)
{
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function attach($eventName, callable $listener, $priority = 1)
{
if (! is_string($eventName)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string for the event; received %s',
__METHOD__,
is_object($eventName) ? $eventName::class : gettype($eventName)
));
}
$this->events[$eventName][(int) $priority][0][] = $listener;
return $listener;
}
/**
Arguments
Laminas\Mvc\MvcEvent {#431}
Closure($r): bool {#2 …4}
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
}
}
if ($event->getError()) {
return $this->completeRequest($event);
}
// Trigger dispatch event
$event->setName(MvcEvent::EVENT_DISPATCH);
$event->stopPropagation(false); // Clear before triggering
$result = $events->triggerEventUntil($shortCircuit, $event);
// Complete response
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
}
$response = $this->response;
$event->setResponse($response);
return $this->completeRequest($event);
}
/**
* Complete the request
Arguments
Closure($r): bool {#2 …4}
Laminas\Mvc\MvcEvent {#431}
} catch(Exception $e) {
//var_dump(debug_backtrace());
$gtgggg=[];
$gtgggg['err']=$e->getMessage();
$gtgggg['line']=$e->getLine();
$gtgggg['file']=$e->getFile();
$gtgggg['trace']=$e->getTrace();
$gtgggg['code']=$e->getCode();
d($gtgggg);
}
else:
Application::init(require 'config/' . PROJECT_ID_STRING . '/application.config.php')->run();
endif;