private function createProperty(
        PropertyInterface $property,
        $propertyName,
        $variantHandling,
        ConditionInterface $condition = null,
        ConditionInterface $legendCondition = null
    ) {
        $paletteProperty = new Property($propertyName);

        $extra = $property->getExtra();

        $chain = new PropertyConditionChain();
        $paletteProperty->setEditableCondition($chain);
        if (isset($extra['readonly'])) {
            $chain->addCondition(new BooleanCondition($extra['readonly']));
        }

        $chain = new PropertyConditionChain();
        $paletteProperty->setVisibleCondition($chain);
        // If variants, do show only if allowed.
        if ($variantHandling) {
            $chain->addCondition(new IsVariantAttribute());
        }
        $chain->addCondition(
            new BooleanCondition(
                !((isset($extra['doNotShow']) && $extra['doNotShow'])
                || (isset($extra['hideInput']) && $extra['hideInput']))
            )
        );

        if (null !== $condition) {
            $chain->addCondition($condition);
        }
        if (null !== $legendCondition) {
            $chain->addCondition($legendCondition);
        }

        return $paletteProperty;
    }