Handles conversion of a single property.

@param Component\VCard $input
@param Component\VCard $output
@param Property        $property
@param int             $targetVersion
14325
protected function convertProperty(Component\VCard $input, Component\VCard $output, Property $property, $targetVersion)
    {
        // Skipping these, those are automatically added.
        if (in_array($property->name, ['VERSION', 'PRODID'])) {
            return;
        }

        $parameters = $property->parameters();
        $valueType = null;
        if (isset($parameters['VALUE'])) {
            $valueType = $parameters['VALUE']->getValue();
            unset($parameters['VALUE']);
        }
        if (!$valueType) {
            $valueType = $property->getValueType();
        }
        $newProperty = $output->createProperty(
            $property->name,
            $property->getParts(),
            [], // parameters will get added a bit later.
            $valueType
        );

        if (Document::VCARD30 === $targetVersion) {
            if ($property instanceof Property\Uri && in_array($property->name, ['PHOTO', 'LOGO', 'SOUND'])) {
                $newProperty = $this->convertUriToBinary($output, $newProperty);
            } elseif ($property instanceof Property\VCard\DateAndOrTime) {
                // In vCard 4, the birth year may be optional. This is not the
                // case for vCard 3. Apple has a workaround for this that
                // allows applications that support Apple's extension still
                // omit birthyears in vCard 3, but applications that do not
                // support this, will just use a random birthyear. We're
                // choosing 1604 for the birthyear, because that's what apple
                // uses.
                $parts = DateTimeParser::parseVCardDateTime($property->getValue());
                if (is_null($parts['year'])) {
                    $newValue = '1604-'.$parts['month'].'-'.$parts['date'];
                    $newProperty->setValue($newValue);
                    $newProperty['X-APPLE-OMIT-YEAR'] = '1604';
                }

                if ('ANNIVERSARY' == $newProperty->name) {
                    // Microsoft non-standard anniversary
                    $newProperty->name = 'X-ANNIVERSARY';

                    // We also need to add a new apple property for the same
                    // purpose. This apple property needs a 'label' in the same
                    // group, so we first need to find a groupname that doesn't
                    // exist yet.
                    $x = 1;
                    while ($output->select('ITEM'.$x.'.')) {
                        ++$x;
                    }
                    $output->add('ITEM'.$x.'.X-ABDATE', $newProperty->getValue(), ['VALUE' => 'DATE-AND-OR-TIME']);
                    $output->add('ITEM'.$x.'.X-ABLABEL', '_$!<Anniversary>!$_');
                }
            } elseif ('KIND' === $property->name) {
                switch (strtolower($property->getValue())) {
                    case 'org':
                        // vCard 3.0 does not have an equivalent to KIND:ORG,
                        // but apple has an extension that means the same
                        // thing.
                        $newProperty = $output->createProperty('X-ABSHOWAS', 'COMPANY');
                        break;

                    case 'individual':
                        // Individual is implicit, so we skip it.
                        return;

                    case 'group':
                        // OS X addressbook property
                        $newProperty = $output->createProperty('X-ADDRESSBOOKSERVER-KIND', 'GROUP');
                        break;
                }
            }
        } elseif (Document::VCARD40 === $targetVersion) {
            // These properties were removed in vCard 4.0
            if (in_array($property->name, ['NAME', 'MAILER', 'LABEL', 'CLASS'])) {
                return;
            }

            if ($property instanceof Property\Binary) {
                $newProperty = $this->convertBinaryToUri($output, $newProperty, $parameters);
            } elseif ($property instanceof Property\VCard\DateAndOrTime && isset($parameters['X-APPLE-OMIT-YEAR'])) {
                // If a property such as BDAY contained 'X-APPLE-OMIT-YEAR',
                // then we're stripping the year from the vcard 4 value.
                $parts = DateTimeParser::parseVCardDateTime($property->getValue());
                if ($parts['year'] === $property['X-APPLE-OMIT-YEAR']->getValue()) {
                    $newValue = '--'.$parts['month'].'-'.$parts['date'];
                    $newProperty->setValue($newValue);
                }

                // Regardless if the year matched or not, we do need to strip
                // X-APPLE-OMIT-YEAR.
                unset($parameters['X-APPLE-OMIT-YEAR']);
            }
            switch ($property->name) {
                case 'X-ABSHOWAS':
                    if ('COMPANY' === strtoupper($property->getValue())) {
                        $newProperty = $output->createProperty('KIND', 'ORG');
                    }
                    break;
                case 'X-ADDRESSBOOKSERVER-KIND':
                    if ('GROUP' === strtoupper($property->getValue())) {
                        $newProperty = $output->createProperty('KIND', 'GROUP');
                    }
                    break;
                case 'X-ANNIVERSARY':
                    $newProperty->name = 'ANNIVERSARY';
                    // If we already have an anniversary property with the same
                    // value, ignore.
                    foreach ($output->select('ANNIVERSARY') as $anniversary) {
                        if ($anniversary->getValue() === $newProperty->getValue()) {
                            return;
                        }
                    }
                    break;
                case 'X-ABDATE':
                    // Find out what the label was, if it exists.
                    if (!$property->group) {
                        break;
                    }
                    $label = $input->{$property->group.'.X-ABLABEL'};

                    // We only support converting anniversaries.
                    if (!$label || '_$!<Anniversary>!$_' !== $label->getValue()) {
                        break;
                    }

                    // If we already have an anniversary property with the same
                    // value, ignore.
                    foreach ($output->select('ANNIVERSARY') as $anniversary) {
                        if ($anniversary->getValue() === $newProperty->getValue()) {
                            return;
                        }
                    }
                    $newProperty->name = 'ANNIVERSARY';
                    break;
                // Apple's per-property label system.
                case 'X-ABLABEL':
                    if ('_$!<Anniversary>!$_' === $newProperty->getValue()) {
                        // We can safely remove these, as they are converted to
                        // ANNIVERSARY properties.
                        return;
                    }
                    break;
            }
        }

        // set property group
        $newProperty->group = $property->group;

        if (Document::VCARD40 === $targetVersion) {
            $this->convertParameters40($newProperty, $parameters);
        } else {
            $this->convertParameters30($newProperty, $parameters);
        }

        // Lastly, we need to see if there's a need for a VALUE parameter.
        //
        // We can do that by instantating a empty property with that name, and
        // seeing if the default valueType is identical to the current one.
        $tempProperty = $output->createProperty($newProperty->name);
        if ($tempProperty->getValueType() !== $newProperty->getValueType()) {
            $newProperty['VALUE'] = $newProperty->getValueType();
        }

        $output->add($newProperty);
    }
