[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Generate @{class:DivinerAtom}s from source code. 5 */ 6 abstract class DivinerAtomizer { 7 8 private $book; 9 private $fileName; 10 private $atomContext; 11 12 /** 13 * If you make a significant change to an atomizer, you can bump this 14 * version to drop all the old atom caches. 15 */ 16 public static function getAtomizerVersion() { 17 return 1; 18 } 19 20 final public function atomize($file_name, $file_data, array $context) { 21 $this->fileName = $file_name; 22 $this->atomContext = $context; 23 $atoms = $this->executeAtomize($file_name, $file_data); 24 25 // Promote the "@group" special to a property. If there's no "@group" on 26 // an atom but the file it's in matches a group pattern, associate it with 27 // the right group. 28 foreach ($atoms as $atom) { 29 $group = null; 30 try { 31 $group = $atom->getDocblockMetaValue('group'); 32 } catch (Exception $ex) { 33 // There's no docblock metadata. 34 } 35 36 // If there's no group, but the file matches a group, use that group. 37 if ($group === null && isset($context['group'])) { 38 $group = $context['group']; 39 } 40 41 if ($group !== null) { 42 $atom->setProperty('group', $group); 43 } 44 } 45 46 return $atoms; 47 } 48 49 abstract protected function executeAtomize($file_name, $file_data); 50 51 final public function setBook($book) { 52 $this->book = $book; 53 return $this; 54 } 55 56 final public function getBook() { 57 return $this->book; 58 } 59 60 protected function newAtom($type) { 61 return id(new DivinerAtom()) 62 ->setBook($this->getBook()) 63 ->setFile($this->fileName) 64 ->setType($type); 65 } 66 67 protected function newRef($type, $name, $book = null, $context = null) { 68 $book = coalesce($book, $this->getBook()); 69 70 return id(new DivinerAtomRef()) 71 ->setBook($book) 72 ->setContext($context) 73 ->setType($type) 74 ->setName($name); 75 } 76 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |