SL Reseplanerare 2 -> JourneyDetail

See https://www.trafiklab.se/api/sl-reseplanerare-2

@link https://www.trafiklab.se/api/sl-reseplanerare-2
@param string $ref
@return mixed
430991
public function slReseplanerare2JourneyDetail($ref) {
        $url = $this->SlReseplanerare2URL.'/journeydetail.json';

        $params = [
            'key' => $this->slReseplanerare2key,
            'ref' => $ref
        ];

        $request = $this->client->request('GET', $url, [
            'query' => $params
        ]);

        $resp = $this->client->send($request);
        $json = json_decode($resp->getBody(), true);
        return $json;
    }
117625
public static function ref($ref)
    {
        if (isset($ref['$id'])) {
            if ($ref['$ref'] == self::collectionName()) {
                return self::id($ref['$id']);
            }
        }

        return null;
    }
327889
public function getLastCommit($ref = 'master')
    {
        if ($this->isRoot()) {
            return $this->getRepository()->getCommit($ref);
        }
        $log = $this->repository->getObjectLog($this->getObject(), $ref);

        return $log[0];
    }
354679
public function getEmail($reference)
    {
        if (!isset($this->emails[$reference])) {
            $this->emails[$reference] = $this->em->getRepository($this->options['email_class'])->findOneByReference($reference);
        }

        $email = $this->emails[$reference];

        if (!$email instanceof EmailInterface) {
            throw new ReferenceNotFoundException($reference, sprintf('Reference "%s" does not exist for email.', $reference));
        }

        return $email;
    }
76857
protected function buildRouteMaps($refresh = false)
    {
        if ($this->routeMaps && !$this->debug && !$refresh) {
            return $this;
        }

        foreach ($this->routes as $key => $routeItem) {
            $this->routeMaps[$routeItem->getName()] = $key;
        }

        return $this;
    }
115544
public static function trimReference($reference)
    {
        if (substr($reference, -1) == '.' || substr($reference, -1) == '-') {
            $reference = trim(substr($reference, 0, -1));
        }
        while (preg_match('/(\.0+)$/', $reference, $matches)) {
            $reference = substr($reference, 0, strlen($matches[1]) * -1);
        }
        return $reference;
    }
1371514
public function getAvailableTransitions(Reference $ref, $state = null)
	{
		if ($state === null) {
			$state = $ref->state;
		}

		$available_transitions = array();

		foreach ($this->actions as $a => $action) {
			if (!empty($action['transitions'][$state]) && $this->isTransitionAllowed($ref, $a, $state)) {
				$available_transitions[] = $a;
			}
		}

		return $available_transitions;
	}
321185
public static function getRef($reference)
	{
		if (isset(self::$strings[$reference]))
		{
			return self::$strings[$reference];
		}

		return false;
	}
277876
protected function doGetDBRef(array $reference)
    {
        $mongoCollection = $this->mongoCollection;
        return $this->retry(function() use ($mongoCollection, $reference) {
            return $mongoCollection->getDBRef($reference);
        });
    }
138616
public function url($doc = 'index', $ref = null)
    {
        return $this->factory->url($this, $ref, $doc);
    }
97855
public function resolve($reference)
    {
        if (empty($reference)) {
            return $reference;
        }

        if ($this->isResolvableAnonymousReference($reference)) {
            return $this->resolveAnonymousReference($reference);
        }

        return $this->resolveInternal($reference);
    }
