private function generateManyToManySetter(ManyToManyProperty $property)
 {
     $containerProp = $property->getEntity()->getPrimaryKey()->getName();
     $containedProp = Singleton::create("ServiceBuilder")->getEntity($property->getEntityName())->getPrimaryKey()->getName();
     $signature = "set" . ucfirst($property->getName()) . "(\${$containerProp}, \${$containedProp}s)";
     return "\tpublic function {$signature} {\n\t\t\$this->getPersistence()->{$signature};\n\t}\n\n";
 }
Beispiel #2
0
 public function __construct()
 {
     $this->db = Singleton::create("DatabaseManager");
     if (is_null(self::$dbCache)) {
         self::$dbCache = BeanLocator::get("DatabaseCache");
     }
 }
Beispiel #3
0
 public function __construct()
 {
     $this->id = rand(100000, 999999);
     if (is_null(self::$settings)) {
         self::$settings = Singleton::create("Settings");
     }
 }
 protected function getAsObject($row)
 {
     $result = new Teacher();
     $result->setNew(false);
     $result->setTeacherId(Singleton::create("NullConverter")->fromDBtoDOM($row["teacherId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     return $result;
 }
 protected function getAsObject($row)
 {
     $result = new BoggleGame();
     $result->setNew(false);
     $result->setGameId(Singleton::create("NullConverter")->fromDBtoDOM($row["gameId"]));
     $result->setStarted(Singleton::create("BooleanConverter")->fromDBtoDOM($row["started"]));
     return $result;
 }
 protected function getAsObject($row)
 {
     $result = new BogglePlayer();
     $result->setNew(false);
     $result->setPlayerId(Singleton::create("NullConverter")->fromDBtoDOM($row["playerId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     $result->setGameId(Singleton::create("NullConverter")->fromDBtoDOM($row["gameId"]));
     return $result;
 }
 protected function getAsObject($row)
 {
     $result = new Address();
     $result->setNew(false);
     $result->setAddressId(Singleton::create("NullConverter")->fromDBtoDOM($row["addressId"]));
     $result->setStreet(Singleton::create("NullConverter")->fromDBtoDOM($row["street"]));
     $result->setLocation(Singleton::create("NullConverter")->fromDBtoDOM($row["location"]));
     return $result;
 }
 private function getOneToManyMappedGettersSetters(Entity $entity)
 {
     $result = "";
     foreach (Singleton::create("ServiceBuilder")->getOneToManyMappedProperties($entity) as $property) {
         $entityName = $property->getEntity()->getName();
         $name = $property->getMappingKey();
         $result .= "\tprivate \${$name};\n\n" . "\tpublic function get" . ucfirst($name) . "() {\n\t\treturn \$this->{$name};\n\t}\n\n" . "\tpublic function get" . $entityName . "() {\n\t\treturn {$entityName}ServiceUtil::get{$entityName}(\$this->{$name});\n\t}\n\n" . "\tpublic function set" . ucfirst($name) . "(\${$name}) {\n\t\t\$this->{$name} = \${$name};\n\t}\n\n";
     }
     return $result;
 }
 protected function getAsObject($row)
 {
     $result = new BubbleHighScore();
     $result->setNew(false);
     $result->setHscoreId(Singleton::create("NullConverter")->fromDBtoDOM($row["hscoreId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     $result->setPlayDate(Singleton::create("DateConverter")->fromDBtoDOM($row["playDate"]));
     $result->setSeconds(Singleton::create("NullConverter")->fromDBtoDOM($row["seconds"]));
     return $result;
 }
Beispiel #10
0
 protected function getAsObject($row)
 {
     $result = new User();
     $result->setNew(false);
     $result->setId(Singleton::create("NullConverter")->fromDBtoDOM($row["id"]));
     $result->setFirstName(Singleton::create("NullConverter")->fromDBtoDOM($row["firstName"]));
     $result->setLastName(Singleton::create("NullConverter")->fromDBtoDOM($row["lastName"]));
     $result->setCreateDate(Singleton::create("DateConverter")->fromDBtoDOM($row["createDate"]));
     $result->setDefault(Singleton::create("BooleanConverter")->fromDBtoDOM($row["default"]));
     return $result;
 }
Beispiel #11
0
 public function moveToDir($destinationDir, $renamedFile = null)
 {
     $newName = is_null($renamedFile) ? $this->getFileName() : $renamedFileName;
     $root = Singleton::create("Settings")->getRootPath();
     $relativeDestination = "{$destinationDir}/{$newName}";
     $uploadDestination = "{$root}/{$relativeDestination}";
     if (!move_uploaded_file($this->tempServerName, $uploadDestination)) {
         throw new FileUploadException("File cannot be moved from temporary directory");
     }
     $this->relativeDestination = $relativeDestination;
 }
Beispiel #12
0
 private function generateMappingTable($table, $props)
 {
     $sql = "CREATE TABLE `{$table}` (\n";
     $pkNames = array();
     foreach ($props as $prop) {
         $pk = Singleton::create("ServiceBuilder")->getEntity($prop->getEntityName())->getPrimaryKey();
         $pkName = "`{$pk->getName()}`";
         $sql .= "\t{$pkName} {$pk->getDbType()} NOT NULL,\n";
         $pkNames[] = $pkName;
     }
     return $sql . "\t PRIMARY KEY (" . implode(",", $pkNames) . ")\n);\n\n";
 }
Beispiel #13
0
 private function getConverter()
 {
     $t = is_null($this->type) ? "Null" : $this->type;
     return Singleton::create("Domain{$t}Converter");
 }
Beispiel #14
0
 private function getPersistence()
 {
     return Singleton::create("TeamPersistence");
 }
 private static function getService()
 {
     return Singleton::create("BubbleHighScoreService");
 }
 private function getPersistence()
 {
     return Singleton::create("BogglePlayerPersistence");
 }
Beispiel #17
0
<?php

require_once "path.php";
session_start();
require_once "lib/error/runtime-errors.php";
set_exception_handler("handleException");
set_error_handler("handleError", E_ALL);
$view = Singleton::create("ActionController")->perform($_GET, $_POST, $_FILES);
echo Singleton::create("ViewRenderer")->render($view);
Beispiel #18
0
<?php

error_reporting(E_ALL);
ini_set("display_errors", "1");
require_once "path.php";
require_once "lib/error/service-errors.php";
set_exception_handler("handleException");
set_error_handler("handleError", E_ALL);
print "\n\n";
$sb = Singleton::create("ServiceBuilder");
$entities = $sb->buildServices();
print "\n\n";
Beispiel #19
0
 public function __construct()
 {
     $this->xmlFactory = Singleton::create("DOMXmlFactory");
     $this->settings = Singleton::create("Settings");
 }
Beispiel #20
0
 public function __construct()
 {
     $this->defaultUrl = Singleton::create("Settings")->getDefaultUrl();
 }
Beispiel #21
0
 public function __construct()
 {
     $this->enabled = Singleton::create("Settings")->isDbCacheEnabled();
 }
 private function getPersistence()
 {
     return Singleton::create("BoggleHighScorePersistence");
 }
 private function getPersistence()
 {
     return Singleton::create("AddressPersistence");
 }
Beispiel #24
0
 private function importEntities()
 {
     $file = Singleton::create("DOMXmlFactory")->fromFile("config/service.xml");
     $root = $file->getRootElement();
     $entityEls = $root->getChildren("entity");
     $this->entities = array();
     foreach ($entityEls as $entityEl) {
         $name = $entityEl->getAttribute("name");
         $table = $entityEl->getAttribute("table");
         $entity = new Entity($name, $table);
         // Insert properties
         foreach ($entityEl->getChildren("column") as $property) {
             $propertyName = $property->getAttribute("name");
             $type = $property->getAttribute("type");
             $size = $property->getAttribute("size");
             $entityName = $property->getAttribute("entity");
             $mappingTable = $property->getAttribute("mapping-table");
             $primary = $property->getAttribute("primary") == "true";
             $autoIncrement = $property->getAttribute("auto-increment") == "true";
             if ($primary) {
                 $entity->addPKProperty(new PrimaryKeyProperty($propertyName, $type, $size, $autoIncrement));
             } elseif ($type == "Object") {
                 $entity->addOneToOneProperty(new OneToOneProperty($propertyName, $entityName));
             } elseif ($type == "Collection" && !$mappingTable) {
                 $entity->addOneManyProperty(new OneToManyProperty($propertyName, $entityName));
             } elseif ($mappingTable) {
                 $entity->addManyToManyProperty(new ManyToManyProperty($propertyName, $entityName, $mappingTable));
             } else {
                 $entity->addProperty(new Property($propertyName, $type, $size));
             }
         }
         // Insert finders
         foreach ($entityEl->getChildren("finder") as $finderEl) {
             $finderName = $finderEl->getAttribute("name");
             $unique = $finderEl->getAttribute("unique");
             $cacheable = $finderEl->getAttribute("cacheable");
             $unique = $unique === "true";
             $cacheable = !($cacheable === "false");
             $finder = new Finder($entity, $finderName, $unique, $cacheable);
             foreach ($finderEl->getChildren("finder-column") as $fcEl) {
                 $name = $fcEl->getAttribute("name");
                 $comparator = $fcEl->getAttribute("comparator");
                 if (empty($comparator)) {
                     $comparator = "=";
                 }
                 $finder->addFinderColumn(new FinderColumn($name, $comparator));
             }
             $orderEls = $finderEl->getChildren("order");
             if ($orderEls->size() > 1) {
                 throw new ServiceBuilderException("Multiple order elements defined for finder {$finderName}");
             }
             if ($orderEls->size() == 1) {
                 $orderEl = $orderEls->getFirst();
                 foreach ($orderEl->getChildren("order-column") as $ocEl) {
                     $ocName = $ocEl->getAttribute("name");
                     $ocOrderBy = $ocEl->getAttribute("order-by");
                     $finder->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
                 }
             }
             $entity->addFinder($finder);
         }
         // Insert order
         $orderEls = $entityEl->getChildren("order");
         if ($orderEls->size() > 1) {
             throw new ServiceBuilderException("Multiple order elements defined for entity {$entity->getName()}");
         }
         if ($orderEls->size() == 1) {
             $orderEl = $orderEls->get(0);
             foreach ($orderEl->getChildren("order-column") as $ocEl) {
                 $ocName = $ocEl->getAttribute("name");
                 $ocOrderBy = $ocEl->getAttribute("order-by");
                 $entity->addOrderCol(new OrderColumn($ocName, $ocOrderBy));
             }
         }
         $entity->validate();
         // Add entity
         $this->entities[$entity->getName()] = $entity;
     }
 }
 protected function getAsObject($row)
 {
     $result = new BoggleHighScore();
     $result->setNew(false);
     $result->setHscoreId(Singleton::create("NullConverter")->fromDBtoDOM($row["hscoreId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     $result->setLang(Singleton::create("NullConverter")->fromDBtoDOM($row["lang"]));
     $result->setGrid(Singleton::create("NullConverter")->fromDBtoDOM($row["grid"]));
     $result->setPoints(Singleton::create("NullConverter")->fromDBtoDOM($row["points"]));
     $result->setPlayDate(Singleton::create("DateConverter")->fromDBtoDOM($row["playDate"]));
     return $result;
 }
Beispiel #26
0
 public function testSimpleXmlFactory()
 {
     $this->verifyXmlContents(Singleton::create("SimpleXmlFactory"));
 }
 private static function getService()
 {
     return Singleton::create("BoggleGameService");
 }
 private function getPersistence()
 {
     return Singleton::create("BoggleGuessedWordPersistence");
 }
Beispiel #29
0
 private static function getService()
 {
     return Singleton::create("UserService");
 }
 private function getPersistence()
 {
     return Singleton::create("BuildingPersistence");
 }