Exemple #1
0
 protected function _initLoggers()
 {
     try {
         $writer = new Zend_Log_Writer_Stream(_APP_LOG_FILE);
         $logger = new Zend_Log($writer);
         Zend_Registry::set('appLogger', $logger);
         $writerAD = new Zend_Log_Writer_Stream(_AD_LOG_FILE);
         $loggerAD = new Zend_Log($writerAD);
         Zend_Registry::set('ADLogger', $loggerAD);
         $writerError = new Zend_Log_Writer_Stream(_ERROR_LOG_FILE);
         $loggerError = new Zend_Log($writerError);
         Zend_Registry::set('errorLogger', $loggerError);
         $writerDebug = new Zend_Log_Writer_Stream(_DEBUG_LOG_FILE);
         $loggerDebug = new Zend_Log($writerDebug);
         Zend_Registry::set('debugLogger', $loggerDebug);
         $writerShutDown = new Zend_Log_Writer_Stream(_SHUTDOWN_LOG_FILE);
         $loggerShutDown = new Zend_Log($writerShutDown);
         Zend_Registry::set('shutdownLogger', $loggerShutDown);
         $writerPropel = new Zend_Log_Writer_Stream(_PROPEL_LOG_FILE);
         $loggerPropel = new Zend_Log($writerPropel);
         Zend_Registry::set('propelLogger', $loggerPropel);
     } catch (Exception $e) {
         $logFiles = array(_APP_LOG_FILE, _ERROR_LOG_FILE, _DEBUG_LOG_FILE, _SHUTDOWN_LOG_FILE, _PROPEL_LOG_FILE);
         foreach ($logFiles as $logFile) {
             if (!Dfi_File::isWriteable($logFile)) {
                 throw new Exception('file ' . $logFile . ' is not readeable');
             }
         }
     }
 }
Exemple #2
0
 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);
     }
 }
Exemple #3
0
 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 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);
     }
 }