1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace Drupal\janrain_views;
- class EntityType {
- /**
- *
- * @var Api
- */
- public static $api;
- public static function bind(Api $api) {
- static::$api = $api;
- }
- /**
- * Janrain entityType/list
- *
- * Cannot use the "list" name as it is a PHP keyword.
- */
- public static function getList() {
- $api = static::$api;
- $ret = $api('entityType.list');
- return $ret;
- }
- public static function getEntityType($type_name = 'user') {
- $api = static::$api;
- $result = $api('entityType', array('type_name' => $type_name));
- if ($result['stat'] == 'ok') {
- $name = $result['schema']['name'];
- $rows = array();
- foreach ($result['schema']['attr_defs'] as $typeInfo) {
- $row = array();
- $row['name'] = $typeInfo['name'];
- $row['type'] = $typeInfo['type'];
- $row['description'] = isset($typeInfo['description']) ? $typeInfo['description'] : NULL;
- unset($typeInfo['name'], $typeInfo['type'], $typeInfo['description']);
- $items = array();
- foreach ($typeInfo as $k => $v) {
- $items[] = t('@k: @v', array('@k' => $k, '@v' => print_r($v, TRUE)));
- }
- $row['other'] = theme('item_list', array('items' => $items));
- $rows[] = $row;
- }
- $header = array(
- t('Name'),
- t('Type'),
- t('Description'),
- t('Other'),
- );
- $ret = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- );
- }
- else {
- $ret = t('Operation did not succeed.');
- }
- return $ret;
- }
- public static function getAccessSchema($type_name = 'user', $client_id = NULL) {
- $api = static::$api;
- if (empty($client_id)) {
- $client_id = $api->clientId;
- }
- $read = $api('entityType.getAccessSchema', array(
- 'type_name' => $type_name,
- 'for_client_id' => $client_id,
- 'access_type' => 'read',
- ));
- dsm($read);
- $write = $api('entityType.getAccessSchema', array(
- 'type_name' => $type_name,
- 'for_client_id' => $client_id,
- 'access_type' => 'read',
- ));
- dsm($write);
- }
- }
|