public function render() { $template = $this->getTemplate(); if (Dfi_File::isReadable($template)) { $code = file_get_contents($template); $code = $this->prepare($code); $this->renderedCode = $code; } else { $this->provider->_printMessage('template ' . $template . ' not readable ', ZFscaffold_ZfTool_ScaffoldProvider::MSG_ERROR); } $this->isRendered = true; return $this; }
public function merge($schemaPath, $config) { error_reporting(E_ALL | E_STRICT); ini_set('display_errors', true); defined('PROJECT_IN_ENGLISH') || define('PROJECT_IN_ENGLISH', true); date_default_timezone_set('Europe/Warsaw'); $this->schemaXml = $schemaPath . '/schema.xml'; if (Dfi_File::isReadable($config)) { $this->config = new Zend_Config_Ini($config); } else { $this->config = new Zend_Config(array()); } $files = array(); //$path = dirname(__FILE__) . '/../schema'; $iterator = new DirectoryIterator($schemaPath); foreach ($iterator as $fileInfo) { /* @var $fileInfo SplFileInfo */ if ($fileInfo->isFile()) { if (strpos($fileInfo->getFilename(), 'schema') !== false) { $files[] = $fileInfo->getPathname(); } } } foreach ($files as $schemaFile) { if (isset($schema)) { unset($schema); } $schema = new DOMDocument(); $schema->preserveWhiteSpace = false; $schema->formatOutput = true; if (!$schema->load($schemaFile)) { throw new Exception(sprintf("Nie odnaleziono pliku %s.", $this->schemaXml)); } $domElemsToRemove = array(); /** @var $tables DOMNodeList */ $tables = $schema->getElementsByTagName('table'); /** @var $table DOMElement */ foreach ($tables as $table) { if ($this->isAllowedTable($table)) { $this->checkPhpName($table); $this->publicSchemaFix($table, $schema); $this->checkInherit($table); $this->checkView($table, $schema); $this->checkTree($table, $schema); $this->checkManyToMany($table, $schema); $this->checkManyToManyEqual($table, $schema); $this->checkSortable($table, $schema); $this->checkSlugable($table, $schema); $this->checkHashable($table, $schema); $this->checkCrossReference($table); } else { //remove table $domElemsToRemove[] = $table; } } foreach ($domElemsToRemove as $domElement) { $domElement->parentNode->removeChild($domElement); } $schema->save($schemaFile); } }
public static function copyFileContent(Zend_Tool_Project_Context_Filesystem_File $resource) { $path = realpath(__DIR__ . '/templates/project') . '/'; if ($resource->getResource()->getAttribute('sourceName')) { $template = $resource->getResource()->getAttribute('sourceName'); } else { $template = $resource->getResource()->getAttribute('filesystemName'); } /** @noinspection PhpToStringImplementationInspection */ if (Dfi_File::isReadable($path . $template)) { return file_get_contents($path . $template); } else { throw new ZFscaffold_ZfTool_Exception('template defined but not found: ' . $template, self::MSG_ERROR); } }