Returns the list of URLs that can be accessed, and the function/method that should be called when the URL is called.

@param string $instanceName The identifier for this object in the container.

@return SplashRoute[]
540842
public function getUrlsList($instanceName)
    {
        $moufManager = MoufManager::getMoufManager();
        $instanceNames = $moufManager->findInstances(UrlProviderInterface::class);

        $urls = array();

        foreach ($instanceNames as $instanceName) {
            $urlProvider = $moufManager->getInstance($instanceName);
            /* @var $urlProvider UrlProviderInterface */
            if ($urlProvider === $this) {
                continue;
            }
            $tmpUrlList = $urlProvider->getUrlsList($instanceName);
            $urls = array_merge($urls, $tmpUrlList);
        }

        return $urls;
    }
967727
protected function getInternalDomains()
    {
        $internalDomains = [$this->getApplicationDomainRegex()];

        foreach ($this->app['routes'] as $route) {
            if (!is_null($route->domain())) {
                $internalDomains[] = $this->getDomainRegex($route);
            }
        }

        return array_unique($internalDomains);
    }
1196822
protected function exists($id, $instanceName)
    {
        return $this->getConnection()->table($this->getTableName())
            ->where('id', $id)
            ->where('instance', $instanceName)
            ->exists();
    }
662429
private function instantiateComponent($instanceName) {
		if (!isset($this->declaredInstances[$instanceName])) {
			throw new MoufInstanceNotFoundException("The object instance '".$instanceName."' is not defined.", 1, $instanceName);
		}
		try {
			$instanceDefinition = $this->declaredInstances[$instanceName];
	
			if (isset($instanceDefinition['code'])) {
				if (isset($instanceDefinition['error'])) {
					throw new MoufException("The code defining instance '$instanceName' is invalid: ".$instanceDefinition['error']);
				}
				$closures = $this->getClosures();
				$closure = $closures[$instanceName];
				$instance = $closure($this->delegateLookupContainer);
				$this->objectInstances[$instanceName] = $instance;
				return $instance;
			}
			
			$className = $instanceDefinition["class"];
	
			if (isset($instanceDefinition['constructor'])) {
				$constructorParametersArray = $instanceDefinition['constructor'];
				
				$classDescriptor = new \ReflectionClass($className);
				
				$constructorParameters = array();
				foreach ($constructorParametersArray as $key=>$constructorParameterDefinition) {
					$value = $constructorParameterDefinition["value"];
					switch ($constructorParameterDefinition['parametertype']) {
						case "primitive":
							switch ($constructorParameterDefinition["type"]) {
								case "string":
									$constructorParameters[] = $value;
									break;
								case "request":
									$constructorParameters[] = $_REQUEST[$value];
									break;
								case "session":
									$constructorParameters[] = $_SESSION[$value];
									break;
								case "config":
									$constructorParameters[] = constant($value);
									break;
								case "php":
									$closures = $this->getClosures();
									$closure = $closures[$instanceName]['constructor'][$key];
									if ($closure instanceof \Closure) {
										$constructorParameters[] = $closure($this->delegateLookupContainer);
									} else {
										throw new MoufException("Parse error in the callback of '$instanceName' constructor argument '$key': ".$closure);
									}
									break;
								default:
									throw new MoufException("Invalid type '".$constructorParameterDefinition["type"]."' for object instance '$instanceName'.");
							}
							break;
						case "object":
							if (is_array($value)) {
								$tmpArray = array();
								foreach ($value as $keyInstanceName=>$valueInstanceName) {
									if ($valueInstanceName !== null) {
										$tmpArray[$keyInstanceName] = $this->delegateLookupContainer->get($valueInstanceName);
									} else {
										$tmpArray[$keyInstanceName] = null;
									}
								}
								$constructorParameters[] = $tmpArray;
							} else {
								if ($value !== null) {
									$constructorParameters[] = $this->delegateLookupContainer->get($value);
								} else {
									$constructorParameters[] = null;
								}
							}
							break;
						default:	
							throw new MoufException("Unknown parameter type ".$constructorParameterDefinition['parametertype']." for parameter in constructor of instance '".$instanceName."'");
					}
				}
				if (!isset($this->objectInstances[$instanceName])) {
						$object = $classDescriptor->newInstanceArgs($constructorParameters);
				} else {
						$object = $this->objectInstances[$instanceName];
				}
			} else {
				$object = new $className();
			}
			$this->objectInstances[$instanceName] = $object;
			if (isset($instanceDefinition["fieldProperties"])) {
				foreach ($instanceDefinition["fieldProperties"] as $key=>$valueDef) {
					switch ($valueDef["type"]) {
						case "string":
							$object->$key = $valueDef["value"];
							break;
						case "request":
							$object->$key = $_REQUEST[$valueDef["value"]];
							break;
						case "session":
							$object->$key = $_SESSION[$valueDef["value"]];
							break;
						case "config":
							$object->$key = constant($valueDef["value"]);
							break;
						case "php":
							$closures = $this->getClosures();
							$closure = $closures[$instanceName]['fieldProperties'][$key];
							if ($closure instanceof \Closure) {
								$closure = $closure->bindTo($object);
								$object->$key = $closure($this->delegateLookupContainer);
							} else {
								throw new MoufContainerException("Parse error in the callback of '$instanceName' property '$key': ".$closure);
							}
							break;
						default:
							throw new MoufContainerException("Invalid type '".$valueDef["type"]."' for object instance '$instanceName'.");
					}
				}
			}
	
			if (isset($instanceDefinition["setterProperties"])) {
				foreach ($instanceDefinition["setterProperties"] as $key=>$valueDef) {
					//$object->$key($valueDef["value"]);
					switch ($valueDef["type"]) {
						case "string":
							$object->$key($valueDef["value"]);
							break;
						case "request":
							$object->$key($_REQUEST[$valueDef["value"]]);
							break;
						case "session":
							$object->$key($_SESSION[$valueDef["value"]]);
							break;
						case "config":
							$object->$key(constant($valueDef["value"]));
							break;
						case "php":
							$closures = $this->getClosures();
							$closure = $closures[$instanceName]['setterProperties'][$key];
							if ($closure instanceof \Closure) {
								$closure = $closure->bindTo($object);
							} else {
								throw new MoufContainerException("Parse error in the callback of '$instanceName' setter '$key': ".$closure);
							}
							$object->$key($closure($this->delegateLookupContainer));
							break;
						default:
							throw new MoufContainerException("Invalid type '".$valueDef["type"]."' for object instance '$instanceName'.");
					}
				}
			}
	
			if (isset($instanceDefinition["fieldBinds"])) {
				foreach ($instanceDefinition["fieldBinds"] as $key=>$value) {
					if (is_array($value)) {
						$tmpArray = array();
						foreach ($value as $keyInstanceName=>$valueInstanceName) {
							if ($valueInstanceName !== null) {
								$tmpArray[$keyInstanceName] = $this->get($valueInstanceName);
							} else {
								$tmpArray[$keyInstanceName] = null;
							}
						}
						$object->$key = $tmpArray;
					} else {
						$object->$key = $this->get($value);
					}
				}
			}
	
			if (isset($instanceDefinition["setterBinds"])) {
				foreach ($instanceDefinition["setterBinds"] as $key=>$value) {
					if (is_array($value)) {
						$tmpArray = array();
						foreach ($value as $keyInstanceName=>$valueInstanceName) {
							if ($valueInstanceName !== null) {
								$tmpArray[$keyInstanceName] = $this->get($valueInstanceName);
							} else {
								$tmpArray[$keyInstanceName] = null;
							}
						}
						$object->$key($tmpArray);
					} else {
						$object->$key($this->get($value));
					}
				}
			}
		} catch (MoufInstanceNotFoundException $e) {
			throw new MissingDependencyException("The object instance '".$instanceName."' could not be created because it depends on an object in error (".$e->getMissingInstanceName().")", 2, $instanceName, $e);
		}
		return $object;
	}
