/** * @return string[] * @throws PersistException * */ public function getClassDoc() { $comments = parent::getClassDoc(); $pattern = '/(?<pname>\\w+)="(?P<pval>[^"]+)"/'; $message = sprintf(self::ANNONTATION_COMMENT_NOT_FOUND, $this->_reflection->getName()); PersistException::throwsExceptionIfParamIsNull(trim($comments), $message); $result = array(); preg_match_all(self::ANNONTATION_ER_DEF_ENTITY_AND_SCHEMA, $comments, $result); $classDef = next($result); $comments = array(); # identificador da definicao # @ident(...) foreach ($classDef as $key => $ident) { # recupera os valores definidos em cada propriedade # @...(name="value") preg_match_all($pattern, $result[0][$key], $resAnnon); if (1 < count($resAnnon['pname'])) { $attrs = array(); foreach ($resAnnon['pval'] as $idx => $val) { $attrs[$resAnnon['pname'][$idx]] = $val; } $comments[$ident][] = $attrs; } else { $comments[$ident] = $resAnnon['pval'][0]; } } return $comments; }
/** * Monta o conteudo do arquivo de cache * * @param Annotation $annon * @return string * */ public function encodeAnnotation(Annotation $annon) { $content = array('class' => self::NAMESPACE_SEPARATOR . $annon->getClassName()); $tmpEntity = $annon->getClassDoc(); $content['attrs'] = $annon->getAttrsDoc(); foreach ($tmpEntity as $key => $value) { $content[$key] = $value; } return json_encode($content); }