Skip to content

Commit

Permalink
Library optimizations looking good.
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Nov 13, 2008
1 parent f868764 commit bce1fc1
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
10 changes: 10 additions & 0 deletions apps/blog/controllers/PostsController.class.php
Expand Up @@ -42,6 +42,16 @@ function newComment($postId) {

}

/** !Route GET, comment/$commentId/delete/ */
function deleteComment($commentId) {
$comment = new Comment();
$comment->id = $commentId;
$post = $comment->post();
$comment->delete();
Library::import('recess.http.ForwardingResponse');
return $this->forwardOk('/blog/comments/' . $post->id);
}

}

?>
2 changes: 1 addition & 1 deletion apps/blog/views/home/comments.php
Expand Up @@ -12,7 +12,7 @@

foreach($comments as $comment) {

echo '<p>' . $comment->comment . '</p>';
echo '<p><a href="/blog/comment/' . $comment->id . '/delete/">X</a> ' . $comment->comment . '</p>';

echo '<hr />';

Expand Down
5 changes: 5 additions & 0 deletions lib/recess/framework/controllers/Controller.class.php
Expand Up @@ -152,6 +152,11 @@ protected function ok($viewName = null) {
return $response;
}

protected function forwardOk($forwardedUri) {
Library::import('recess.http.responses.ForwardingOkResponse');
return new ForwardingOkResponse($this->request, $forwardedUri);
}

protected function created($resourceUri, $contentUri = '') {
Library::import('recess.http.responses.CreatedResponse');
if($contentUri == '') $contentUri = $resourceUri;
Expand Down
2 changes: 0 additions & 2 deletions lib/recess/http/Response.class.php
@@ -1,5 +1,4 @@
<?php

Library::import('recess.http.Request');
Library::import('recess.http.Cookie');

Expand Down Expand Up @@ -31,5 +30,4 @@ protected function addHeader($header) {
$this->headers[] = $header;
}
}

?>
1 change: 0 additions & 1 deletion lib/recess/http/responses/ForbiddenResponse.class.php
@@ -1,5 +1,4 @@
<?php

Library::import('recess.http.responses.ErrorResponse');
Library::import('recess.http.ResponseCodes');

Expand Down
10 changes: 10 additions & 0 deletions lib/recess/http/responses/ForwardingOkResponse.class.php
@@ -0,0 +1,10 @@
<?php
Library::import('recess.http.ForwardingResponse');
Library::import('recess.http.ResponseCodes');

class ForwardingOkResponse extends ForwardingResponse {
public function __construct(Request $request, $contentUri) {
parent::__construct($request, ResponseCodes::HTTP_OK, $contentUri);
}
}
?>
8 changes: 5 additions & 3 deletions public/recess-config.php
Expand Up @@ -4,7 +4,7 @@

Config::$mode = Config::DEVELOPMENT;

Config::$useTurboSpeed = true; // Do you want to go fast?
Config::$useTurboSpeed = false; // I wanna go FAST!

Config::$cacheProviders
= array( 'Apc',
Expand All @@ -13,8 +13,8 @@
);

Config::$applications
= array( // 'frontend.FrontEndApplication',
// 'backend.BackEndApplication',
= array( 'frontend.FrontEndApplication',
'backend.BackEndApplication',
'recess.apps.ide.RecessIdeApplication',
'blog.BlogApplication'
);
Expand Down Expand Up @@ -71,6 +71,7 @@ static function init() {
$provider = $provider . 'CacheProvider';
Cache::reportsTo(new $provider);
}
Cache::clear();
}

if(isset(self::$settings['dir.temp'])) {
Expand All @@ -97,6 +98,7 @@ static function init() {
Library::addClassPath(self::$settings['dir.apps']);

// TODO: GET RID OF THIS
Library::import('recess.framework.Application');
self::$applications = array_map(create_function('$class','return Library::importAndInstantiate($class);'),Config::$applications);

Library::import('recess.sources.db.DbSources');
Expand Down

0 comments on commit bce1fc1

Please sign in to comment.