From 5eab8093e781a6cb064b02899955208a2d2d230a Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 20 Dec 2014 20:40:48 +0000 Subject: [PATCH] PHPDoc and code formatting changes --- app/controllers/DashComponentController.php | 24 +++++++++++++++++++++ app/models/Component.php | 1 - app/models/Incident.php | 4 +--- app/models/Metric.php | 3 +-- app/models/Service.php | 9 ++++++++ app/models/User.php | 12 +++++++++-- app/models/WebHook.php | 5 ----- app/models/WebHookResponse.php | 4 ++++ app/routes/dashboard.php | 2 ++ app/views/dashboard/components.blade.php | 2 +- 10 files changed, 52 insertions(+), 14 deletions(-) diff --git a/app/controllers/DashComponentController.php b/app/controllers/DashComponentController.php index 2175dd89..851009da 100644 --- a/app/controllers/DashComponentController.php +++ b/app/controllers/DashComponentController.php @@ -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 diff --git a/app/models/Component.php b/app/models/Component.php index db96dc2f..aeb61da9 100644 --- a/app/models/Component.php +++ b/app/models/Component.php @@ -32,7 +32,6 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable /** * Get the transformer instance. - * * @return ComponentTransformer */ public function getTransformer() { diff --git a/app/models/Incident.php b/app/models/Incident.php index c9b2496a..9085e36d 100644 --- a/app/models/Incident.php +++ b/app/models/Incident.php @@ -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(); diff --git a/app/models/Metric.php b/app/models/Metric.php index 3c5e9eca..22e658c8 100644 --- a/app/models/Metric.php +++ b/app/models/Metric.php @@ -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(); diff --git a/app/models/Service.php b/app/models/Service.php index 41d4953d..ad057b96 100644 --- a/app/models/Service.php +++ b/app/models/Service.php @@ -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); } diff --git a/app/models/User.php b/app/models/User.php index b5da447a..596a384c 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -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 + ); } } diff --git a/app/models/WebHook.php b/app/models/WebHook.php index 242ddf58..557c755f 100644 --- a/app/models/WebHook.php +++ b/app/models/WebHook.php @@ -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 */ diff --git a/app/models/WebHookResponse.php b/app/models/WebHookResponse.php index 41910439..db7b7e70 100644 --- a/app/models/WebHookResponse.php +++ b/app/models/WebHookResponse.php @@ -1,6 +1,10 @@ belongsTo('WebHook', 'id', 'hook_id'); } diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php index 0c9ed7a3..f8b17559 100644 --- a/app/routes/dashboard.php +++ b/app/routes/dashboard.php @@ -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']); diff --git a/app/views/dashboard/components.blade.php b/app/views/dashboard/components.blade.php index 438d51a8..f4efe2a3 100644 --- a/app/views/dashboard/components.blade.php +++ b/app/views/dashboard/components.blade.php @@ -19,7 +19,7 @@