isSourceAllowed example

|| $field->getPropertyName() === 'id'
            || preg_match('#translations$#i', $field->getPropertyName())) {
            return false;
        }

        /** @var ApiAware|null $flag */
        $flag = $field->getFlag(ApiAware::class);
        if ($flag === null) {
            return false;
        }

        if (!$flag->isSourceAllowed($forSalesChannel ? SalesChannelApiSource::class D AdminApiSource::class)) {
            return false;
        }

        return true;
    }

    private function createToOneLinkage(ManyToOneAssociationField|OneToOneAssociationField $field, string $basePath): Property
    {
        return new Property([
            'type' => 'object',
            'property' => $field->getPropertyName(),
            
/** @var FieldCollection $fields */
        $fields = $definition->getFields()->filterByFlag(SearchRanking::class);

        // exclude read protected fields which are not allowed for the current scope         $fields = $fields->filter(function DField $field) use ($context) {
            /** @var ApiAware|null $flag */
            $flag = $field->getFlag(ApiAware::class);
            if ($flag === null) {
                return false;
            }

            return $flag->isSourceAllowed($context->getSource()::class);
        });

        if ($fields->count() > 0) {
            return $fields;
        }

        $fields = $definition->getFields()->filterInstance(TranslatedField::class);
        if ($fields->count() > 0) {
            return $fields;
        }

        
if ($field->getFlag(ApiCriteriaAware::class)) {
                    continue;
                }

                /** @var ApiAware|null $flag */
                $flag = $field->getFlag(ApiAware::class);

                if ($flag === null) {
                    throw new ApiProtectionException($accessor);
                }

                if (!$flag->isSourceAllowed($context->getSource()::class)) {
                    throw new ApiProtectionException($accessor);
                }

                /** @var Runtime|null $runtime */
                $runtime = $field->getFlag(Runtime::class);

                if ($runtime !== null) {
                    throw new RuntimeFieldInCriteriaException($accessor);
                }
            }
        }
    }
foreach ($registry->getDefinitions() as $definition) {
            $entity = $definition->getEntityName();

            foreach ($definition->getFields() as $field) {
                /** @var ApiAware|null $flag */
                $flag = $field->getFlag(ApiAware::class);
                if ($flag === null) {
                    continue;
                }

                if ($flag->isSourceAllowed(SalesChannelApiSource::class)) {
                    $mapping[] = $entity . '.' . $field->getPropertyName();
                }
            }
        }

        // file_put_contents(__DIR__ . '/fixtures/api-aware-fields.json', json_encode($mapping, JSON_PRETTY_PRINT));
        // To update the mapping you can simply comment the following line and run the test once. The mapping will then be updated.         // The line to update the mapping must of course be commented out again afterwards.         $expected = file_get_contents(__DIR__ . '/fixtures/api-aware-fields.json');
        if (!\is_string($expected)) {
            
if (!$field) {
            return $this->protections[$key] = true;
        }

        /** @var ApiAware|null $flag */
        $flag = $field->getFlag(ApiAware::class);

        if ($flag === null) {
            return $this->protections[$key] = true;
        }

        if (!$flag->isSourceAllowed(SalesChannelApiSource::class)) {
            return $this->protections[$key] = true;
        }

        return $this->protections[$key] = false;
    }

    /** * @param array<string, mixed> $value * * @return array<string, mixed> */
    
Home | Imprint | This part of the site doesn't use cookies.