Moved transformers to namespaced directory

This commit is contained in:
Elliot Hesp 2014-11-27 19:18:01 +00:00
parent 15b43dc9a9
commit 4804eb90f8
8 changed files with 29 additions and 8 deletions

View File

@ -1,6 +1,12 @@
<?php <?php
class ComponentTransformer extends \League\Fractal\TransformerAbstract { namespace CachetHQ\Cachet\Transformers;
use Component;
use League\Fractal\TransformerAbstract;
class ComponentTransformer extends TransformerAbstract {
public function transform(Component $component) { public function transform(Component $component) {
return [ return [
'id' => (int) $component->id, 'id' => (int) $component->id,
@ -13,4 +19,5 @@ class ComponentTransformer extends \League\Fractal\TransformerAbstract {
'updated_at' => $component->updated_at->timestamp, 'updated_at' => $component->updated_at->timestamp,
]; ];
} }
} }

View File

@ -1,7 +1,14 @@
<?php <?php
class IncidentTransformer extends \League\Fractal\TransformerAbstract { namespace CachetHQ\Cachet\Transformers;
use Incident;
use League\Fractal\TransformerAbstract;
class IncidentTransformer extends TransformerAbstract {
public function transform(Incident $incident) { public function transform(Incident $incident) {
$component = $incident->parent; $component = $incident->parent;
$transformer = $component->getTransformer(); $transformer = $component->getTransformer();

View File

@ -1,6 +1,12 @@
<?php <?php
class MetricTransformer extends \League\Fractal\TransformerAbstract { namespace CachetHQ\Cachet\Transformers;
use Metric;
use League\Fractal\TransformerAbstract;
class MetricTransformer extends ransformerAbstract {
public function transform(Metric $metric) { public function transform(Metric $metric) {
return [ return [
'id' => (int) $metric->id, 'id' => (int) $metric->id,
@ -12,4 +18,5 @@ class MetricTransformer extends \League\Fractal\TransformerAbstract {
'updated_at' => $metric->updated_at->timestamp, 'updated_at' => $metric->updated_at->timestamp,
]; ];
} }
} }

View File

@ -35,6 +35,6 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
* @return ComponentTransformer * @return ComponentTransformer
*/ */
public function getTransformer() { public function getTransformer() {
return new ComponentTransformer(); return new CachetHQ\Cachet\Transformers\ComponentTransformer();
} }
} }

View File

@ -3,6 +3,7 @@
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface { class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
use ValidatingTrait; use ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait; use Illuminate\Database\Eloquent\SoftDeletingTrait;
@ -54,6 +55,6 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
* @return IncidentTransformer * @return IncidentTransformer
*/ */
public function getTransformer() { public function getTransformer() {
return new IncidentTransformer(); return new CachetHQ\Cachet\Transformers\IncidentTransformer();
} }
} }

View File

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

View File

@ -19,7 +19,6 @@
"app/commands", "app/commands",
"app/controllers", "app/controllers",
"app/models", "app/models",
"app/transformers",
"app/database/migrations", "app/database/migrations",
"app/database/seeds", "app/database/seeds",
"app/tests/TestCase.php", "app/tests/TestCase.php",

0
package.json Normal file
View File