Get the widget instance.

@param string $fieldName     The property name.
@param string $serializedId  The serialized id of the model.
@param string $propertyValue The property value.

@return Widget
6291
protected function getWidget($fieldName, $serializedId, $propertyValue)
    {
        $environment    = $this->getEnvironment();
        $property       = $environment->getDataDefinition()->getPropertiesDefinition()->getProperty($fieldName);
        $propertyValues = new PropertyValueBag();

        if (null !== $serializedId) {
            $model = $this->getModelFromSerializedId($serializedId);
        } else {
            $dataProvider = $environment->getDataProvider();
            $model        = $dataProvider->getEmptyModel();
        }

        $widgetManager = new ContaoWidgetManager($environment, $model);

        // Process input and update changed properties.
        $treeType      = \substr($property->getWidgetType(), 0, 4);
        $propertyValue = $this->getTreeValue($treeType, $propertyValue);
        if (('file' === $treeType) || ('page' === $treeType)) {
            $extra = $property->getExtra();
            if (\is_array($propertyValue) && !isset($extra['multiple'])) {
                $propertyValue = $propertyValue[0];
            } else {
                $propertyValue = \implode(',', (array) $propertyValue);
            }
        }

        $propertyValues->setPropertyValue($fieldName, $propertyValue);
        $widgetManager->processInput($propertyValues);
        $model->setProperty($fieldName, $propertyValues->getPropertyValue($fieldName));

        return $widgetManager->getWidget($fieldName);
    }
987403
public static function getClassPropertyValue($className, $propertyName)
    {
        $value = BeanProxy::getInjectValue($className, $propertyName);
        if(null === $value)
        {
            if(!class_exists($className))
            {
                $className = BeanParser::getInstance()->getData()[$className]['className'];
            }
            $ref = new \ReflectionClass($className);
            $value = $ref->getDefaultProperties()[$propertyName] ?? null;
        }
        return $value;
    }
456495
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $swoftDir      = dirname(__FILE__, 5);
        $componentDirs = scandir($swoftDir);
        foreach ($componentDirs as $component) {
            if ($component == '.' || $component == '..') {
                continue;
            }

            $componentCommandDir = $swoftDir . DS . $component . DS . 'src/Bean/Collector';
            if (!is_dir($componentCommandDir)) {
                continue;
            }

            $componentNs = ComponentHelper::getComponentNs($component);
            $collectNs = "Swoft{$componentNs}\\Bean\\Collector";
            $collectorFiles = scandir($componentCommandDir);
            foreach ($collectorFiles as $collectorFile){
                $pathInfo = pathinfo($collectorFile);
                if(!isset($pathInfo['filename'])){
                    continue;
                }
                $fileName = $pathInfo['filename'];
                $collectClassName = $collectNs.'\\'.$fileName;
                if(!class_exists($collectClassName)){
                    continue;
                }

                /* @var \Swoft\Bean\CollectorInterface $collector */
                $collector = new $collectClassName();
                $collector->collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);
            }
        }

        return null;
    }
692228
public function widgetToValue($varValue, $itemId)
    {
        if (null === $varValue) {
            return null;
        }
        static $cache = [];
        $attributeId = $this->get('id');
        if (array_key_exists($attributeId, $cache) && array_key_exists($varValue, $cache[$attributeId])) {
            return $cache[$attributeId][$varValue];
        }

        $model = $this->getSelectMetaModel();
        $alias = $this->getIdColumn();

        if ($model->hasAttribute($alias)) {
            $attribute = $model->getAttribute($alias);
            // It is an attribute, we may search for it.
            $ids = $attribute->searchFor($varValue);
        } else {
            // Must be a system column then.
            $result = $this->connection->createQueryBuilder()
                ->select('v.id')
                ->from($this->getSelectSource(), 'v')
                ->where('v.' . $this->getIdColumn() . '=:value')
                ->setParameter('value', $varValue)
                ->execute();

            $ids = $result->fetchAll(\PDO::FETCH_COLUMN);
        }

        // Maybe deleted value?
        if ([] === $ids) {
            return $cache[$attributeId][$varValue] = null;
        }

        // Multiple results.
        if (null === $ids || \count($ids) > 1) {
            throw new \RuntimeException(
                \sprintf(
                    'Multiple values found for %s, are there obsolete values for %s.%s (att_id: %s)?',
                    \var_export($varValue, true),
                    $model->getTableName(),
                    $this->getColName(),
                    $this->get('id')
                )
            );
        }
        $valueId = \array_shift($ids);

        $value = $this->getValuesById(
            [$valueId],
            [$this->getAliasColumn(), $this->getValueColumn(), $this->getIdColumn(), $this->getSortingColumn()]
        );

        return $cache[$attributeId][$varValue] = $value[$valueId];
    }
