Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
View
4 Controller/BanchaController.php
@@ -81,7 +81,8 @@ public function index($metadataFilter='') {
'metadata' => $this->getMetadata($banchaApi,$remotableModels, $metadataFilter),
'actions' => $actions
);
-
+
+ // no extra view file needed, simply output
$this->response->body(sprintf("Ext.ns('Bancha');\n%s=%s", Configure::read('Bancha.Api.remoteApiNamespace'), json_encode($api)));
}
@@ -145,4 +146,5 @@ private function getMetaData($banchaApi, $remotableModels, $metadataFilter) {
return $metadata;
}
+
}
View
14 Lib/Bancha/BanchaApi.php
@@ -49,7 +49,8 @@ public function getRemotableModels()
foreach ($models as $modelClass) {
$model = $this->loadModel($modelClass);
if (isset($model->actsAs) && is_array($model->actsAs)) {
- if (in_array('Bancha.BanchaRemotable', $model->actsAs)) {
+ // check if it is remotable (first when a AppModel behavior is also defined, second when not)
+ if (array_key_exists('Bancha.BanchaRemotable', $model->actsAs) || in_array('Bancha.BanchaRemotable', $model->actsAs)) {
$remotableModels[] = $modelClass;
}
}
@@ -140,19 +141,19 @@ public function getControllerClassByModelClass($modelClass) {
public function getCrudActionsOfController($controllerClass) {
$methods = $this->getClassMethods($controllerClass);
- $formHandler = false;
+ $addFormHandler = false;
$crudActions = array();
foreach ($methods as $method) {
if ('add' === $method->name || 'edit' == $method->name) {
- $formHandler = true;
+ $addFormHandler = true;
}
if (isset($this->crudMapping[$method->name])) {
$crudActions[] = $this->crudMapping[$method->name];
}
}
- // If this controller has a form handler, add it to the crud actions.
- if ($formHandler) {
+ // If this controller supports a form handler submit, add it to the crud actions.
+ if ($addFormHandler) {
$crudActions[] = array(
'name' => 'submit',
'len' => 1,
@@ -240,8 +241,7 @@ protected function loadController($controllerClass) {
protected function getClassMethods($class) {
$reflection = new ReflectionClass($class);
- return $reflection->getMethods();
+ return $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
}
-
}
View
2  Test/Case/BanchaApiTest.php
@@ -8,6 +8,7 @@
* @copyright Copyright 2011-2012 Roland Schuetz, Kung Wong, Andreas Kern, Florian Eckerstorfer
* @link http://banchaproject.org Bancha Project
* @since Bancha v 0.9.0
+ * @author Roland Schuetz <mail@rolandschuetz.at>
* @author Florian Eckerstorfer <f.eckerstorfer@gmail.com>
*/
@@ -149,7 +150,6 @@ public function testGetRemotableModelActions()
$this->assertCount(6, $remotableActions['Article']);
$this->assertEquals('getAll', $remotableActions['Article'][0]['name']);
}
-
}

No commit comments for this range

Something went wrong with that request. Please try again.