-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #196: Added data provider for variables.
Also adds support for drupal_write_record on DB query.
- Loading branch information
1 parent
0aaa911
commit bad9c9b
Showing
15 changed files
with
717 additions
and
165 deletions.
There are no files selected for viewing
24 changes: 0 additions & 24 deletions
24
modules/restful_example/plugins/restful/db_query/variable/1.0/RestfulQueryVariable.class.php
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
modules/restful_example/plugins/restful/db_query/variable/1.0/variable__1_0.inc
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...s/restful_example/plugins/restful/db_query/watchdog/1.0/RestfulWatchdogResource.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains RestfulEntityBase. | ||
*/ | ||
|
||
class RestFulWatchdogResource extends \RestfulDataProviderDbQuery implements \RestfulDataProviderDbQueryInterface { | ||
public function publicFieldsInfo() { | ||
|
||
$public_fields['log_id'] = array( | ||
'property' => 'wid', | ||
); | ||
|
||
$public_fields['log_type'] = array( | ||
'property' => 'type', | ||
); | ||
|
||
$public_fields['log_text'] = array( | ||
'property' => 'message', | ||
); | ||
|
||
$public_fields['log_variables'] = array( | ||
'property' => 'variables', | ||
); | ||
|
||
$public_fields['log_level'] = array( | ||
'property' => 'severity', | ||
); | ||
|
||
$public_fields['log_path'] = array( | ||
'property' => 'location', | ||
); | ||
|
||
return $public_fields; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function access() { | ||
$account = $this->getAccount(); | ||
return user_access('view site reports', $account); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
modules/restful_example/plugins/restful/db_query/watchdog/1.0/watchdog.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
$plugin = array( | ||
'label' => t('Watchdog entries'), | ||
'resource' => 'watchdog', | ||
'name' => 'watchdog', | ||
'data_provider_options' => array( | ||
'table_name' => 'watchdog', | ||
'id_column' => 'wid', | ||
), | ||
'description' => t('Expose watchdog entries to the REST API.'), | ||
'class' => 'RestfulWatchdogResource', | ||
'authentication_types' => TRUE, | ||
); |
32 changes: 32 additions & 0 deletions
32
modules/restful_example/plugins/restful/variable/1.0/RestfulVariableResource.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \RestfulQueryVariable | ||
*/ | ||
|
||
class RestfulVariableResource extends \RestfulDataProviderVariable { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function publicFieldsInfo() { | ||
return array( | ||
'variable_name' => array( | ||
'property' => 'name', | ||
), | ||
'variable_value' => array( | ||
'property' => 'value', | ||
), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function access() { | ||
$account = $this->getAccount(); | ||
return user_access('adminsiter site configuration', $account); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
modules/restful_example/plugins/restful/variable/1.0/variable__1_0.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
$plugin = array( | ||
'label' => t('Variable'), | ||
'description' => t('Expose site variables to the REST API.'), | ||
'resource' => 'variables', | ||
'class' => 'RestfulVariableResource', | ||
'authentication_types' => TRUE, | ||
'render_cache' => array( | ||
'render' => TRUE, | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.