예제 #1
0
 public function testGetLastRecipient()
 {
     $state = $this->prophesize(StateInterface::class);
     $state->get('hugs.last_recipient')->willReturn('Dries');
     $tracker = new HugTracker($state->reveal());
     $this->assertEquals('Dries', $tracker->getLastRecipient());
 }
예제 #2
0
 public function hug($to, $from, $count)
 {
     $this->hugTracker->addHug($to);
     if (!$count) {
         $count = $this->config('hugs.settings')->get('default_count');
     }
     return ['#theme' => 'hug_page', '#from' => $from, '#to' => $to, '#count' => $count];
 }
예제 #3
0
 public function build()
 {
     if ($this->configuration['enabled']) {
         $message = $this->t('@to was the last person hugged', ['@to' => $this->hugTracker->getLastRecipient()]);
     } else {
         $message = $this->t('No hugs :-(');
     }
     return ['#markup' => $message];
 }
 public function hug($to, $from, $count)
 {
     // implement the hug tracker
     $this->hugTracker->addHug($to);
     // check for default count and return the hug page
     if (!$count) {
         $count = $this->config('hugs.settings')->get('default_count');
     }
     // build the return array
     $return = ['#theme' => 'hug_page', '#from' => $from, '#to' => $to, '#count' => $count];
     return $return;
 }