Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
80.00% |
8 / 10 |
CRAP | |
50.00% |
9 / 18 |
FileReadOnlyStorage | |
0.00% |
0 / 1 |
|
80.00% |
8 / 10 |
38.50 | |
50.00% |
9 / 18 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
exists | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
load | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
save | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
delete | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
getFullPath | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
writeable | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
deleteAll | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
listAll | |
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 8 |
|||
garbageCollection | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\Component\PhpStorage\FileReadOnlyStorage. | |
*/ | |
namespace Drupal\Component\PhpStorage; | |
/** | |
* Reads code as regular PHP files, but won't write them. | |
*/ | |
class FileReadOnlyStorage implements PhpStorageInterface { | |
/** | |
* The directory where the files should be stored. | |
* | |
* @var string | |
*/ | |
protected $directory; | |
/** | |
* Constructs this FileStorage object. | |
* | |
* @param $configuration | |
* An associative array, containing at least two keys (the rest are ignored): | |
* - directory: The directory where the files should be stored. | |
* - bin: The storage bin. Multiple storage objects can be instantiated with | |
* the same configuration, but for different bins. | |
*/ | |
public function __construct(array $configuration) { | |
$this->directory = $configuration['directory'] . '/' . $configuration['bin']; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function exists($name) { | |
return file_exists($this->getFullPath($name)); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function load($name) { | |
// The FALSE returned on failure is enough for the caller to handle this, | |
// we do not want a warning too. | |
return (@include_once $this->getFullPath($name)) !== FALSE; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function save($name, $code) { | |
return FALSE; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function delete($name) { | |
return FALSE; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getFullPath($name) { | |
return $this->directory . '/' . $name; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
function writeable() { | |
return FALSE; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function deleteAll() { | |
return FALSE; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function listAll() { | |
$names = array(); | |
if (file_exists($this->directory)) { | |
foreach (new \DirectoryIterator($this->directory) as $fileinfo) { | |
if (!$fileinfo->isDot()) { | |
$name = $fileinfo->getFilename(); | |
if ($name != '.htaccess') { | |
$names[] = $name; | |
} | |
} | |
} | |
} | |
return $names; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function garbageCollection() { | |
} | |
} |