# BaseBuilder.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2006-2009 by Konstantin V. Arkhipov                     *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00015     abstract class BaseBuilder extends StaticFactory
    00016     {
    00017         public static function build(MetaClass $class)
    00018         {
    00019             throw new UnimplementedFeatureException('i am forgotten method');
    00020         }
    00021
    00022         protected static function buildPointers(MetaClass $class)
    00023         {
    00024             $out = null;
    00025
    00026             if (!$class->getPattern() instanceof AbstractClassPattern) {
    00027                 if (
    00028                     $class->getIdentifier()->getColumnName() !== 'id'
    00029                 ) {
    00030                     $out .= <<<EOT
    00031 public function getIdName()
    00032 {
    00033     return '{$class->getIdentifier()->getColumnName()}';
    00034 }
    00035
    00036 EOT;
    00037                 }
    00038
    00039                 $out .= <<<EOT
    00040 public function getTable()
    00041 {
    00042     return '{$class->getTableName()}';
    00043 }
    00044
    00045 public function getObjectName()
    00046 {
    00047     return '{$class->getName()}';
    00048 }
    00049
    00050 public function getSequence()
    00051 {
    00052     return '{$class->getTableName()}_id';
    00053 }
    00054 EOT;
    00055             } elseif ($class->getWithInternalProperties()) {
    00056                 $out .= <<<EOT
    00057 // no get{Table,ObjectName,Sequence} for abstract class
    00058 EOT;
    00059             }
    00060
    00061             if ($liaisons = $class->getReferencingClasses()) {
    00062                 $uncachers = array();
    00063                 foreach ($liaisons as $className) {
    00064                     $uncachers[] = $className.'::dao()->uncacheLists();';
    00065                 }
    00066
    00067                 $uncachers = implode("\n", $uncachers);
    00068
    00069                 $out .= <<<EOT
    00070
    00071
    00072 public function uncacheLists()
    00073 {
    00074 {$uncachers}
    00075
    00076 return parent::uncacheLists();
    00077 }
    00078 EOT;
    00079             }
    00080
    00081             if ($source = $class->getSourceLink()) {
    00082                 $out .= <<<EOT
    00083
    00084
    00085 public function getLinkName()
    00086 {
    00087     return '{$source}';
    00088 }
    00089 EOT;
    00090             }
    00091
    00092             return $out;
    00093         }
    00094
    00095         protected static function getHead()
    00096         {
    00097             $head = self::startCap();
    00098
    00099             $head .=
    00100                 ' *   This file is autogenerated - do not edit.'
    00101                 .'                               *';
    00102
    00103             return $head."\n".self::endCap();
    00104         }
    00105
    00106         protected static function startCap()
    00107         {
    00108             $version = ONPHP_VERSION;
    00109             $date = date('Y-m-d H:i:s');
    00110
    00111             $info = " *   Generated by onPHP-{$version} at {$date}";
    00112             $info = str_pad($info, 77, ' ', STR_PAD_RIGHT).'*';
    00113
    00114             $cap = <<<EOT
    00115 <?php
    00116 /*****************************************************************************
    00117  *   Copyright (C) 2006-2009, onPHP's MetaConfiguration Builder.             *
    00118 {$info}
    00119
    00120 EOT;
    00121
    00122             return $cap;
    00123         }
    00124
    00125         protected static function endCap()
    00126         {
    00127             $cap = <<<EOT
    00128  *****************************************************************************/
    00129
    00130
    00131 EOT;
    00132             return $cap;
    00133         }
    00134
    00135         protected static function getHeel()
    00136         {
    00137             return '?>';
    00138         }
    00139     }
    00140 ?>