Get the supported attribute or null.

@param EncodePropertyValueFromWidgetEvent|DecodePropertyValueForWidgetEvent $event The subscribed event.

@return Timestamp|null
491357
private function getSupportedAttribute($event)
    {
        $model = $event->getModel();

        // Not a metamodel model.
        if (!$model instanceof Model) {
            return null;
        }

        $property  = $event->getProperty();
        $attribute = $model->getItem()->getAttribute($property);

        if ($attribute instanceof Timestamp) {
            return $attribute;
        }

        return null;
    }
669597
public function getFilters(GetPropertyOptionsEvent $event)
    {
        if (!$this->scopeMatcher->currentScopeIsBackend()) {
            return;
        }

        if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_attribute')
            || ($event->getPropertyName() !== 'select_filter')
        ) {
            return;
        }

        $model     = $event->getModel();
        $metaModel = $this->factory->getMetaModel($model->getProperty('select_table'));

        if ($metaModel) {
            $statement = $this->connection
                ->prepare('SELECT id,name FROM tl_metamodel_filter WHERE pid=:pid ORDER BY name');

            $statement->execute(['pid' => $metaModel->get('id')]);

            $result = [];
            while ($row = $statement->fetch(\PDO::FETCH_OBJ)) {
                /** @noinspection PhpUndefinedFieldInspection */
                $result[$row->id] = $row->name;
            }

            $event->setOptions($result);
        }
    }
586192
public function determineEventBinding(Event $event)
    {
        switch ($event->getCode()) {
            case Event::RESOURCE_DELETED:
                return 'delete';
                break;
            case Event::RESOURCE_CREATED:
                return 'create';
                break;
            case Event::RESOURCE_MODIFIED:
                return 'modify';
            break;
        }
    }
320574
public static function get_property_null($property) {

        self::fill_properties_cache();

        if (!array_key_exists($property, self::$propertiescache)) {
            throw new coding_exception('Invalid property requested: ' . $property);
        }

        return self::$propertiescache[$property]['null'];
    }
1004125
public function handleEncode(EncodeValueEvent $event)
    {
        $definition = $event->getValue();
        if (!$definition instanceof Definition) {
            return;
        }

        $type   = $definition->getType();
        $method = 'encode' . $this->convertTypeToMethod($type);

        if (method_exists($this, $method)) {
            $buffer = $this->$method($definition, $event->getEncoder(), $event->getJsonFlags());

            if ($buffer) {
                $event->addLine($buffer);
                $this->handleMethodCalls($definition, $event->getEncoder(), $event);
            }

            $event->setSuccessful();
        }
    }
182658
public function resolve($event)
    {
        if ($event instanceof UserEvent) {
            return $this->getEventDetailsArray($event->getUser()->getUsername());
        }

        return null;
    }
1374058
public function evaluateAttributes($event)
    {
        if ($this->skipUpdateOnClean
            && $event->name == ActiveRecordSaveEvent::BEFORE_UPDATE
            && empty($this->owner->dirtyAttributes)
        ) {
            return;
        }

        if (!empty($this->attributes[$event->name])) {
            $attributes = (array) $this->attributes[$event->name];
            $value = $this->getValue($event);
            foreach ($attributes as $attribute) {
                // ignore attribute names which are not string (e.g. when set by TimestampBehavior::updatedAtAttribute)
                if (is_string($attribute)) {
                    if ($this->preserveNonEmptyValues && !empty($this->owner->$attribute)) {
                        continue;
                    }
                    $this->owner->$attribute = $value;
                }
            }
        }
    }
705966
protected function getDecodedValueForProp($propName, $propValue)
    {
        if (in_array($propName, $this->propTypes['string'])) {
            // Strip away null terminators. I think this should be desired, otherwise it just ends in confusion.
            $value = str_replace("\0", '', $this->decodePropValue($propValue, true));
        } elseif (in_array($propName, $this->propTypes['time'])) {
            // Convert from microseconds to minutes (how ADUC displays it anyway, and seems the most practical).
            $value = hexdec($this->decodePropValue($propValue)) / self::TIME_CONVERSION;
        } elseif (in_array($propName, $this->propTypes['int'])) {
            $value = hexdec($this->decodePropValue($propValue));
        } else {
            $value = $this->decodePropValue($propValue);
        }

        return $value;
    }
