Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 final class DirectoryGetter extends PrototypedGetter
00013 {
00014 public function get($name)
00015 {
00016 if (!isset($this->mapping[$name]))
00017 throw new WrongArgumentException(
00018 "knows nothing about property '{$name}'"
00019 );
00020
00021 $primitive = $this->mapping[$name];
00022
00023 $path = $this->object.'/'.$primitive->getName();
00024
00025 if ($primitive instanceof PrimitiveFile)
00026 return $path;
00027
00028 if (!file_exists($path))
00029 return null;
00030
00031 if ($primitive instanceof PrimitiveForm) {
00032 if (!$primitive instanceof PrimitiveFormsList)
00033 return $path;
00034
00035 $result = array();
00036
00037 $subDirs = glob($path.'/*');
00038
00039 if ($subDirs === false)
00040 throw new WrongStateException(
00041 'cannot read directory '.$path
00042 );
00043
00044 foreach ($subDirs as $path)
00045 $result[basename($path)] = $path;
00046
00047 return $result;
00048 }
00049
00050 for ($i = 0; $i <= 42; ++$i) {
00051 $result = file_get_contents($path);
00052
00053 if ($result === false) {
00054 throw new WrongArgumentException("failed to read $path");
00055 }
00056
00057 if ($result)
00058 break;
00059
00060
00061
00062
00063 }
00064
00065 return $result;
00066 }
00067 }
00068 ?>