Doctrine\OXM\Tools\XmlEntityGenerator::writeXmlEntityClass PHP Метод

writeXmlEntityClass() публичный Метод

Generated and write xml-entity class to disk for the given ClassMetadataInfo instance
public writeXmlEntityClass ( ClassMetadataInfo $metadata, string $outputDirectory ) : void
$metadata Doctrine\OXM\Mapping\ClassMetadataInfo
$outputDirectory string
Результат void
    public function writeXmlEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
    {
        $path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metadata->name) . $this->extension;
        $dir = dirname($path);
        if (!is_dir($dir)) {
            mkdir($dir, 0777, true);
        }
        $this->isNew = !file_exists($path) || file_exists($path) && $this->regenerateXmlEntityIfExists;
        if (!$this->isNew) {
            $this->parseTokensInXmlEntityFile($path);
        }
        if ($this->backupExisting && file_exists($path)) {
            $backupPath = dirname($path) . DIRECTORY_SEPARATOR . "~" . basename($path);
            if (!copy($path, $backupPath)) {
                throw new \RuntimeException("Attempt to backup overwritten xml-entity file but copy operation failed.");
            }
        }
        // If xml-entity doesn't exist or we're re-generating the xml-entities entirely
        if ($this->isNew) {
            file_put_contents($path, $this->generateXmlEntityClass($metadata));
            // If xml-entity exists and we're allowed to update the xml-entity class
        } else {
            if (!$this->isNew && $this->updateXmlEntityIfExists) {
                file_put_contents($path, $this->generateUpdatedXmlEntityClass($metadata, $path));
            }
        }
    }