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"; }
public function __construct() { $this->db = Singleton::create("DatabaseManager"); if (is_null(self::$dbCache)) { self::$dbCache = BeanLocator::get("DatabaseCache"); } }
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; }
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; }
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; }
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"; }
private function getConverter() { $t = is_null($this->type) ? "Null" : $this->type; return Singleton::create("Domain{$t}Converter"); }
private function getPersistence() { return Singleton::create("TeamPersistence"); }
private static function getService() { return Singleton::create("BubbleHighScoreService"); }
private function getPersistence() { return Singleton::create("BogglePlayerPersistence"); }
<?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);
<?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";
public function __construct() { $this->xmlFactory = Singleton::create("DOMXmlFactory"); $this->settings = Singleton::create("Settings"); }
public function __construct() { $this->defaultUrl = Singleton::create("Settings")->getDefaultUrl(); }
public function __construct() { $this->enabled = Singleton::create("Settings")->isDbCacheEnabled(); }
private function getPersistence() { return Singleton::create("BoggleHighScorePersistence"); }
private function getPersistence() { return Singleton::create("AddressPersistence"); }
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; }
public function testSimpleXmlFactory() { $this->verifyXmlContents(Singleton::create("SimpleXmlFactory")); }
private static function getService() { return Singleton::create("BoggleGameService"); }
private function getPersistence() { return Singleton::create("BoggleGuessedWordPersistence"); }
private static function getService() { return Singleton::create("UserService"); }
private function getPersistence() { return Singleton::create("BuildingPersistence"); }