Esempio n. 1
0
 public function __construct($path)
 {
     if (!is_dir($path)) {
         throw new FileNotFoundException('The specified path does not exist.', 404);
     }
     try {
         $iterator = new \DirectoryIterator($path);
     } catch (\Exception $ex) {
         throw new FileNotFoundException('The specified path does not exist.', 404);
     }
     $dirs = array();
     $files = array();
     foreach ($iterator as $file) {
         if ($file->isDot() || !$file->isReadable()) {
             continue;
         } else {
             if ($file->isDir()) {
                 $dirs[] = $file->getFilename();
             } else {
                 $files[] = $file->getFilename();
             }
         }
     }
     sort($dirs);
     sort($files);
     $properties = array('Name' => basename($path), 'Path' => $path, 'Directories' => $dirs, 'Files' => $files);
     parent::__construct($properties);
 }
Esempio n. 2
0
 public function __construct($relationship, $fromField, $toField, array $submappings = null, $lazy = null)
 {
     if (is_null($lazy)) {
         // By default, lazy load "Many" items while loading "One" items immediately. -- cwells
         $lazy = $relationship === self::OneToMany || $relationship === self::ManyToMany;
     }
     $table = explode('.', $toField);
     $table = $table[0];
     if (is_null($submappings)) {
         $objectType = $table;
     } else {
         // The main object type is the same as that of the last submapping. -- cwells
         $lastMapping = end($submappings);
         $objectType = $lastMapping->ObjectType;
     }
     if (is_null($fromField)) {
         // Could default to null, but makes the code awkward for complex mappings. -- cwells
         if ($relationship === self::OneToOne || $relationship === self::ManyToOne) {
             $fromField = $objectType . 'ID';
         } else {
             $fromField = 'ID';
         }
     }
     $properties = array('Relationship' => $relationship, 'FromField' => $fromField, 'ToField' => $toField, 'Table' => $table, 'ObjectType' => $objectType, 'Submappings' => $submappings, 'Lazy' => $lazy);
     parent::__construct($properties);
 }
Esempio n. 3
0
 public function __construct($path)
 {
     $this->fileInfo = new \SplFileInfo($path);
     if (!$this->fileInfo->isFile()) {
         throw new FileNotFoundException('The specified path does not exist.', 404);
     }
     $properties = array('Name' => $this->fileInfo->getBaseName(), 'Path' => $path, 'Updated' => $this->fileInfo->getCTime(), 'Modified' => $this->fileInfo->getMTime(), 'Size' => $this->fileInfo->getSize(), 'Hash' => hash_file(\CWA\IO\HASH_ALGORITHM, $path));
     parent::__construct($properties);
 }
Esempio n. 4
0
 public function &__get($property)
 {
     $value = parent::__get($property);
     // I removed the Lazy condition because selectAll() defaults to MAPPINGS_NONE. -- cwells
     //		if (is_null($value) && isset(self::$dbMappings[$this->className][$property]) && self::$dbMappings[$this->className][$property]->Lazy && is_callable(static::$mappingLoader)) {
     if (is_null($value) && isset(self::$dbMappings[$this->className][$property]) && is_callable(static::$mappingLoader)) {
         // This property has a lazy-loaded DB mapping, so load it now. -- cwells
         if (call_user_func(static::$mappingLoader, $this, $property, self::$dbMappings[$this->className][$property])) {
             return $this->properties[$property];
         }
     }
     return $value;
 }