30530
public function findRouteByName($routeName) {
        $routePath = array_search($routeName, $this->routeNames);
        list($method, $index) = explode(':', $routePath);

        return $this->routes[$method][$index];
    }
120370
public function getRoutesWithoutCache()
    {
        $urlsList = array();

        foreach ($this->routeProviders as $routeProvider) {
            /* @var $routeProvider UrlProviderInterface */
            $tmpUrlList = $routeProvider->getUrlsList(null);
            $urlsList = array_merge($urlsList, $tmpUrlList);
        }

        $items = array();

        foreach ($urlsList as $urlCallback) {
            /* @var $urlCallback SplashCallback */

            $url = $urlCallback->url;
            // remove trailing slash
            $url = rtrim($url, '/');

            $title = null;
            if ($urlCallback->title !== null) {
                $title = $urlCallback->title;
            }

            //////////////// Let's analyze the URL for parameter ////////////////////
            $trimmedUrl = trim($url, '/');
            $urlParts = explode('/', $trimmedUrl);
            $urlPartsNew = array();
            $parametersList = array();
                        // We will store the number of parameters for a URL
                        $nbParam = 0;

            for ($i = 0; $i < count($urlParts); ++$i) {
                $urlPart = $urlParts[$i];
                if (strpos($urlPart, '{') === 0 && strpos($urlPart, '}') === strlen($urlPart) - 1) {
                    $nbParam += 1;
                    // Parameterized URL element
                    $varName = substr($urlPart, 1, strlen($urlPart) - 2);

                    $parametersList[$varName] = $i;
                    $urlPartsNew[] = '([^/]*?)';
                } else {
                    $urlPartsNew[] = $urlPart;
                }
            }

            // Let's rewrite the URL, but replacing the {var} parameters with a regexp wildcard
            $url = '^'.implode('/', $urlPartsNew).'$';
            ///////////////// End URL analysis ////////////////////

            $httpMethods = $urlCallback->httpMethods;
            if (empty($httpMethods)) {
                $httpMethods['default'] = 'moufpress_execute_action';
            } else {
                foreach ($httpMethods as $httpMethod) {
                    $httpMethods[strtoupper($httpMethod)] = 'moufpress_execute_action';
                }
            }

            foreach ($httpMethods as $httpMethod) {
                $item = array(
                        'path' => $url,

                        'page_callback' => $httpMethods,
                        // First argument passed to execute_action as the instance name, second argument is the method.
                        'page_arguments' => array($urlCallback->controllerInstanceName, $urlCallback->methodName, $parametersList, $urlCallback->parameters, $urlCallback->filters),
                        'access_callback' => true,
                                                 // We store the number of parameters for an item
                                                'nbParam' => $nbParam,
                        //'page arguments' => array(array($httpMethod => array("instance"=>$urlCallback->controllerInstanceName, "method"=>$urlCallback->methodName, "urlParameters"=>$parametersList))),
                );

                if ($title) {
                    $item['title'] = $title;
                }

                $items[] = $item;
            }
        }

                /*
                 * We sort the tableOfURLS with the one with the fewer parameters coming first
                 */
                usort($items, function (array $a, array $b) {
                    return $a['nbParam'] - $b['nbParam'];
                });

        return $items;
    }
