Capsule::setTemplatePath PHP Method

setTemplatePath() public method

Set the basepath to use for template lookups.
public setTemplatePath ( string $v )
$v string
    function setTemplatePath($v)
    {
        $this->templatePath = rtrim($v, DIRECTORY_SEPARATOR . '/');
    }

Usage Example

 /**
  * Creates a new Capsule context with some basic properties set.
  * (Capsule is a simple PHP encapsulation system -- aka a php "template" class.)
  * @return Capsule
  */
 protected function createContext()
 {
     $context = new Capsule();
     // Make sure the output directory exists, if it doesn't
     // then create it.
     $outputDir = new PhingFile($this->outputDirectory);
     if (!$outputDir->exists()) {
         $this->log("Output directory does not exist, creating: " . $outputDir->getAbsolutePath());
         $outputDir->mkdirs();
     }
     // Place our set of data models into the context along
     // with the names of the databases as a convenience for now.
     $context->put("targetDatabase", $this->targetDatabase);
     $context->put("targetPackage", $this->targetPackage);
     $context->put("now", strftime("%c"));
     $this->log("Target database type: " . $this->targetDatabase);
     $this->log("Target package: " . $this->targetPackage);
     $this->log("Using template path: " . $this->templatePath);
     $this->log("Output directory: " . $this->outputDirectory);
     $context->setTemplatePath($this->templatePath);
     $context->setOutputDirectory($this->outputDirectory);
     $this->populateContextProperties($context);
     return $context;
 }
All Usage Examples Of Capsule::setTemplatePath