protected function execute(InputInterface $input, OutputInterface $output) { $file = $input->getArgument('file'); $compile = (bool) $input->getOption('compile'); if ($file == '') { $output->writeln('Datei nicht angegeben'); return; } $file = new File($file); /* Performance: kein file_exists() */ //if (!$file->exists()) { // $output->writeln('Datei existiert nicht.'); // return; //} /* Der Source Path vom CMS */ $cp = PSC::getProjectsFactory()->getProject('psc-cms')->getClassPath(); //$output->writeln($file->getDirectory().' subDirOf '); //$output->writeln((string) $cp); /* Die Datei ist für uns (erstmal) nur interessant, wenn Sie im PSC-CMS Verzeichnis liegt Sie ist damit also eine SRC Datei und triggered das compilieren des Phars */ if ($file->getDirectory()->isSubdirectoryOf($cp) || $file->getDirectory()->equals($cp)) { PSC::getEventManager()->dispatchEvent('Psc.SourceFileChanged', (object) array('file' => $file, 'compile' => $compile), $this); if ($compile) { $output->writeln('SourceDatei in psc-cms ' . $file->getName() . ' wurde compiled.'); } else { $output->writeln('SourceDatei in psc-cms ' . $file->getName() . ' wurde als geändert markiert.'); } } else { $output->writeln('SourceDatei ' . $file . ' wurde nicht markiert.'); } }
public function testAppendName() { $path = self::absPath('Filme', 'Serien', 'The Big Bang Theory', 'Season 5'); $file = new File($path . 'The.Big.Bang.Theory.S05E07.en.IMMERSE.srt'); $file->setName($file->getName(File::WITHOUT_EXTENSION) . '-en.srt'); $this->assertEquals($path . 'The.Big.Bang.Theory.S05E07.en.IMMERSE-en.srt', (string) $file); }
/** * Gibt den Namen der Klasse für eine Datei zurück * * beruht auf der Konvention, dass jedes Verzeichnis ein Namespace ist und der Dateiname der Klassename ist * * Beispiel siehe Test * * * @param Dir $root darf nicht das verzeichnis des Namespaces sein. also nicht base\src\SerienLoader sondern base\src\ * @param string $style wird _ übergeben wird z. B. der PHPWord Style benutzt (PSR-0 mit Underscore) * @return string class mit \ davor */ public static function mapFileToClass(File $classFile, Dir $root = NULL, $style = '\\') { $classDir = clone $classFile->getDirectory(); if (isset($root)) { $classDir->makeRelativeTo($root); } $pa = $classDir->getPathArray(); if ($style === '\\') { $ns = count($pa) > 1 ? '\\' . implode('\\', array_slice($pa, 1)) : NULL; return $ns . '\\' . $classFile->getName(File::WITHOUT_EXTENSION); } elseif ($style === '_') { $parts = count($pa) > 1 ? array_slice($pa, 1) : array(); $parts[] = $classFile->getName(File::WITHOUT_EXTENSION); return implode('_', $parts); } else { \Psc\Exception('Der Style: ' . self::varInfo($style) . ' ist nicht bekannt'); } }
/** * Gibt den vollen Namen der Klasse aus der Datei zurück * * dies parsed nicht den Code der Datei, sondern geht von der Klassen-Struktur wie in Konventionen beschrieben aus * @return string */ public static function getFullClassName(File $classFile, Dir $classPath = NULL) { $classPath = $classPath ?: self::getProject()->getClassPath()->up(); try { $parts = $classFile->getDirectory()->makeRelativeTo($classPath)->getPathArray(); } catch (\Webforge\Common\System\Exception $e) { throw new Exception('ClassFile: "' . $classFile . '" liegt nicht im Verzeichnis: "' . $classPath . '"!', 0, $e); } array_shift($parts); // den . entfernen $parts[] = $classFile->getName(File::WITHOUT_EXTENSION); $className = '\\' . implode('\\', $parts); return $className; }
/** * @return string */ protected function getAliasFromFile($file) { $f = new File($file); return $f->getName(File::WITHOUT_EXTENSION); }
public function getExcelFileName() { return $this->exportFile->getName(File::WITHOUT_EXTENSION); }