init
This commit is contained in:
27
mysyde/common/traits/genericViewTrait.php
Normal file
27
mysyde/common/traits/genericViewTrait.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace DynCom\mysyde\common\traits;
|
||||
/**
|
||||
* Class genericViewTrait
|
||||
*/
|
||||
trait genericViewTrait
|
||||
{
|
||||
use directoryFileWriterTrait;
|
||||
|
||||
abstract public function render();
|
||||
|
||||
/**
|
||||
* @param $filePath
|
||||
* @param bool $replace
|
||||
* @return bool
|
||||
*/
|
||||
public function renderToFilePath($filePath, $replace = false) {
|
||||
$filepath = $this->truepath($filePath,false,true,true);
|
||||
if($filepath && $this->canWriteToDirectory($filePath)) {
|
||||
$flags = 0;
|
||||
if($replace) $flags = (FILE_APPEND | LOCK_EX);
|
||||
return (file_put_contents($filePath,$this->render()) > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user