PHPDoc and code formatting changes

This commit is contained in:
James Brooks
2014-12-20 20:40:48 +00:00
parent 3790ae240e
commit 5eab8093e7
10 changed files with 52 additions and 14 deletions

View File

@@ -14,6 +14,30 @@ class DashComponentController extends Controller {
]);
}
/**
* Shows the edit component view.
* @param Component $component
* @return \Illuminate\View\View
*/
public function showEditComponent(Component $component) {
return View::make('dashboard.component-edit')->with([
'pageTitle' => 'Editing "' . $component->name . '" Component - Dashboard',
'component' => $component
]);
}
/**
* Updates a component.
* @return \Illuminate\Http\RedirectResponse
*/
public function updateComponentAction(Component $component) {
$_component = Input::get('component');
$component->update($_component);
return Redirect::back()->with('savedComponent', $component);
}
/**
* Shows the add component view.
* @return \Illuminate\View\View

View File

@@ -32,7 +32,6 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
/**
* Get the transformer instance.
*
* @return ComponentTransformer
*/
public function getTransformer() {

View File

@@ -3,7 +3,6 @@
use Watson\Validating\ValidatingTrait;
class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
use ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
@@ -51,8 +50,7 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
/**
* Get the transformer instance.
*
* @return IncidentTransformer
* @return CachetHQ\Cachet\Transformers\IncidentTransformer
*/
public function getTransformer() {
return new CachetHQ\Cachet\Transformers\IncidentTransformer();

View File

@@ -31,8 +31,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/**
* Get the transformer instance.
*
* @return MetricTransformer
* @return CachetHQ\Cachet\Transformers\MetricTransformer
*/
public function getTransformer() {
return new CachetHQ\Cachet\Transformers\MetricTransformer();

View File

@@ -11,10 +11,19 @@ class Service extends Eloquent {
'properties' => ''
];
/**
* Returns a decoded properties object for the service.
* @param string $properties
* @return object
*/
public function getPropertiesAttribute($properties) {
return json_decode($properties);
}
/**
* Sets the properties attribute which auto encodes to a JSON string.
* @param mixed $properties
*/
public function setPropertiesAttribute($properties) {
$this->attributes['properties'] = json_encode($properties);
}

View File

@@ -6,7 +6,6 @@ use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
/**
@@ -37,8 +36,17 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
$this->attributes['password'] = Hash::make($password);
}
/**
* Returns a Gravatar URL for the users email address.
* @param integer $size
* @return string
*/
public function getGravatarAttribute($size = 200) {
return 'https://www.gravatar.com/avatar/' . md5($this->email) . '?size=' . $size;
return sprintf(
'https://www.gravatar.com/avatar/%s?size=%d',
md5($this->email),
$size
);
}
}

View File

@@ -11,7 +11,6 @@ class WebHook extends Eloquent {
/**
* Returns all responses for a WebHook.
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function response() {
@@ -20,7 +19,6 @@ class WebHook extends Eloquent {
/**
* Returns all active hooks.
*
* @param Illuminate\Database\Eloquent\Builder $query
* @return Illuminate\Database\Eloquent\Builder
*/
@@ -30,7 +28,6 @@ class WebHook extends Eloquent {
/**
* Setups a Ping event that is fired upon a web hook.
*
* @return array result of the ping
*/
public function ping() {
@@ -39,7 +36,6 @@ class WebHook extends Eloquent {
/**
* Fires the actual web hook event.
*
* @param string $eventType the event to send X-Cachet-Event
* @param mixed $data Data to send to the Web Hook
* @return object
@@ -80,7 +76,6 @@ class WebHook extends Eloquent {
/**
* Returns a human readable request type name.
*
* @throws Exception
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc
*/

View File

@@ -1,6 +1,10 @@
<?php
class WebHookResponse extends Eloquent {
/**
* Returns the hook that a response belongs to.
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function hook() {
return $this->belongsTo('WebHook', 'id', 'hook_id');
}

View File

@@ -9,6 +9,8 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
Route::get('components/add', ['as' => 'dashboard.components.add', 'uses' => 'DashComponentController@showAddComponent']);
Route::post('components/add', 'DashComponentController@createComponentAction');
Route::get('components/{component}/delete', 'DashComponentController@deleteComponentAction');
Route::get('components/{component}/edit', 'DashComponentController@showEditComponent');
Route::post('components/{component}/edit', 'DashComponentController@updateComponentAction');
// Incidents
Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashIncidentController@showIncidents']);

View File

@@ -19,7 +19,7 @@
</div>
<div class='col-md-6'>
<ul class='nav nav-pills'>
<li role='presentation'><a href='javascript: void(0);'>Edit</a></li>
<li role='presentation'><a href='/dashboard/components/{{ $component->id }}/edit'>Edit</a></li>
<li role='presentation'><a href='/dashboard/components/{{ $component->id }}/delete'>Delete</a></li>
</ul>
</div>