23473
public static function getValue($objectOrClass, string $propertyName)
    {
        $objectOrClass = self::getObject($objectOrClass);
        $closure =
            /**
             * @return mixed
             */
            function () use ($propertyName) {
                if (\property_exists($this, $propertyName)) {
                    $class = new \ReflectionClass(typeOf($this));
                    $property = $class->getProperty($propertyName);
                    $property->setAccessible(true);
                    return $property->getValue($this);
                }
                throw new \RuntimeException(
                    Picklock::errorMessage($this, $propertyName, false)
                );
            };
        return
            $closure->bindTo($objectOrClass, $objectOrClass)();
    }
1231286
protected function isValueObject($className, $propertySourceHint)
    {
        $className = $this->getUnproxiedClassName($className);
        try {
            $classSchema = $this->getClassSchema($className);

            return $classSchema->getModelType() === ClassSchema::MODELTYPE_VALUEOBJECT;
        } catch (ClassSchemaNotFoundException $exception) {
            throw new ClassSchemaNotFoundException('No class schema found for "' . $className . '". The class should probably marked as entity or value object! This happened while examining "' . $propertySourceHint . '"', 1340185197);
        }
    }
950769
public function property(string $propertyName): PropertyColumnDefiner
    {
        $this->verifyProperty(__METHOD__, $propertyName);

        return new PropertyColumnDefiner($this, $propertyName, function (
            Column $column,
            callable $phpToDbPropertyConverter = null,
            callable $dbToPhpPropertyConverter = null,
            bool $ignoreNullabilityMismatch = false
        ) use ($propertyName) {
            $this->propertyColumnMap[$propertyName] = $column->getName();
            $this->addColumn($column);
            $this->mappedProperties[$propertyName] = true;

            $propertyType = $this->class->getProperty($propertyName)->getType();
            $columnType   = $column->getType()->getPhpType();

            if ($ignoreNullabilityMismatch) {
                $propertyType = $propertyType->nonNullable();
                $columnType   = $columnType->nonNullable();
            }

            if ($phpToDbPropertyConverter && $dbToPhpPropertyConverter) {
                $this->phpToDbPropertyConverterMap[$propertyName] = $phpToDbPropertyConverter;
                $this->dbToPhpPropertyConverterMap[$propertyName] = $dbToPhpPropertyConverter;
            } elseif (!$propertyType->equals($columnType)) {
                throw IncompatiblePropertyMappingException::format(
                    'Invalid property to column mapping: cannot bind %s to column \'%s\' as the types are incompatible, '
                    . 'property type %s must match the column type %s',
                    $this->class->getClassName() . '::$' . $propertyName, $column->getName(),
                    $propertyType->asTypeString(), $columnType->asTypeString()
                );
            }
        });
    }
738298
public function getFieldByPropertyName(string $propertyName): ?FieldMetadataInterface
    {
        foreach ($this->fieldsMetadata as $fieldMetadata) {
            if ($propertyName === $fieldMetadata->getPropertyName()) {
                return $fieldMetadata;
            }
        }

        return null;
    }
1122920
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $beanName = $className;
        $scope    = Scope::SINGLETON;

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

        return [$beanName, $scope, ""];
    }
1087303
public static function createDefaultField($fieldName, $fieldConfig)
    {
        /** @var UserField $fieldType */
        $fieldType = $fieldConfig['FieldType'];

        $field = $fieldType::create();
        $field->Name = $fieldName;
        if (is_array($fieldConfig)) {
            foreach ($fieldConfig as $property => $value) {
                $field->setField($property, $value);
            }
        }

        return $field;
    }
526866
def get_widget_for(self, fieldname):
        
        field = self.context.getField(fieldname)
        if not field:
            return None
        return field.widget
