Ouzo\Utilities\Files::loadIfExists PHP Method

loadIfExists() public static method

Loads a file using require or require_once if the $loadOnce flag is set to true.
public static loadIfExists ( string $path, boolean $loadOnce = true ) : boolean
$path string
$loadOnce boolean
return boolean
    public static function loadIfExists($path, $loadOnce = true)
    {
        if (self::exists($path)) {
            self::_require($path, $loadOnce);
            return true;
        }
        return false;
    }

Usage Example

Beispiel #1
0
 private function _loadHelpers()
 {
     $viewHelperPath = Path::join('Helper', 'ViewHelper.php');
     $appHelperPath = Path::join(ROOT_PATH, ApplicationPaths::getHelperPath(), 'ApplicationHelper.php');
     $formHelperPath = Path::join('Helper', 'FormHelper.php');
     $urlHelperPath = Path::join(ROOT_PATH, ApplicationPaths::getHelperPath(), 'UrlHelper.php');
     $this->_requireOnce($viewHelperPath);
     Files::loadIfExists($appHelperPath);
     $this->_requireOnce($formHelperPath);
     Files::loadIfExists($urlHelperPath);
 }
All Usage Examples Of Ouzo\Utilities\Files::loadIfExists