Source of file Section.php
Size: 1,782 Bytes - Last Modified: 2022-01-13T10:01:28+00:00
/var/www/docs.ssmods.com/process/src/code/model/Section.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | <?php namespace BenManu\StyleGuide; use SilverStripe\Control\Controller; use SilverStripe\View\ViewableData; use SplFileObject; /** * Section * * A Comment Block that represents a single section. */ class Section extends ViewableData { /** * The raw Comment Block * * @var string */ protected $rawComment = ''; /** * The file where the Comment Block came from * * @var \SplFileObject */ protected $file = null; /** * Creates a section with the Comment Block and source file * * @param string $comment * @param \SplFileObject $file */ public function __construct($comment = '', \SplFileObject $file = null) { $this->rawComment = $comment; $this->file = $file; } /** * Returns the source filename for where the comment block was located * * @return string */ public function getFilename() { if ($this->file === null) { return ''; } return $this->file->getFilename(); } /** * Render a SilverStripe template with fixture data if set. * @param String $template The name of the template. * @return String HTMLText string of the rendered template. */ public function getRenderedTemplate($template) { $controller = Controller::curr(); $fixture = $controller->getFixture(); // if the factory is set and the fixture object exists render the template with // the object. if($fixture) { if(array_key_exists($template, $fixture)) { $obj = $fixture[$template]; return $obj->renderWith($template); } } return $controller->renderWith($template); } } |