2016-01-11 13:49:12 +01:00
|
|
|
// #docregion
|
2016-05-03 14:06:32 +02:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
import { HEROES } from './mock-heroes';
|
|
|
|
import { Logger } from '../logger.service';
|
2016-01-11 13:49:12 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HeroService {
|
|
|
|
// #docregion internals
|
|
|
|
constructor(
|
2016-05-03 14:06:32 +02:00
|
|
|
private logger: Logger,
|
|
|
|
private isAuthorized: boolean) { }
|
2016-01-11 13:49:12 +01:00
|
|
|
|
|
|
|
getHeroes() {
|
2016-06-08 01:06:25 +02:00
|
|
|
let auth = this.isAuthorized ? 'authorized ' : 'unauthorized';
|
2016-05-03 14:06:32 +02:00
|
|
|
this.logger.log(`Getting heroes for ${auth} user.`);
|
|
|
|
return HEROES.filter(hero => this.isAuthorized || !hero.isSecret);
|
2016-01-11 13:49:12 +01:00
|
|
|
}
|
|
|
|
// #enddocregion internals
|
|
|
|
}
|