{ DrupalCorn 2014 }
Ryan Frahm | rlfrahm
July 18th 2014
A model-view-controller for Javascript?
module.cookie:
path: '/api/v1/cookies/{kind}'
defaults:
_controller: '\Drupal\api_module\Controller\ModuleController::getCookiesOfKind'
requirements:
_permission: 'access content'
...
class ModuleController implements ContainerInjectionInterface {
...constructor
public function getCookiesOfKind($kind) {
return $cookies[$kind];
}
}
- Drupal
- ...
- App
- ...
- Drupal
- App
- ...
- core
- modules
- themes
- ...
- Drupal
- modules
- App
- ...
- ...
- ...
if ($modules['restui']->installed == TRUE) {
} else {
}
resources:
entity:node:
GET:
supported_formats:
- hal_json
supported_auth:
- basic_auth
POST:
supported_formats:
- hal_json
supported_auth:
- basic_auth
PATCH:
supported_formats:
- hal_json
supported_auth:
- basic_auth
DELETE:
supported_formats:
- hal_json
supported_auth:
- basic_auth
{"nid":[{"value":"1"}],"uuid":[{"value":"06dbb9be-033d-4b29-bd00-bb6ccbfcac54"}],"vid":[{"value":"1"}],"type":[{"target_id":"item"}],"langcode":[{"value":"en"}],"title":[{"value":"Laptop"}],"uid":[{"target_id":"1"}],"status":[{"value":"1"}],"created":[{"value":"1405707194"}],"changed":[{"value":"1405707194"}],"promote":[{"value":"1"}],"sticky":[{"value":"0"}],"revision_timestamp":[{"value":"1405707194"}],"revision_uid":[{"target_id":"1"}],"revision_log":[{"value":""}],"body":[{"value":null,"format":null,"summary":null}]}
$http.get('http://drupalangular.com/getCookiesOfKind/chocolate').success(function(result) {
$log.log(result);
});
// Set view 1 to filter by chocolate kinds
$http.get('http://drupalangular.com/view/1').success(function(result) {
$log.log(result);
});