Refactor ArticleControler to ArticleController

Fix some typos
This commit is contained in:
PJ Dietz 2012-12-24 08:42:44 -05:00
parent c788c9ee70
commit 471abda822
5 changed files with 46 additions and 17 deletions

View File

@ -5,7 +5,7 @@ namespace apisample;
/**
* Simple class for reading and writing articles to a text file.
*/
class ArticlesControler {
class ArticlesController {
public $data;
protected $path;

View File

@ -1,13 +1,41 @@
The apisample directory contains a mini API project that demonstrates all of the
The apisample directory contains a mini API project that demonstrates the
main features of Well RESTEd.
Resources
---------
For this sample project, the only resources
are "articles", which are kind of like little mini blog posts or news feed
items. Each article contains the following fields:
articleId: Numeric unique identifier for the article
slug: A human readable unique identifier for the article
title: Text title describing the article
excerpt: A short portion of the article's content
In JSON, an article resource looks like this:
{
"articleId": 1,
"slug": "good-movie",
"title": "Reports Of Movie Being Good Reach Area Man",
"excerpt": "Local resident Daniel Paxson has reportedly heard dozens of accounts from numerous friendly sources in the past two weeks confirming that the new James Bond film is pretty good. According to persons with knowledge of the situation, an unnamed friend of Paxsons coworker Wendy Mathers watched the movie on opening weekend and found it to be “decent enough.”"
}
URIs
----
The API exposes both the collection of articles and each article individually.
/articles/
Represents a list of articles.
Represents the collection of articles.
GET
Displays a list of articles
Display the full list of articles.
POST
Add a new article
Add a new article. Provide the new article in JSON format as the
request body.
PUT
Not allowed
DELETE
@ -16,13 +44,14 @@ main features of Well RESTEd.
/articles/{id}
/articles/{slug}
Represents one specific article identified by the numberic ID {id} or by the
alpha-numeric slug.
alpha-numeric slug {slug}.
GET
Displays one specific article
Display one specific article.
POST
Not allowed
PUT
Replace the article with the given contents
Replace the article with the new article. Provide the new article in
JSON format as the request body.
DELETE
Remove the article
Remove the article.

View File

@ -3,7 +3,7 @@
namespace apisample\handlers;
require_once(dirname(__FILE__) . '/../../../Handler.inc.php');
require_once(dirname(__FILE__) . '/../ArticlesControler.inc.php');
require_once(dirname(__FILE__) . '/../ArticlesController.inc.php');
/**
* Handler class for a list of articles.
@ -16,7 +16,7 @@ class ArticleCollectionHandler extends \wellrested\Handler {
protected function get() {
// Display the list of articles.
$articles = new \apisample\ArticlesControler();
$articles = new \apisample\ArticlesController();
if (isset($articles->data)) {
@ -73,7 +73,7 @@ class ArticleCollectionHandler extends \wellrested\Handler {
}
// Ensure slug is not a duplicate.
$articles = new \apisample\ArticlesControler();
$articles = new \apisample\ArticlesController();
if ($articles->getArticleBySlug($article['slug']) !== false) {
$this->response->statusCode = 409;
$this->response->setHeader('Content-type', 'text/plain');

View File

@ -3,7 +3,7 @@
namespace apisample\handlers;
require_once(dirname(__FILE__) . '/../../../Handler.inc.php');
require_once(dirname(__FILE__) . '/../ArticlesControler.inc.php');
require_once(dirname(__FILE__) . '/../ArticlesController.inc.php');
/**
* Handler class for one specific article.
@ -19,7 +19,7 @@ class ArticleItemHandler extends \wellrested\Handler {
protected function get() {
// Read the list of articles.
$articles = new \apisample\ArticlesControler();
$articles = new \apisample\ArticlesController();
$article = false;
@ -89,7 +89,7 @@ class ArticleItemHandler extends \wellrested\Handler {
}
// Read the list of articles.
$articles = new \apisample\ArticlesControler();
$articles = new \apisample\ArticlesController();
$oldArticle = false;
@ -159,7 +159,7 @@ class ArticleItemHandler extends \wellrested\Handler {
protected function delete() {
// Read the list of articles.
$articles = new \apisample\ArticlesControler();
$articles = new \apisample\ArticlesController();
$article = false;

View File

@ -13,7 +13,7 @@ $rqst->uri = 'https://www.google.com/search?q=my+search+terms';
// You could also set the members individually, like this:
//$rqst->protocol = 'https';
//$rqst->hostname = ['www.google.com';
//$rqst->hostname = 'www.google.com';
//$rqst->path = '/search';
//$rqst->query = array('q' => 'my search terms');