Обертка для 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() {
|
function getInfo() {
|
||||||
$filename = Path::join($this->viewPath[0], 'install.json');
|
$filename = Path::join($this->viewPath[0], 'install.json');
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
$settings = json_decode(file_get_contents($filename), true);
|
$settings = json_decode(File::getContents($filename), true);
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ class Database_Manager
|
||||||
$this->db->query($q);
|
$this->db->query($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConstraintDef($c) {
|
function getConstraintDef(/*.array.*/$c) {
|
||||||
if ($c['type'] == 'unique') {
|
if ($c['type'] == 'unique') {
|
||||||
return "UNIQUE(" . implode(", ", $c['fields']) . ")";
|
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 т.к читать настройки можно несколько раз
|
// Не include_once т.к читать настройки можно несколько раз
|
||||||
$settings = array();
|
$settings = array();
|
||||||
if ($this->format == 'json') {
|
if ($this->format == 'json') {
|
||||||
$settings = json_decode(file_get_contents($this->file), true);
|
$settings = json_decode(File::getContents($this->file), true);
|
||||||
} else {
|
} else {
|
||||||
include ($this->file);
|
include ($this->file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ class Tools_SQLStatementExtractor {
|
||||||
*/
|
*/
|
||||||
public static function extractFile($filename) {
|
public static function extractFile($filename) {
|
||||||
$buffer = file_get_contents($filename);
|
$buffer = file_get_contents($filename);
|
||||||
if ($buffer === false) {
|
if ($buffer !== false) {
|
||||||
throw new Exception("Unable to read file: " . $filename);
|
|
||||||
}
|
|
||||||
return self::extractStatements(self::getLines($buffer));
|
return self::extractStatements(self::getLines($buffer));
|
||||||
}
|
}
|
||||||
|
throw new Exception("Unable to read file: " . $filename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract statements from string.
|
* Extract statements from string.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue