collect

@param string    $className
@param Bootstrap $objectAnnotation
@param string    $propertyName
@param string    $methodName
@param null      $propertyValue
@return void
542475
public static function collect(string $className, $objectAnnotation = null, string $propertyName = '', string $methodName = '', $propertyValue = null)
    {
        if ($objectAnnotation instanceof Bootstrap) {

            $name = $objectAnnotation->getName();
            $order = $objectAnnotation->getOrder();

            self::$bootstraps[$className]['name'] = $name;
            self::$bootstraps[$className]['order'] = $order;
        }
    }
100925
public function execute(RequestAnnotation $annotation, PropertyParserBuilder $propertyParser)
    {
        $propertyParser->addFilter(
            FilterBuilder::builder()
            ->withClass($annotation->getAssociatedClass())
            ->withSpecification($annotation->getValue())
            ->build()
        );
    }
37824
public static function initByPolymorphicOneToMany($model, $propertyName, $annotation)
    {
        $className = BeanFactory::getObjectClass($model);

        if(class_exists($annotation->model))
        {
            $modelClass = $annotation->model;
        }
        else
        {
            $modelClass = Imi::getClassNamespace($className) . '\\' . $annotation->model;
        }

        $struct = new PolymorphicOneToMany($className, $propertyName, $annotation);
        $leftField = $struct->getLeftField();
        $rightField = $struct->getRightField();

        $model->$propertyName = new ArrayList($modelClass);
        if(null !== $model->$leftField)
        {
            $list = $modelClass::query()->where($annotation->type, '=', $annotation->typeValue)->where($rightField, '=', $model->$leftField)->select()->getArray();
            if(null !== $list)
            {
                $model->$propertyName->append(...$list);
            }
        }
    }
964922
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $injectValue = $objectAnnotation->getName();
        $envValue    = $objectAnnotation->getEnv();
        if (empty($injectValue) && empty($envValue)) {
            throw new \InvalidArgumentException("the name and env of @Value can't be empty! class={$className} property={$propertyName}");
        }

        $isRef          = false;
        $injectProperty = null;
        if (!empty($injectValue)) {
            list($injectProperty, $isRef) = $this->annotationResource->getTransferProperty($injectValue);
        }

        if (!empty($envValue)) {
            $value          = $this->getEnvValue($envValue);
            $isArray        = $this->isEnvArrayValue($className, $propertyName);
            $value          = $this->getTransferEnvValue($value, $isArray);
            $injectProperty = ($value !== null) ? $value : $injectProperty;
            $isRef          = ($value !== null) ? false : $isRef;
        }

        return [$injectProperty, $isRef];
    }
1213827
public static function parseByPolymorphicOneToMany($model, $propertyName, $annotation)
    {
        $className = BeanFactory::getObjectClass($model);

        $struct = new PolymorphicOneToMany($className, $propertyName, $annotation);
        $leftField = $struct->getLeftField();
        $rightField = $struct->getRightField();
        $rightModel = $struct->getRightModel();

        $rightModel::deleteBatch(function(IQuery $query) use($model, $leftField, $rightField, $annotation){
            $query->where($annotation->type, '=', $annotation->typeValue)->where($rightField, '=', $model->$leftField);
        });
    }
699331
public static function getInjectValue($className, $propertyName)
    {
        list($annotations, $configs) = static::getInjects($className);
        if(isset($configs[$propertyName]))
        {
            return $configs[$propertyName];
        }
        else
        {
            $annotation = $annotations[0] ?? null;
            if($annotation)
            {
                return $annotation->getRealValue();
            }
            else
            {
                return null;
            }
        }
    }
1191886
protected function parseAssociation($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) {
		if ($propertyAnnotations->has('OneToOne')) {
			$association = new OneToOne($propertyName, $reflectionProperty, $propertyAnnotations);
			
			if ($association->isForeignKey()) {
				$attribute = $association->getAttribute()->getArgument();
				$this->foreignKeys[$attribute] = $propertyName;
			}
			elseif ($association->isCascade())
				$this->references[] = $propertyName;
		}
		elseif ($propertyAnnotations->has('OneToMany')) {
			$association = new OneToMany($propertyName, $reflectionProperty, $propertyAnnotations);
			
			if ($association->isCascade())
				$this->references[] = $propertyName;
		}
		elseif ($propertyAnnotations->has('ManyToOne')) {
			$association = new ManyToOne($propertyName, $reflectionProperty, $propertyAnnotations);
			$attribute = $association->getAttribute()->getArgument();
			$this->foreignKeys[$attribute] = $propertyName;
		}
		elseif ($propertyAnnotations->has('ManyToMany')) {
			$association = new ManyToMany($propertyName, $reflectionProperty, $propertyAnnotations);
			
			if ($association->isCascade())
				$this->references[] = $propertyName;
		}
		
		$this->associations[$propertyName] = $association;
	}
1268321
public function execute(RequestAnnotation $annotation, PropertyParserBuilder $propertyParser)
    {
        $propertyParser->addValidator(
            ValidatorBuilder::builder()
            ->withClass($annotation->getAssociatedClass())
            ->withSpecification($annotation->getValue())
            ->build()
        );
    }
