vendor/codeages/biz-framework/src/Dao/Annotation/MetadataReader.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Codeages\Biz\Framework\Dao\Annotation;

use Doctrine\Common\Annotations\AnnotationReader;
use Symfony\Component\Filesystem\Filesystem;

class MetadataReader
{
    private $cacheDirectory;

    public function __construct($cacheDirectory = null)
    {
        $this->cacheDirectory = $cacheDirectory;
    }

    public function read($dao)
    {
        $cache = $this->readCache($dao);
        if ($cache) {
            return $cache;
        }

        $reader = new AnnotationReader();
        $classRef = new \ReflectionClass($dao);
        $isDao = $classRef->implementsInterface('Codeages\Biz\Framework\Dao\DaoInterface');
        if (!$isDao) {
            return null;
        }

        $annotation = $reader->getClassAnnotation($classRef, 'Codeages\Biz\Framework\Dao\Annotation\CacheStrategy');
        if (empty($annotation)) {
            return null;
        }

        $metadata = array(
            'strategy' => $annotation->getName(),
            'cache_key_of_field_name' => array(),
            'cache_key_of_arg_index' => array(),
            'update_rel_query_methods' => array(),
        );

        $methodRefs = $classRef->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($methodRefs as $methodRef) {
            $annotation = $reader->getMethodAnnotation($methodRef, 'Codeages\Biz\Framework\Dao\Annotation\RowCache');
            if (empty($annotation)) {
                continue;
            }

            $args = $this->getMethodArgumentNames($methodRef);
            if (empty($annotation->relFields)) {
                $annotation->relFields = $args;
            }

            $metadata['cache_key_of_field_name'][$methodRef->getName()] = $annotation->relFields;

            $args = array_flip($args);
            foreach ($annotation->relFields as $field) {
                if (empty($metadata['cache_key_of_arg_index'][$methodRef->getName()])) {
                    $metadata['cache_key_of_arg_index'][$methodRef->getName()] = array();

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。