public function testIterator() { $dir = new Directory($this->root->url() . '/prj'); $dir->make(); $path = $dir->toPath(); $composer = $path->append('composer.json'); $file = $composer->toFileDescriptor()->toFile(); $file->write('{}'); $vendor = $path->append('vendor'); $folder = $vendor->toFileDescriptor()->toDirectory(); $folder->make(); $arr = new ArrayObject(); foreach ($dir as $k => $file) { if (!$file->isDot()) { $this->assertTrue($file instanceof FileDescriptor); $arr[$k] = $file->getFilename(); if ($file->isFile()) { $this->assertEquals('composer.json', $file->getFilename()); } if ($file->isDir()) { $this->assertEquals('vendor', $file->getFilename()); } } } $this->assertEquals(['composer.json', 'vendor'], $arr->sort()->toArray()); }
/** * Returns the path for managed files for this module * * @return Path */ public function getFilesPath() { $repo = $this->getServiceContainer()->getResourceRepository(); if (!$repo->contains($this->getFilesPuliPath())) { $dir = new Directory($repo->get('/files')->getFilesystemPath()); $path = $dir->toPath()->append('managed/' . $this->model->getName()); $dir = new Directory($path); $dir->make(); } $dir = new Directory($repo->get($this->getFilesPuliPath())->getFilesystemPath()); return $dir->toPath(); }