128104
public static function collect(
        string $className,
        $objectAnnotation = null,
        string $propertyName = '',
        string $methodName = '',
        $propertyValue = null
    ) {
        if ($objectAnnotation instanceof Column) {
            self::collectColumn($objectAnnotation, $className, $propertyName, $propertyValue);
        } elseif ($objectAnnotation instanceof Entity) {
            self::collectEntity($objectAnnotation, $className);
        } elseif ($objectAnnotation instanceof Id) {
            self::collectId($className, $propertyName);
        } elseif ($objectAnnotation instanceof Required) {
            self::collectRequired($className, $propertyName);
        } elseif ($objectAnnotation instanceof Table) {
            self::collectTable($objectAnnotation, $className);
        }
    }
64481
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
        if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
                                                                       self::PROPERTY_TYPE_FLOAT,
                                                                       self::PROPERTY_TYPE_STRING,
                                                                       self::PROPERTY_TYPE_DATE,
                                                                       self::PROPERTY_TYPE_BOOLEAN)))) {
            if ($propertyValue === NULL) {
                $propertyType = self::PROPERTY_TYPE_STRING;
            } elseif (is_float($propertyValue)) {
                $propertyType = self::PROPERTY_TYPE_FLOAT;
            } elseif(is_int($propertyValue)) {
                $propertyType = self::PROPERTY_TYPE_INTEGER;
            } elseif (is_bool($propertyValue)) {
                $propertyType = self::PROPERTY_TYPE_BOOLEAN;
            } else {
                $propertyType = self::PROPERTY_TYPE_STRING;
            }
        }

        $this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
        return $this;
    }
1313489
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $beanName = $objectAnnotation->getName();
        $beanName = empty($beanName) ? $className : $beanName;
        $scope    = Scope::SINGLETON;

        DefinitionCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);

        return [$beanName, $scope, ""];
    }
104317
public static function parseByOneToOne($model, $propertyName, $annotation)
    {
        $className = BeanFactory::getObjectClass($model);

        $struct = new OneToOne($className, $propertyName, $annotation);
        $leftField = $struct->getLeftField();
        $rightField = $struct->getRightField();

        $model->$propertyName->$rightField = $model->$leftField;
        $model->$propertyName->delete();
    }
945946
private static function collectPointAnnotation(PointAnnotation $objectAnnotation, string $className)
    {
        if (!isset(self::$aspects[$className])) {
            return null;
        }

        $include = $objectAnnotation->getInclude();
        $exclude = $objectAnnotation->getExclude();

        self::$aspects[$className]['point']['annotation'] = [
            'include' => $include,
            'exclude' => $exclude,
        ];
    }
764009
private function propertyToField($propertyValue, AbstractField $annotation)
    {
        $fieldType = $annotation->type;
        switch ($fieldType) {
            case 'string':
                $fieldValue = strval($propertyValue);
                break;
            case 'bool':
                $fieldValue = boolval($propertyValue);
                break;
            case 'int':
                $fieldValue = intval($propertyValue);
                break;
            case 'float':
                $fieldValue = floatval($propertyValue);
                break;
            case 'array':
                $fieldValue = is_array($propertyValue) ? $propertyValue : (array)($propertyValue);
                break;
            case 'date':
                /** @var UTCDateTime $propertyValue */
                $fieldValue = ($propertyValue instanceof UTCDateTime) ? $propertyValue->toDateTime()->setTimezone(new \DateTimeZone(date_default_timezone_get())) : $propertyValue;
                break;
            case 'id':
                /** @var ObjectId $propertyValue */
                $fieldValue = $propertyValue;
                break;
            case 'embedOne':
                $fieldValue = $this->propertyToEmbedOne($propertyValue, $annotation);
                break;
            case 'embedMany':
                $fieldValue = $this->propertyToEmbedMany((array)$propertyValue, $annotation);
                break;
            case 'raw':
                $fieldValue = $propertyValue;
                break;
            default:
                $fieldValue = $propertyValue;
                break;
        }
        return $fieldValue;
    }
876896
public function getPropertyValue($propertyName, $objectId = null)
    {

        //You can return this protected properties as objects too.
        if (in_array($propertyName, array("objectId", "objectType", "objectURI")) && isset($this->$propertyName)) {
            return $this->$propertyName;
        }

        $property = strtolower($propertyName);
        //1. Check that the property exists in $dataModel;
        if (!array_key_exists($property, $this->propertyModel))
            return false; //@TODO Raise error? specified column not found
        //2. if isset objectId and object is this object, check value in propertyData
        if ((!empty($objectId) && (int)$objectId == $this->objectId) || empty($objectId)) {
            //IF we have a property that is not defined go get 
            if (!isset($this->propertyData[$property])) {
                //@TODO Database QUERY with objectId
                //Remember that this will most likely be used for 'un-modeled' data
                return;
            }
            //If we already have the property set and the objectId is empty
            return $this->propertyData[$property];
        }
        //3. If we have an Id and its not the same go back to the DB
        //if we have an id
        return;
    }
257135
private static function collectAround(string $className, string $methodName)
    {
        if (!isset(self::$aspects[$className])) {
            return null;
        }

        self::$aspects[$className]['advice']['around'] = [$className, $methodName];
    }
431002
private static function collectScheduled(string $className, Scheduled $objectAnnotation, string $methodName)
    {
        if (!isset(self::$tasks['mapping'][$className])) {
            return;
        }

        $cron     = $objectAnnotation->getCron();
        $taskName = self::$tasks['mapping'][$className];

        self::$tasks['crons'][] = [
            'cron'      => $cron,
            'task'      => $taskName,
            'method'    => $methodName,
            'className' => $className,
        ];
    }