task = $task; } /** * {@inheritdoc} */ public function getVersions() { $x = sprintf('/^task_%d-(|(.*))\.log$/', $this->task->getId()); $f = new Finder(); $versions = []; /** @var \SplFileInfo $file */ foreach($f->files()->in($this->root) as $file) { $matches = []; if(preg_match($x, $file->getBasename(), $matches)) { $versions[] = $matches[1]; } } return $versions; } /** * Returns the related Task entity. * * @return Task */ public function getTask() { return $this->task; } /** * {@inheritdoc} */ public function getPath($version = '') { if (trim($version) != '') { $version = '-' . $version; } return sprintf('%s/task%s.log', $this->root, $version); } }