public static function setInstance($instance) { if (self::$instance != null) { throw new UnexpectedValueException('Instance has already been set.'); } self::$instance = $instance; }
function createKeyForTestItem() { $path = new Google_Service_Datastore_KeyPathElement(); $path->setKind("testkind"); $path->setName("testkeyname"); $key = DatastoreService::getInstance()->createKey(); $key->setPath([$path]); return $key; }
/** * Generate the Key for the item. * @param $item */ protected static function createKeyForItem($item) { $path = new Google_Service_Datastore_KeyPathElement(); $path->setKind($item->getKindName()); // Sanity check if ($item->key_id !== null && $item->key_name !== null) { throw new UnexpectedValueException('Only one of key_id or key_name should be set.'); } if ($item->key_id !== null) { $path->setId($item->key_id); } else { if ($item->key_name !== null) { $path->setName($item->key_name); } } $key = DatastoreService::getInstance()->createKey(); $key->setPath([$path]); return $key; }
<?php session_start(); ob_start(); //Still looking for a better yet simpler way to do redirects after outputs adn update meta tags, so I'm using ob_ things require_once 'include/config.php'; require_once 'include/EventModel.php'; require_once 'include/EventController.php'; DatastoreService::setInstance(new DatastoreService($google_api_config)); $eventController = new EventsController(); $eventController->loadHeader(); $eventController->handleRequest(); $eventController->loadFooter(); //List Events //Add Events //View Events $pageContents = ob_get_contents(); ob_end_clean(); echo $pageContents;