315291
private function fieldToProperty($fieldValue, AbstractField $annotation)
    {
        $fieldType = $annotation->type;

        switch ($fieldType) {
            case 'string':
                $propertyValue = strval($fieldValue);
                break;
            case 'bool':
                $propertyValue = boolval($fieldValue);
                break;
            case 'int':
                $propertyValue = intval($fieldValue);
                break;
            case 'float':
                $propertyValue = floatval($fieldValue);
                break;
            case 'array':
                $propertyValue = is_array($fieldValue) ? $fieldValue : (array)($fieldValue);
                break;
            case 'date':
                /** @var \DateTime $fieldValue */
                $propertyValue = ($fieldValue instanceof \DateTime) ? new UTCDateTime($fieldValue) : $fieldValue;
                break;
            case 'id':
                $propertyValue = $fieldValue instanceof ObjectId ? $fieldValue : new ObjectId();
                break;
            case 'embedOne':
                $propertyValue = $this->embedOneToProperty($fieldValue, $annotation);
                break;
            case 'embedMany':
                $propertyValue = $this->embedManyToProperty((array)$fieldValue, $annotation);
                break;
            case 'raw':
            default:
                $propertyValue = $fieldValue;
                break;
        }

        return $propertyValue;
    }
1294993
protected function setProperty($entity, $propertyName, $propertyValue)
    {
        if ($this->getReflection()->hasProperty($propertyName)) {
            $property = $this->getReflection()->getProperty($propertyName);
            $property->setValue($entity, $propertyValue);
        } else {
            $entity->setVirtual($propertyName, $propertyValue);
        }
        
        return $this;
    }
765432
public static function getPropertyValue($obj,$propertyName,$fieldAccess=false)
    {
        $getter=self::getGetter($obj, $propertyName);
        if(!empty($getter)){
            return $obj->$getter();
        }else if($fieldAccess && property_exists($obj, $propertyName)){
            return $obj->$propertyName;
        }
    }
926627
public static I_CmsSerialDateBean createSerialDateBean(String widgetValue) {

        I_CmsSerialDateValue value;
        value = new CmsSerialDateValue(widgetValue);
        return createSerialDateBean(value);
    }
266008
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null)
    {
        $injectValue = $objectAnnotation->getName();
        if (!empty($injectValue)) {
            return [$injectValue, true];
        }

        // phpdoc解析
        $phpReader = new PhpDocReader();
        $property = new \ReflectionProperty($className, $propertyName);
        $propertyClass = $phpReader->getPropertyClass($property);

        $isRef = true;
        $injectProperty = $propertyClass;
        return [$injectProperty, $isRef];
    }