130428
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        switch ($propertyName) {
            case 'resource':
                return PersistentResource::class;
            case 'originalAsset':
                return Image::class;
            case 'title':
                return 'string';
        }
        return parent::getTypeOfChildProperty($targetType, $propertyName, $configuration);
    }
1072298
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        if ($source instanceof \DateTimeInterface) {
            return $source->format('U');
        }

        if ($source === null || strlen($source) === 0) {
            return null;
        }

        if (!is_numeric($source)) {
            return new Error('"%s" is not numeric.', 1332933658, [$source]);
        }
        return (integer)$source;
    }
664518
public function setOriginalDocumentProperty(string $oid, string $property, $value) : void
    {
        $this->originalDocumentData[$oid][$property] = $value;
    }
748191
public function convert($img, $outputFormat, $targetPath, $quality = null)
    {
        ImageFile::save(
            $targetPath,
            ImageFile::get($img),
            ImageFile::getType($img, $outputFormat),
            $quality
        );
    }
246095
protected function convertVCard($data, $target, array $propertiesFilter = null)
    {
        if (is_resource($data)) {
            $data = stream_get_contents($data);
        }
        $input = VObject\Reader::read($data);
        if (!empty($propertiesFilter)) {
            $propertiesFilter = array_merge(['UID', 'VERSION', 'FN'], $propertiesFilter);
            $keys = array_unique(array_map(function ($child) {
                return $child->name;
            }, $input->children()));
            $keys = array_diff($keys, $propertiesFilter);
            foreach ($keys as $key) {
                unset($input->$key);
            }
            $data = $input->serialize();
        }
        $output = null;
        try {
            switch ($target) {
                default:
                case 'vcard3':
                    if (VObject\Document::VCARD30 === $input->getDocumentType()) {
                        // Do nothing
                        return $data;
                    }
                    $output = $input->convert(VObject\Document::VCARD30);

                    return $output->serialize();
                case 'vcard4':
                    if (VObject\Document::VCARD40 === $input->getDocumentType()) {
                        // Do nothing
                        return $data;
                    }
                    $output = $input->convert(VObject\Document::VCARD40);

                    return $output->serialize();
                case 'jcard':
                    $output = $input->convert(VObject\Document::VCARD40);

                    return json_encode($output);
            }
        } finally {
            // Destroy circular references to PHP will GC the object.
            $input->destroy();
            if (!is_null($output)) {
                $output->destroy();
            }
        }
    }
626757
public function transmute(InputDescriptor $input, $targetFormat)
    {
        if (!in_array($targetFormat, array('image', 'audio', 'video', 'flash', 'text'))) {
            return null;
        }

        $mediaType = $this->mediaTypeManager->find($input->getMediaType());

        return $this->extractor->extract($input, $mediaType, $targetFormat);
    }
