1 <?php
2
3 namespace Skimia\Foundation\Annotations;
4
5 use Illuminate\Contracts\Foundation\Application;
6 use Collective\Annotations\AnnotationScanner as BaseScanner;
7
8 abstract class Scanner extends BaseScanner
9 {
10 11 12
13 protected $app;
14
15 16 17
18 public function __construct(Application $app, array $scan)
19 {
20 $this->app = $app;
21
22
23 parent::__construct($scan);
24 }
25
26 27 28 29
30 abstract public function getScannedAnnotationPath();
31
32 public function annotationsAreScanned()
33 {
34 return $this->app['files']->exists($this->getScannedAnnotationPath());
35 }
36
37 38 39
40 public function loadScannedAnnotations()
41 {
42 if ($this->annotationsAreScanned()) {
43 require $this->getScannedAnnotationPath();
44
45 return true;
46 }
47
48 return false;
49 }
50
51 52 53
54 public function scan()
55 {
56 $filename = $this->getScannedAnnotationPath();
57 file_put_contents(
58 $filename, '<?php '.$this->getAnnotationsDefinitions()
59 );
60 chmod($filename, fileperms($filename) | 128 + 16 + 2);
61 }
62
63 abstract public function getAnnotationsDefinitions();
64 }
65