1071681
public static function node($ref = null, $strict = true) {
		$db = static::connection();
		$name = static::meta('name');

		extract(static::meta('acl'), EXTR_SKIP);
		extract(static::actsAs('Tree', true), EXTR_SKIP);

		if (is_string($ref)) {
			$w = $with = 'Parent';
			$i = 0;
			$paths = explode('/', $ref);
			$start = $paths[0];
			unset($paths[0]);

			$query = [
				'alias' => $name,
				'fields' => [$name],
				'with' => [
					$with => [
						'alias' => "{$name}0",
						'constraints' => (object) [
							"{$name}0.{$alias}" => (object) $db->value($start, [
								'type' => 'string'
							])
						]
					]],
				'order' => "{$name}.{$left} DESC"
			];

			$conditions = [static::_wrapCond($db, $name, 0, $left, $right)];

			foreach ($paths as $i => $path) {
				$j = $i - 1;
				$w .= ".{$with}";
				$query['with'][$w] = [
					'alias' => "{$name}{$i}",
					'constraints' => (object) [
						"{$name}{$i}.{$left}" => ['>' => "{$name}{$j}.{$left}"],
						"{$name}{$i}.{$right}" => ['<' => "{$name}{$j}.{$right}"],
						"{$name}{$i}.{$alias}" => $db->value($path, ['type' => 'string']),
						"{$name}{$j}." . static::meta('key') => "{$name}{$i}.{$parent}"
					]
				];
				$conditions[] = static::_wrapCond($db, $name, $i, $left, $right);
			}

			$query['conditions'] = ['OR' => $conditions];

			$result = static::find('all', $query + ['return' => 'array']);

			$paths = array_values($paths);

			if (!isset($result[0])) {
				return false;
			}
			if ($strict && (
				($paths && $result[0][$alias] !== $paths[count($paths) - 1]) ||
				(!$paths && $result[0][$alias] !== $start)
			)) {
				return false;
			}
			return $result;
		} elseif (is_object($ref)) {
			$self = static::_object();
			if ($ref instanceof $self->_classes['entity']) {
				$model = $ref->model();
				$id = $model::meta('key');
				$ref = [$class => $model, $id => $ref->$id];
			}
		}

		if ($ref && is_array($ref) && isset($ref[$class])) {
			$conditions = [];
			$model = $ref[$class];
			$id = $model::meta('key');
			if (isset($ref[$id])) {
				$conditions["{$name}0.{$key}"] = $ref[$id];
			} elseif (isset($ref[$key])) {
				$conditions["{$name}0.{$key}"] = $ref[$key];
			} else {
				return false;
			}
			$conditions["{$name}0.{$class}"] = $model;

			$constraints = (object) static::_wrapCond($db, $name, '0', $left, $right, false);

			$query = [
				'conditions' => $conditions,
				'fields' => [$name],
				'with' => [
					'Parent' => [
						'alias' => "{$name}0",
						'constraints' => $constraints
					]
				],
				'order' => "{$name}.{$left} DESC"
			];

			return static::find('all', $query + ['return' => 'array']);
		}
		return false;
	}
788544
public function getRef($reference)
	{
		$ref = &self::_getArray();

		if (isset($ref[$reference]))
		{
			return $ref[$reference];
		}
		else
		{
			return false;
		}
	}
257555
public function ref($ref1)
    {
        list($ref, $rest) = explode('/', $ref1, 2);

        if (!isset($this->_references[$ref])) {
            /** @type Field_Base $e */
            $e = $this->hasElement($ref);
            if ($e && $e->hasMethod('ref')) {
                return $e->ref();
            } else {
                throw $this->exception('Reference is not defined')
                    ->addMoreInfo('model', $this)
                    ->addMoreInfo('ref', $ref);
            }
        }

        $class = $this->_references[$ref];
        if (is_array($class)) { // hasMany
            if ($rest) {
                throw $this->exception('Cannot traverse multiple references');
            }
            $m = $this->_ref(
                $class[0],
                $class[1] && $class[1] != UNDEFINED ? $class[1] : $this->table.'_id',
                $class[2] && $class[2] != UNDEFINED ? $this[$class[2]] : $this->id
            );
        } else { // hasOne
            $id = $this->get($ref);
            /** @type Model $m */
            $m = $this->_ref(
                $class,
                null,
                $id
            );
            if ($id) {
                $this->hook('beforeRefLoad', array($m, $id));
                $m->load($id);
            }
        }
        if ($rest) {
            $m = $m->ref($rest);
        }

        return $m;
    }
806178
public function resolve($reference)
    {
        if (!is_string($reference)) {
            return $reference;
        }
        $prefix = substr($reference, 0, 1);

        switch (1) {
            case $prefix    === '@'                                             : return $this->container->get(substr($reference, 1));
            case $prefix    === '%'                                             : return $this->container->getParameter(substr($reference, 1));
            case preg_match(static::CONTAINER_REGEXP, $reference, $matches)     : return $this->container;
            case preg_match(static::ENVIRONMENT_REGEXP, $reference, $matches)   : return getenv($matches[1]);
            case preg_match(static::CONSTANT_REGEXP, $reference, $matches)      : return constant($matches[1]);
            default                                                             : return $reference;
        }
    }
275487
public function reference($reference = null)
    {
        if (!func_num_args()) {
            return $this->_reference;
        }
        $this->_reference = $reference;
        return $this;
    }
327736
public function exist(ARef $ref)
    {
        $family = $ref->getType()->getFamily();

        $refConsistExecutor = $this->getRefConsistExecutor($family);

        return $refConsistExecutor->exist($ref);
    }