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); }
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); }
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); }
public function __construct(array $properties = null, $loadMappings = DatabaseRecord::MAPPINGS_NO_LAZY) { parent::__construct($properties); $this->className = get_class($this); if (!isset(self::$dbMappings[$this->className])) { self::$dbMappings[$this->className] = array(); } if ($loadMappings !== self::MAPPINGS_NONE && is_callable(static::$mappingLoader)) { $noLazy = $loadMappings === self::MAPPINGS_NO_LAZY; foreach (self::$dbMappings[$this->className] as $property => $mapping) { if ($noLazy && $mapping->Lazy) { continue; } // Skip lazy mappings at load time. -- cwells call_user_func(static::$mappingLoader, $this, $property, $mapping); } } }