1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- /**
- *
- * Cube Framework $Id$ LsIyAcSahn0uF+QZ9tGePJX0AaQdEhKpWX0PHRCWJsE=
- *
- * @link http://codecu.be/framework
- * @copyright Copyright (c) 2015 CodeCube SRL
- * @license http://codecu.be/framework/license Commercial License
- *
- * @version 1.4
- */
- /**
- * partial view helper
- */
- namespace Cube\View\Helper;
- class Partial extends AbstractHelper
- {
- /**
- *
- * data to be used by the partial
- *
- * @var array
- */
- protected $_data = array();
- /**
- *
- * path where to search for view partial files
- *
- * @var string
- */
- protected $_path;
- /**
- *
- * get view partials path
- *
- * @return string
- */
- public function getPath()
- {
- return $this->_path;
- }
- /**
- *
- * set view partials path
- *
- * @param string $path
- *
- * @return $this
- */
- public function setPath($path)
- {
- $this->_path = rtrim($path, DIRECTORY_SEPARATOR);
- return $this;
- }
- /**
- *
- * process view partial and return output
- *
- * @param string $partial view partial name/path
- * @param array $data input data to be handled by the view partial
- * @param string $path view partials path
- *
- * @return string|$this partial output
- */
- public function partial($partial = null, array $data = null, $path = null)
- {
- if ($partial === null) {
- return $this;
- }
- $this->setPath($path);
- $this->setPartial($partial);
- $view = clone $this->getView();
- $view->clearVariables();
- if ($data !== null) {
- $view->setVariables($data);
- }
- $file = $this->getPath() . DIRECTORY_SEPARATOR . $this->getPartial();
- return $view->process(
- $file, true);
- }
- }
|