Source

Ray / Ray / View / File / View.php

<?php

class Ray_View_File_View{
    
    private $__file;
    
    private $__render;
    
    private $__params;
    
    private $__config;
    
    private $__options;
    
    public function __construct($file, $params=array(), $config, $options){
        
        $this->__file = $file;
        
        $this->__config = $config;
        
        $this->__options = $options;
        
        $this->__params = $params;
        
        foreach($params as $key => $value){
            if(is_string($key)){
                $this->$key = $value;
            }
        }
        
    }
    
    public function element($element, $params=array(), $dir='element'){
        $file = $this->__config['templates'] . DS . $this->__options['actionDir']
              . ($dir ? DS . $dir : '' ) . DS . $element . $this->__options['ext'];
              
        if(file_exists($file)){
            $view = new self($file, array_merge($this->__params, $params), $this->__config, $this->__options);
            
            return $view->render();
        }else{
            throw new Ray_Exception_View_File('Element template file not found. Path: '. $file);
        }
        
        return;
    }
    
    public function render(){
        if(!$this->__render){
            ob_start();
            
            require $this->__file;
            
            $this->__render = ob_get_contents();
            
            ob_end_clean();
        }
        
        return $this->__render;
    }
    
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.