Обертка для file_get_contents
This commit is contained in:
parent
bfd53ecc09
commit
0d92ebad86
5 changed files with 17 additions and 6 deletions
|
|
@ -167,7 +167,7 @@ class Controller_Component
|
|||
function getInfo() {
|
||||
$filename = Path::join($this->viewPath[0], 'install.json');
|
||||
if (file_exists($filename)) {
|
||||
$settings = json_decode(file_get_contents($filename), true);
|
||||
$settings = json_decode(File::getContents($filename), true);
|
||||
return $settings;
|
||||
}
|
||||
return array();
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class Database_Manager
|
|||
$this->db->query($q);
|
||||
}
|
||||
|
||||
function getConstraintDef($c) {
|
||||
function getConstraintDef(/*.array.*/$c) {
|
||||
if ($c['type'] == 'unique') {
|
||||
return "UNIQUE(" . implode(", ", $c['fields']) . ")";
|
||||
}
|
||||
|
|
|
|||
11
src/File.php
Normal file
11
src/File.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
class File {
|
||||
static function getContents($filename) {
|
||||
$buffer = file_get_contents($filename);
|
||||
if ($buffer !== false) {
|
||||
return $buffer;
|
||||
}
|
||||
throw new Exception("Unable to read file: " . $filename);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ class Settings extends Collection
|
|||
// Не include_once т.к читать настройки можно несколько раз
|
||||
$settings = array();
|
||||
if ($this->format == 'json') {
|
||||
$settings = json_decode(file_get_contents($this->file), true);
|
||||
$settings = json_decode(File::getContents($this->file), true);
|
||||
} else {
|
||||
include ($this->file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ class Tools_SQLStatementExtractor {
|
|||
*/
|
||||
public static function extractFile($filename) {
|
||||
$buffer = file_get_contents($filename);
|
||||
if ($buffer === false) {
|
||||
throw new Exception("Unable to read file: " . $filename);
|
||||
if ($buffer !== false) {
|
||||
return self::extractStatements(self::getLines($buffer));
|
||||
}
|
||||
return self::extractStatements(self::getLines($buffer));
|
||||
throw new Exception("Unable to read file: " . $filename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue