summaryrefslogtreecommitdiff
path: root/app/php/web/BaseUrlDerivedFromBasePath.php
blob: 2da277ff76b791e1df189cde9e4ce29f20b926c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

trait BaseUrlDerivedFromBasePath {

    public function init($config) {
        if ($this->BaseUrl === NULL && $this->BasePath !== NULL) {
            $appWebPath = preg_replace(
                '#' . $this->Application->Request->ApplicationUrl . '$#',
                '',
                $this->Application->Request->ApplicationFilePath
            );
            $appBaseUrl = preg_replace(
                '#^' . $appWebPath . '#',
                '',
                dirname($this->Application->Request->ApplicationFilePath)
            );
            $this->BaseUrl = $appBaseUrl
                . preg_replace(
                    '#^' . Prado::getPathOfNamespace('Web') . '#',
                    '',
                    $this->BasePath
                );
        }
        parent::init($config);
    }

}

?>