Esempio n. 1
0
    public function generateClass($request) {
        try {
            if ($request) {

                $this->businessFunctions = array();

                $tableColumns = $this->getColumnsFromTable($request['tableName']);

                $columns = array();

                foreach ($request as $key=>$custom) {
                    $isId = false;
                    $sizeLabel = 0;
                    if (strstr($key, 'ppk-id-')) {
                        $isId = true;
                        $sizeLabel = 7;

                    } else if (strstr($key, 'ppk-column-')) {
                        $sizeLabel = 11;

                    }

                    if ($sizeLabel) {
                        $col = substr($key, $sizeLabel);
                        $label = utf8_encode($request['ppk-label-'.$col]);

                        foreach ($tableColumns as $tblCol) {
                            $ok = false;
                            switch (\core\Config::DATABASE_TYPE) {
                                case 0:
                                    if ($tblCol->Field == $col)
                                        $ok = true;
                                    break;

                                case 1:
                                    if ($tblCol->name == $col)
                                        $ok = true;
                                    break;
                            }
                            if ($ok) {
                                $columns[] = array(
                                        'IsId' => $isId,
                                        'Column' => $col,
                                        'Property' => $custom,
                                        'Label' => $label,
                                        'TableColumn' => $tblCol
                                );
                                break;
                            }
                        }
                    }
                }

                $entityClass = $this->createEntityClass($request['name'], $request['tableName'], $columns);
                $repositoryClass = $this->createRepositoryClass($request['name']);
                $businessClass = $this->createBusinessClass($request['name']);
                $presentationClass = $this->createPresentationClass($request['name'], $columns);

                FileHelper::putContent($request['name'].'.php', PAPRIKA_CUSTOM_PATH.DIRECTORY_SEPARATOR.Config::CUSTOM_CODE_ENTITY, $entityClass);
                FileHelper::putContent($request['name'].'Repository.php', PAPRIKA_CUSTOM_PATH.DIRECTORY_SEPARATOR.Config::CUSTOM_CODE_REPOSITORY, $repositoryClass);
                FileHelper::putContent($request['name'].'Business.php', PAPRIKA_CUSTOM_PATH.DIRECTORY_SEPARATOR.Config::CUSTOM_CODE_BUSINESS, $businessClass);
                FileHelper::putContent($request['name'].'Presentation.php', PAPRIKA_CUSTOM_PATH.DIRECTORY_SEPARATOR.Config::CUSTOM_CODE_PRESENTATION, $presentationClass);

                return true;
            }

        } catch (\Exception $e) {
            throw $e;
        }
    }
Esempio n. 2
0
    private function log($type, $log) {
        if ($type < Config::LOGGING_LEVEL)
            return;

        $detailTime = \helper\DateHelper::getTimeWithMicroSeconds();
        $logTime = \helper\DateHelper::getSysdateCustomFormat(\helper\DateHelper::DT_ONLY_HOURS, true);
        $logDay = \helper\DateHelper::getSysdateCustomFormat(\helper\DateHelper::DT_WITHOUT_HOURS);

        $trace = array();
        foreach (debug_backtrace() as $line) {
            if (isset($line['file'])) {
                $trace[] = $line['class'].$line['type'].$line['function'].'('.$line['file'].':'.$line['line'].')';
            } else {
                $trace[] = $line['class'].$line['type'].$line['function'];
            }
        }

        if (is_a($log, 'Exception')) {
            $message = $log->getMessage();
        } else {
            $message = $log;
        }

        $content = $logTime.' '.self::getTypeText($type).' '.$line['class'].$line['type'].$line['function'].' - '.$message;
        $content .= ' <a href="'.$logDay.'/'.$detailTime.'.html">[ detail ]</a>'.'<br />';

        \helper\FileHelper::createFolder(Config::LOGGING_FOLDER, ROOT_PATH);

        \helper\FileHelper::createFolder($logDay, ROOT_PATH.Config::LOGGING_FOLDER);

        \helper\FileHelper::putContent($logDay.'.html', ROOT_PATH.Config::LOGGING_FOLDER, $content);

        \helper\FileHelper::putContent($detailTime.'.html', ROOT_PATH.Config::LOGGING_FOLDER.'/'.$logDay, implode('<br />', $trace));
    }