33077
public function walkForGarbageCollection($instanceName) {
        // In case the instance does not exist (this could happen after a failed merge or a manual edit of MoufComponents.php...)
        if (!isset($this->declaredInstances[$instanceName])) {
            return;
        }
		$instance = &$this->declaredInstances[$instanceName];
		if (isset($instance['noGarbageCollect']) && $instance['noGarbageCollect'] == true) {
			// No need to go through already visited nodes.
			return;
		}

		$instance['noGarbageCollect'] = true;

		$declaredInstances = &$this->declaredInstances;
		$moufManager = $this;
		if (isset($instance['constructor'])) {
			foreach ($instance['constructor'] as $argument) {
				if ($argument["parametertype"] == "object") {
					$value = $argument["value"];
					if(is_array($value)) {
						array_walk_recursive($value, function($singleValue) use (&$declaredInstances, $moufManager) {
							if ($singleValue != null) {
								$moufManager->walkForGarbageCollection($singleValue);
							}
						});
						/*foreach ($value as $singleValue) {
							if ($singleValue != null) {
								$this->walkForGarbageCollection($this->declaredInstances[$singleValue]);
							}
						}*/
					}
					else {
						if ($value != null) {
							$this->walkForGarbageCollection($value);
						}
					}
				}

			}
		}
		if (isset($instance['fieldBinds'])) {
			foreach ($instance['fieldBinds'] as $prop) {
				if(is_array($prop)) {
					array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) {
						if ($singleProp != null) {
							$moufManager->walkForGarbageCollection($singleProp);
						}
					});
							
					/*foreach ($prop as $singleProp) {
						if ($singleProp != null) {
							$this->walkForGarbageCollection($this->declaredInstances[$singleProp]);
						}
					}*/
				}
				else {
					$this->walkForGarbageCollection($prop);
				}
			}
		}
		if (isset($instance['setterBinds'])) {
			foreach ($instance['setterBinds'] as $prop) {
				if(is_array($prop)) {
					array_walk_recursive($prop, function($singleProp) use (&$declaredInstances, $moufManager) {
						if ($singleProp != null) {
							$moufManager->walkForGarbageCollection($singleProp);
						}
					});
					/*foreach ($prop as $singleProp) {
						if ($singleProp != null) {
							$this->walkForGarbageCollection($this->declaredInstances[$singleProp]);
						}
					}*/
					
				}
				else {
					$this->walkForGarbageCollection($prop);
				}
			}
		}
	}
