protected static function getEntityFromUrl(array $url) : ?EntityInterface
    {
        $entity = null;

        $id = null;
        if (!empty($url['pass'][0])) {
            $id = $url['pass'][0];
        }

        if (empty($id) && !empty($url['0'])) {
            $id = $url['0'];
        }

        // if url includes an id, fetch relevant record
        if (!empty($id)) {
            try {
                $tableName = $url['controller'];
                if (!empty($url['plugin'])) {
                    $tableName = $url['plugin'] . '.' . $tableName;
                }
                $table = TableRegistry::get($tableName);
                $entity = $table->get($id);
            } catch (InvalidPrimaryKeyException $e) {
                Log::warning(sprintf('Failed to fetch record with id [%s] from table [%s]', $id, $url['controller']));
            } catch (RecordNotFoundException $e) {
                Log::warning(sprintf('Failed to fetch record with id [%s] from table [%s]', $id, $url['controller']));
            }
        }

        return $entity;
    }