1356128
protected function RetrievePropertyValueFromData(string $property)
    {
        $isNullable = in_array(
            $property,
            static::DaftObjectNullableProperties(),
            DefinitionAssistant::IN_ARRAY_STRICT_MODE
        );

        if ( ! array_key_exists($property, $this->data) && ! $isNullable) {
            throw Exceptions\Factory::PropertyNotNullableException(static::class, $property);
        } elseif ($isNullable) {
            return $this->data[$property] ?? null;
        }

        return $this->data[$property];
    }
1294838
public static function toEvent(string $event): ?FSEvent
    {
        if (preg_match(static::REGEX, $event, $matches)) {
            $date = Carbon::parse($matches[static::DATE]);
            $path = $matches[static::PATH];
            $events = explode(' ', $matches[static::EVENTS]);
            $events = array_intersect(FSEvent::getPossibleTypes(), $events);
            asort($events);

            return new FSEvent($date, $path, $events);
        }

        return null;
    }
483071
public function getAutocodeProperty($property)
    {
        return isset($this->autocodeProperties[$property])
            ? $this->autocodeProperties[$property]
            : null;
    }
556741
protected function getCurrentLdapAttributeValue($attribute)
    {
        if (!$this->getDn() || !$this->getLdapConnection()) {
            throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
        }

        $query = new LdapQueryBuilder($this->getLdapConnection());
        try {
            return $query->select($attribute)
                ->where($query->filter()->present('objectClass'))
                ->setBaseDn($this->getDn())
                ->setScopeBase()
                ->getLdapQuery()
                ->getSingleScalarOrNullResult();
        } catch (EmptyResultException $e) {
            throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
        }
    }
772324
private function getPropertyValue($property)
    {
        $value  = null;
        $getter = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($property);

        if (method_exists($this, $getter)) {
            $value = $this->{$getter}();
        } elseif ($this->returnAdditionalSetting($property)) {
            $value = $this->returnAdditionalSetting($property);
        }

        return $value;
    }
345414
protected function getSerializeValue($value, $event)
    {
        switch ($event) {
            case ActiveRecord::EVENT_BEFORE_INSERT:
            case ActiveRecord::EVENT_BEFORE_UPDATE:
                if (is_array($value)) {
                    $value = serialize($value);
                }
                break;
            case ActiveRecord::EVENT_AFTER_FIND:
                $value = @unserialize($value) ?: $value;
                break;
        }
        return $value;
    }
425580
public function process(array $event)
    {
        $remoteAddress = null;

        /** @noinspection UnSafeIsSetOverArrayInspection */
        if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) {
            $remoteAddress = $_SERVER['HTTP_CLIENT_IP'];
        } /** @noinspection UnSafeIsSetOverArrayInspection */
        elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $remoteAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } /** @noinspection UnSafeIsSetOverArrayInspection */
        elseif (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
            $remoteAddress = $_SERVER['REMOTE_ADDR'];
        }

        if (!array_key_exists('extra', $event)) {
            $event['extra'] = [];
        }

        $event['extra']['ip'] = $remoteAddress;

        return $event;
    }
1267416
public function getEntityAttributeValue($field)
    {
        if ($field) {
            $functionName = 'get'.ucfirst($field);

            // Avoid error when the widget refer to a property that has been removed
            if (!method_exists($this, $functionName)) {
                return;
            }

            $fieldValue = $this->{$functionName}();
        } else {
            $fieldValue = null;
        }

        return $fieldValue;
    }
103712
public function validateEventExist($event, $events)
    {
        if ($event == '') {
            return null;
        }

        if (!in_array($event, array_values($events))) {
            throw new \InvalidArgumentException(sprintf('Event "%s" is invalid.', $event));
        }

        return $event;
    }