512938
private function findScope(/*object */$target, string $property)
    {
        if (\property_exists($target, $property)) {
            return $target;
        }

        return $this->findParentScope($target, $property);
    }
1350923
private void updateProperties(T target, Map<String, Object> source) {
        Map<String, PropertyDescriptor> mapTargetProps = MappingUtils.mapPropertyDescriptors(target.getClass());

        for (String sourceKey : source.keySet()) {
            if (mapTargetProps.containsKey(sourceKey) == true) {
                MappingUtils.callSetter(target, mapTargetProps.get(sourceKey), source.get(sourceKey));
            }
        }
    }
93718
public function canConvertFrom($source, $targetType)
    {
        return !(
            $this->reflectionService->isClassAnnotatedWith($targetType, Flow\Entity::class) ||
            $this->reflectionService->isClassAnnotatedWith($targetType, Flow\ValueObject::class) ||
            $this->reflectionService->isClassAnnotatedWith($targetType, \Doctrine\ORM\Mapping\Entity::class)
        );
    }
71731
public function getTypeOfChildProperty($targetType, $propertyName, PropertyMappingConfigurationInterface $configuration)
    {
        $specificTargetType = $this->objectContainer->getImplementationClassName($targetType);

        if (Core::get()->classExists($specificTargetType)) {
            $propertyTags = $this->reflectionService->getPropertyTagValues($specificTargetType, $propertyName, 'var');

            if (!empty($propertyTags)) {
                return current($propertyTags);
            }
        }

        return parent::getTypeOfChildProperty($targetType, $propertyName, $configuration);
    }
946322
public function update(PluginBundleInterface $plugin, $currentVersion, $targetVersion)
    {
        $this->checkInstallationStatus($plugin, true);
        $this->validator->activeUpdateMode();
        $this->validatePlugin($plugin);
        $this->validator->deactivateUpdateMode();
        $this->log('Updating plugin configuration...');
        $this->baseInstaller->update($plugin, $currentVersion, $targetVersion);
        $this->recorder->update($plugin, $this->validator->getPluginConfiguration());
    }
606814
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
    {
        $identity = $this->persistenceManager->getIdentifierByObject($source);
        switch (true) {
            case $source instanceof ImageVariant:
                if (!isset($convertedChildProperties['originalAsset']) || !is_array($convertedChildProperties['originalAsset'])) {
                    return null;
                }

                $convertedChildProperties['originalAsset']['__identity'] = $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset());

                return [
                    '__identity' => $identity,
                    '__type' => \Neos\Media\Domain\Model\ImageVariant::class,
                    'originalAsset' => $convertedChildProperties['originalAsset'],
                    'adjustments' => $convertedChildProperties['adjustments']
                ];
            case $source instanceof AssetInterface:
                if (!isset($convertedChildProperties['resource']) || !is_array($convertedChildProperties['resource'])) {
                    return null;
                }

                $convertedChildProperties['resource']['__identity'] = $this->persistenceManager->getIdentifierByObject($source->getResource());

                return [
                    '__identity' => $identity,
                    '__type' => \Neos\Utility\TypeHandling::getTypeForValue($source),
                    'title' => $source->getTitle(),
                    'resource' => $convertedChildProperties['resource']
                ];
        }
    }
915322
public function canConvertFrom($source, $targetType)
    {
        if (is_array($source)) {
            if (isset($source['dateMask']) && ($source['dateMask'] !== '') && isset($source['date'])) {
                if ($source['dateMask'] === $source['date']) {
                    return true;
                }
            }
            return false;
        }
    }
920711
public function cloneProperty($target, $source, $propertyName)
    {
        $this->validaObjects($target, $source);

        $reflection = new \ReflectionClass($target);
        if (!$reflection->hasProperty($propertyName)) {
            throw new NotExistingPropertyException();
        }

        $this->propertyAccessor->setValue(
            $target,
            $propertyName,
            $this->propertyAccessor->getValue($source, $propertyName)
        );
    }
1038999
public function deleteVariant(TargetInterface $target, $variant)
    {
        if ($variant == static::ORIGINAL) {
            $path = $target->original();
        } else {
            $path = $target->variant($variant);
        }

        // If the file does not exist, consider 'deletion' a success
        if ( ! $this->storage->exists($path)) {
            return true;
        }

        return $this->storage->delete($path);
    }
739257
function (inputVersion, outputVersion) {
        var converter;

        inputVersion = semver.clean(inputVersion);
        outputVersion = semver.clean(outputVersion);

        for (converter in this.converters) {
            // eslint-disable-next-line no-prototype-builtins
            converter = this.converters.hasOwnProperty(converter) && this.converters[converter];
            if (converter && semver.eq(converter.input, inputVersion) && semver.eq(converter.output, outputVersion)) {
                return generateConverter(converter);
            }
        }
    }