Skip to content

Commit

Permalink
Slim4 prep
Browse files Browse the repository at this point in the history
  • Loading branch information
rotexdegba committed Feb 18, 2023
1 parent a315b6f commit b9779d4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,17 @@ public function setResponse(\Psr\Http\Message\ResponseInterface $response): self

return $this;
}


public function getAppBasePath(): string {

return $this->getContainer()->get('settings')['app_base_path'];
}

public function makeLink(string $path): string {

return rtrim($this->getAppBasePath(), '/') . '/' . ltrim($path, '/');
}

/**
*
* Executes a PHP file and returns its output as a string. This file is
Expand Down Expand Up @@ -294,6 +304,12 @@ public function renderLayout( string $file_name, array $data = ['content'=>'Cont
}
} // if( !($this->layout_renderer instanceof \Rotexsoft\FileRenderer\Renderer) )

$self = $this;
$data['sMVC_MakeLink'] = function(string $path) use ($self): string {

return $self->makeLink($path);
};

return $this->layout_renderer->renderToString($file_name, $data);
}

Expand Down Expand Up @@ -371,6 +387,12 @@ public function renderView( string $file_name, array $data = [] ): string {
$this->view_renderer->prependPath($path_2_view_files . $this->controller_name_from_uri);
}

$self = $this;
$data['sMVC_MakeLink'] = function(string $path) use ($self): string {

return $self->makeLink($path);
};

return $this->view_renderer->renderToString($file_name, $data);
}

Expand Down

0 comments on commit b9779d4

Please sign in to comment.