Replace "thread.php" with a controller

This commit is contained in:
Dmitriy Simushev 2014-06-03 10:10:20 +00:00
parent 5244480d4c
commit 7b6604fba2
4 changed files with 51 additions and 22 deletions

View File

@ -0,0 +1,46 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Mibew\Controller\Chat;
use Mibew\RequestProcessor\ThreadProcessor;
use Mibew\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
/**
* Contains actions which are related with thread itself.
*/
class ThreadController extends AbstractController
{
/**
* Update threads state.
*
* @param Request $request Incoming request.
* @return A set of data to update the thread at client side.
*/
public function updateAction(Request $request)
{
$processor = ThreadProcessor::getInstance();
// TODO: Remove bufferization after *Processor classes will be rewritten
// to play nice with symfony request/response objects
ob_start();
$processor->receiveRequest($request->request->get('data'));
$content = ob_get_clean();
return $content;
}
}

View File

@ -1,4 +1,8 @@
# Chat actions
chat_thread_update:
path: /thread/update
defaults:
_controller: Mibew\Controller\Chat\ThreadController::updateAction
## Operator's chat
chat_operator:

View File

@ -77,7 +77,7 @@
jQuery(document).ready(function(){
Mibew.Application.start({
server: {
url: '{{mibewRoot}}/thread.php',
url: '{{mibewRoot}}/thread/update',
requestsFrequency: {{frequency}}
},
page: {

View File

@ -1,21 +0,0 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once(dirname(__FILE__) . '/libs/init.php');
$processor = \Mibew\RequestProcessor\ThreadProcessor::getInstance();
$processor->receiveRequest($_POST['data']);