예제 #1
0
파일: Render.php 프로젝트: thevajko/vf-core
 /**
  * Method for rendering a template file with data
  *
  * Method pass to selected template file a data. Template file is automatically found.
  *
  * @param $templateFilename
  * @param null $data
  * @return string
  * @throws \Exception
  */
 public function renderTemplate($templateFilename, $data = null)
 {
     //check if template file exists
     $template = $this->scriptFinder->findScript("/" . $templateFilename . "/i");
     //if do not existst throw exception
     if (count($template) < 1) {
         throw new \Exception("Presenter '{$templateFilename}' not found.", 500);
     }
     //run template in separed method
     return $this->runTemplate(reset($template), $data);
 }
예제 #2
0
파일: Booter.php 프로젝트: thevajko/vf-core
 /**
  * Method that creates base instances needed for application
  *
  * @throws \Exception
  */
 private function boot()
 {
     //start the magic - auto loading
     $this->initScriptLazyAutoloading();
     // !!!! - Below is initialization of core element that cannot be changed
     //application init
     //first step - init container
     $this->container = new Container();
     //add script finder for templates
     $this->container->add($this->scriptFinder, EnumCoreElements::scriptFinder);
     //create configurator
     $this->configurator = new Configurator($this->scriptFinder->findScript("/config.json/"));
     //loading config file is needed to be here
     $this->container->add($this->configurator, EnumCoreElements::config);
     // !!!! - End of initialization of core element that cannot be changed
     //get classes from config, these element can be changed by developer, that is why are loaded from configuration file
     $classesToLoad = (array) $this->configurator->get("www.bootSequence");
     //start autoloading
     foreach ($classesToLoad as $classIdentificator => $classToLoad) {
         //get class name and crete instance
         /** @var IContainerItem $classInstance */
         $classInstance = new $classToLoad();
         //put instance into container
         $this->container->add($classInstance, $classIdentificator);
     }
     //run post fulling method, so components in container can fully initialize
     $this->container->initializeCall();
 }