675708
protected function getInternalDomains()
    {
        $internalDomains = [$this->getApplicationDomainRegex()];

        /** @var RouterInterface $router */
        $router = $this->di->get('router');

        if ($router instanceof RouterInterface) {
            /** @var RouteInterface[] $routes */
            $routes = $router->getRoutes();

            foreach ($routes as $route) {
                if ($route instanceof RouteInterface) {
                    $hostName = $route->getHostname();
                    if (!empty($hostName)) {
                        $internalDomains[] = '/^' . str_replace('.', '\.', $route->getHostname()) . '$/';
                    }
                }
            }
        }

        return array_unique($internalDomains);
    }
106486
protected function collectMethods($instance, $filter = ReflectionMethod::IS_PUBLIC)
    {
        static $methodsCache = null;

        if (null === $methodsCache) {
            $methodsCache = $instance
                ? (new ReflectionClass($instance))->getMethods($filter)
                : [];
        }

        return $methodsCache;
    }
780920
public function getInternalDomains()
    {
        $internalDomains = [];

        foreach ($this->app['routes'] as $route) {
            if ($domain = $route->getHost()) {
                $internalDomains[] = '/^' . preg_quote($domain, '/') . '$/';
            }
        }

        return $internalDomains;
    }
281768
protected static function _applyUrlFilters($url)
    {
        $request = static::getRequest(true);
        $e = null;
        foreach (static::$_urlFilters as $filter) {
            try {
                $url = $filter($url, $request);
            } catch (Exception $e) {
                // fall through
            } catch (Throwable $e) {
                // fall through
            }
            if ($e !== null) {
                if (is_array($filter)) {
                    $ref = new ReflectionMethod($filter[0], $filter[1]);
                } else {
                    $ref = new ReflectionFunction($filter);
                }
                $message = sprintf(
                    'URL filter defined in %s on line %s could not be applied. The filter failed with: %s',
                    $ref->getFileName(),
                    $ref->getStartLine(),
                    $e->getMessage()
                );
                throw new RuntimeException($message, $e->getCode(), $e);
            }
        }

        return $url;
    }
914968
public function get($instanceName) {
		if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) {
			$this->instantiateComponent($instanceName);
		}
		return $this->objectInstances[$instanceName];
	}
701276
public static function &getAuth($instance)
	{
		static $instances;
		if (!isset($instances)) {
			$instances = array();
		}
		//only create a new authentication instance if it has not been created before
		if (!isset($instances[$instance])) {
			$name = static::getNameFromInstance($instance);

			static::pluginAutoLoad($name);

			$class = '\JFusion\Plugins\\' . $name . '\Auth';
			if (!class_exists($class)) {
				$class = '\JFusion\Plugin\Auth';
			}
			$instances[$instance] = new $class($instance);
		}
		return $instances[$instance];
	}
584475
public function getUrlAssetUrls($url, array $assetTypes = ['image'], $siteId = null): array
    {
        return RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId);
    }
777817
protected function getAllRouteNames($resourceName = null)
    {
        $resourceName = $resourceName ?? $this->resourceName;

        return [
            'index'   => $this->prefix.$this->resourceName.'.index',
            'create'  => $this->prefix.$this->resourceName.'.create',
            'store'   => $this->prefix.$this->resourceName.'.store',
            'show'    => $this->prefix.$this->resourceName.'.show',
            'edit'    => $this->prefix.$this->resourceName.'.edit',
            'update'  => $this->prefix.$this->resourceName.'.update',
            'destroy' => $this->prefix.$this->resourceName.'.destroy',
        ];
    }
839378
public function getHTTPMethods($uri)
    {
        try {
            $node = $this->server->tree->getNodeForPath($uri);
        } catch (NotFound $e) {
            return [];
        }

        if ($node instanceof IOutbox) {
            return ['POST'];
        }

        return [];
    }
262197
private function generateGetterString($instanceName) {
		$modInstance = str_replace(" ", "", $instanceName);
		$modInstance = str_replace("\n", "", $modInstance);
		$modInstance = str_replace("-", "", $modInstance);
		$modInstance = str_replace(".", "_", $modInstance);
		// Let's remove anything that is not an authorized character:
		$modInstance = preg_replace("/[^A-Za-z0-9_]/", "", $modInstance);


		return "get".strtoupper(substr($modInstance,0,1)).substr($modInstance,1);
	}