265190
public function getProperty($clientId, $propertyId)
    {
        if (!is_int($clientId)) {
            throw new \InvalidArgumentException('Client ID must be an integer.');
        }

        if (!is_int($propertyId)) {
            throw new \InvalidArgumentException('Property ID must be an integer.');
        }

        $xml = $this->execute(sprintf('branch/%d/property/%d', $clientId, $propertyId));

        $property = new Property;
        $property->setAttributes($xml->attributes());

        $property->setAgentReference(self::normalise($xml->reference->agents, 'string'));

        $address = new Address;
        $address
            ->setName(self::normalise($xml->address->name, 'string'))
            ->setStreet(self::normalise($xml->address->street, 'string'))
            ->setLocality(self::normalise($xml->address->locality, 'string'))
            ->setTown(self::normalise($xml->address->town, 'string'))
            ->setCounty(self::normalise($xml->address->county, 'string'))
            ->setPostcode(self::normalise($xml->address->postcode, 'string'))
            ->setCustomLocation(self::normalise($xml->address->custom_location, 'string'))
            ->setDisplay(self::normalise($xml->address->display, 'string'));

        $property->setAddress($address);

        $price = new Price(self::normalise($xml->price, 'int'));
        $price->setAttributes($xml->price->attributes());
        $property->setPrice($price);

        $property->setRentalFees(self::normalise($xml->rentalfees, 'string'));
        $property->setLettingsFee(self::normalise($xml->lettingsfee, 'string'));
        $property->setRmQualifier(self::normalise($xml->{'rm_qualifier'}, 'int'));
        $property->setAvailable(self::normalise($xml->available, 'string'));
        $property->setUploaded(self::normalise($xml->uploaded, 'string'));
        $property->setLongitude(self::normalise($xml->longitude, 'float'));
        $property->setLatitude(self::normalise($xml->latitude, 'float'));
        $property->setEasting(self::normalise($xml->easting, 'int'));
        $property->setNorthing(self::normalise($xml->northing, 'int'));
        $property->setWebStatus(self::normalise($xml->{'web_status'}, 'int'));
        $property->setCustomStatus(self::normalise($xml->{'custom_status'}, 'string'));
        $property->setCommRent(self::normalise($xml->{'comm_rent'}, 'string'));
        $property->setPremium(self::normalise($xml->premium, 'string'));
        $property->setServiceCharge(self::normalise($xml->{'service_charge'}, 'string'));
        $property->setRateableValue(self::normalise($xml->{'rateable_value'}, 'string'));
        $property->setType(self::normalise($xml->type, 'string'));
        $property->setFurnished(self::normalise($xml->furnished, 'int'));
        $property->setRmType(self::normalise($xml->{'rm_type'}, 'int'));
        $property->setLetBond(self::normalise($xml->{'let_bond'}, 'int'));
        $property->setRmLetTypeId(self::normalise($xml->{'rm_let_type_id'}, 'int'));
        $property->setBedrooms(self::normalise($xml->bedrooms, 'int'));
        $property->setReceptions(self::normalise($xml->receptions, 'int'));
        $property->setBathrooms(self::normalise($xml->bathrooms, 'int'));
        $property->setUserField1(self::normalise($xml->userfield1, 'string'));
        $property->setUserField2(self::normalise($xml->userfield2, 'int'));
        $property->setSoldDate(self::normalise($xml->solddate, 'datetime'));
        $property->setLeaseEnd(self::normalise($xml->leaseend, 'datetime'));
        $property->setInstructed(self::normalise($xml->instructed, 'datetime'));
        $property->setSoldPrice(self::normalise($xml->soldprice, 'int'));
        $property->setGarden(self::normalise($xml->garden, 'boolean'));
        $property->setParking(self::normalise($xml->parking, 'boolean'));
        $property->setNewBuild(self::normalise($xml->newbuild, 'boolean'));
        $property->setGroundRent(self::normalise($xml->groundrent, 'string'));
        $property->setCommission(self::normalise($xml->commission, 'string'));

        if ($xml->landarea) {
            $landArea = new LandArea(
                self::normalise($xml->landarea->area, 'float')
            );
            $landArea->setAttributes($xml->landarea->attributes());
            $property->setLandArea($landArea);
        }

        $property->setStreetView(
            new StreetView(
                self::normalise($xml->streetview->pov_latitude, 'float'),
                self::normalise($xml->streetview->pov_longitude, 'float'),
                self::normalise($xml->streetview->pov_pitch, 'float'),
                self::normalise($xml->streetview->pov_heading, 'float'),
                self::normalise($xml->streetview->pov_zoom, 'int')
            )
        );

        $arr = array();
        foreach ($xml->area as $a) {
            $area = new Area(
                self::normalise($a->min, 'float'),
                self::normalise($a->max, 'float')
            );
            $area->setAttributes($a->attributes());
            $arr[] = $area;
        }
        $property->setArea($arr);

        $property->setDescription(self::normalise($xml->description, 'string'));

        $property->setEnergyEfficiency(
            new EnergyRatingPair(
                self::normalise($xml->hip->energy_performance->energy_efficiency->current, 'int'),
                self::normalise($xml->hip->energy_performance->energy_efficiency->potential, 'int')
            )
        );

        $property->setEnvironmentalImpact(
            new EnergyRatingPair(
                self::normalise($xml->hip->energy_performance->environmental_impact->current, 'int'),
                self::normalise($xml->hip->energy_performance->environmental_impact->potential, 'int')
            )
        );

        $arr = array();
        foreach ($xml->paragraphs->paragraph as $p) {

            $paragraph = new Paragraph;
            $paragraph->setName(self::normalise($p->name, 'string'));
            $paragraph->setFile(self::normalise($p->file->attributes()['ref'], 'int'));
            $paragraph->setDimension(
                new Dimension(
                    self::normalise($p->dimensions->metric, 'string'),
                    self::normalise($p->dimensions->imperial, 'string'),
                    self::normalise($p->dimensions->mixed, 'string')
                )
            );
            $paragraph->setText(self::normalise($p->text, 'string'));
            $paragraph->setAttributes($p->attributes());
            $arr[] = $paragraph;
        }
        $property->setParagraphs($arr);

        $arr = array();
        foreach ($xml->bullets->bullet as $b) {
            $bullet = new Bullet(self::normalise($b, 'string'));
            $bullet->setAttributes($b->attributes());
            $arr[$bullet->getAttribute('id')] = $bullet;
        }
        $property->setBullets($arr);

        $arr = array();
        foreach ($xml->files->file as $f) {
            $file = new File;
            $file->setName(self::normalise($f->name, 'string'));
            $file->setUrl(self::normalise($f->url, 'string'));
            $file->setUpdated(self::normalise($f->updated, 'datetime'));
            $file->setAttributes($f->attributes());
            $arr[$file->getAttribute('id')] = $file;
        }
        $property->setFiles($arr);

        return $property;
    }