Get an instance of a converter with its options set.

@param string $converterName The name of the converter from the schema.
@param string $attribute The name of the attribute.
@return AttributeConverterInterface
499814
protected function getConverterWithOptions($converterName, $attribute)
    {
        $converter = AttributeConverterFactory::get($converterName);
        $converter->setOptions(array_merge(
            $this->schema->getConverterOptions($converterName, '_default'),
            $this->schema->getConverterOptions($converterName, $attribute)
        ));
        $converter->setOperationType($this->type);
        $converter->setLdapConnection($this->connection);
        $converter->setDn($this->dn);

        if ($converter instanceof OperationGeneratorInterface) {
            $converter->setOperation($this->operation);
        }

        return $converter;
    }
664061
protected function denormalizeRelation(string $attributeName, PropertyMetadata $propertyMetadata, string $className, $value, ?string $format, array $context)
    {
        // Give a chance to other normalizers (e.g.: DateTimeNormalizer)
        if (!$this->resourceClassResolver->isResourceClass($className)) {
            $context['resource_class'] = $className;

            if ($this->serializer instanceof DenormalizerInterface) {
                return $this->serializer->denormalize($value, $className, $format, $context);
            }
            throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class));
        }

        if (!\is_array($value) || !isset($value['id'], $value['type'])) {
            throw new NotNormalizableValueException('Only resource linkage supported currently, see: http://jsonapi.org/format/#document-resource-object-linkage.');
        }

        try {
            return $this->iriConverter->getItemFromIri($value['id'], $context + ['fetch_data' => true]);
        } catch (ItemNotFoundException $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
425530
public function getDisplayableAttribute($attribute)
    {
        $primaryAttribute = $this->getPrimaryAttribute($attribute);

        $expectedAttributes = $attribute != $primaryAttribute
                    ? [$attribute, $primaryAttribute] : [$attribute];

        foreach ($expectedAttributes as $name) {
            // The developer may dynamically specify the array of custom attributes on this
            // validator instance. If the attribute exists in this array it is used over
            // the other ways of pulling the attribute name for this given attributes.
            if (isset($this->customAttributes[$name])) {
                return $this->customAttributes[$name];
            }

            // We allow for a developer to specify language lines for any attribute in this
            // application, which allows flexibility for displaying a unique displayable
            // version of the attribute name instead of the name used in an HTTP POST.
            if ($line = $this->getAttributeFromTranslations($name)) {
                return $line;
            }
        }

        // When no language line has been specified for the attribute and it is also
        // an implicit attribute we will display the raw attribute's name and not
        // modify it with any of these replacements before we display the name.
        if (isset($this->implicitAttributes[$primaryAttribute])) {
            return $attribute;
        }

        return str_replace('_', ' ', Str::snake($attribute));
    }
1247404
public function input($attribute=null) {
		if($attribute)
			return $this->attribute($attribute)->input();
		return $this->input;
	}
14108
function attribute( $attributeName )
    {
        if ( in_array( $attributeName,
                       array( 'alternative_text',
                              'original_filename',
                              'is_valid' ) ) )
        {
            return $this->attributeFromOriginal( $attributeName );
        }
        $aliasName = $attributeName;
        return $this->imageAlias( $aliasName );
    }
991862
protected function denormalizeRelation(string $attributeName, PropertyMetadata $propertyMetadata, string $className, $value, ?string $format, array $context)
    {
        if (\is_string($value)) {
            try {
                return $this->iriConverter->getItemFromIri($value, $context + ['fetch_data' => true]);
            } catch (ItemNotFoundException $e) {
                throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
            } catch (InvalidArgumentException $e) {
                // Give a chance to other normalizers (e.g.: DateTimeNormalizer)
            }
        }

        if (
            !$this->resourceClassResolver->isResourceClass($className) ||
            $propertyMetadata->isWritableLink()
        ) {
            $context['resource_class'] = $className;
            $context['api_allow_update'] = true;

            try {
                if (!$this->serializer instanceof DenormalizerInterface) {
                    throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', DenormalizerInterface::class));
                }

                return $this->serializer->denormalize($value, $className, $format, $context);
            } catch (InvalidValueException $e) {
                if (!$this->allowPlainIdentifiers || null === $this->itemDataProvider) {
                    throw $e;
                }
            }
        }

        if (!\is_array($value)) {
            // repeat the code so that IRIs keep working with the json format
            if (true === $this->allowPlainIdentifiers && $this->itemDataProvider) {
                $item = $this->itemDataProvider->getItem($className, $value, null, $context + ['fetch_data' => true]);
                if (null === $item) {
                    throw new ItemNotFoundException(sprintf('Item not found for "%s".', $value));
                }

                return $item;
            }

            throw new UnexpectedValueException(sprintf(
                'Expected IRI or nested document for attribute "%s", "%s" given.', $attributeName, \gettype($value)
            ));
        }

        throw new UnexpectedValueException(sprintf('Nested documents for attribute "%s" are not allowed. Use IRIs instead.', $attributeName));
    }
1235069
public function getFormOptions(AttributeInterface $attribute)
    {
        $formOptions = parent::getFormOptions($attribute);
        $formOptions['attribute'] = $attribute;

        return $formOptions;
    }
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()));
        }
    }
1106721
public function getAttribute($attribute)
    {
        // Return the raw value of a translatable attribute if requested
        if ($this->rawValueRequested($attribute)) {
            $rawAttribute = snake_case(str_replace('raw', '', $attribute));
            return $this->attributes[$rawAttribute];
        }
        // Return the translation for the given attribute if available
        if ($this->isTranslated($attribute)) {
            return $this->translate($attribute);
        }
        // Return parent
        return parent::getAttribute($attribute);
    }
235023
protected function getHelper($helperName)
    {
        if (method_exists($this->view, 'plugin')) {
            $helper = $this->view->plugin($helperName);
        }
        return $helper;
    }
424653
public static function register($name, $class)
    {
        if (isset(self::$converterMap[$name])) {
            throw new InvalidArgumentException(
                sprintf('The attribute converter name "%s" is already registered.', $name)
            );
        }

        self::$converterMap[$name] = $class;
    }
325237
public function getByName(string $name): Conversion
    {
        $conversion = $this->first(function (Conversion $conversion) use ($name) {
            return $conversion->getName() === $name;
        });

        if (! $conversion) {
            throw InvalidConversion::unknownName($name);
        }

        return $conversion;
    }
2513
private static function getAdapterClassName($adapterName)
    {
        $className = 'Piwik\Db\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace(array('_', '\\'), ' ', strtolower($adapterName))));
        if (!class_exists($className)) {
            throw new \Exception(sprintf("Adapter '%s' is not valid. Maybe check that your Matomo configuration files in config/*.ini.php are readable by the webserver.", $adapterName));
        }
        return $className;
    }
1246474
private function loadAdapter($adapterName, $configName, array $adapterConfig, ContainerBuilder $container)
    {
        if (isset($adapterConfig['service'])) {
            // Custom adapter service.
            $container->setAlias($adapterName, Utility::cleanServiceName($adapterConfig['service']));
            return $this;
        }

        // Built-In Adapter
        switch ($adapterConfig['type']) {
            case 'jsonapiorg':
                $definition = $this->createJsonApiAdapter($configName, $container);
                break;
            default:
                throw new \RuntimeException(sprintf('The adapter type "%s" is currently not supported.', $adapterConfig['type']));
        }
        $container->setDefinition($adapterName, $definition);
        return $this;

    }
600418
public function getAttribute(AttributeType $attributeType): Attribute
    {
        $attribute = null;

        $this->attributes->filter(function ($attr) use ($attributeType, &$attribute) {
            if ($attr->getAttributeType() === $attributeType) {
                $attribute = $attr;
            }
        });

        if ($attribute === null) {
            throw new InvalidArgumentException(sprintf('Attribute with name « %s » not found for product « %s »', $attributeName, $this->getName()));
        }

        return $attribute;
    }
852902
public function attr($attribute)
    {
        if (!$this->nodes) {
            throw new \InvalidArgumentException('The current node list is empty.');
        }

        $node = $this->getNode(0);

        return $node->hasAttribute($attribute) ? $node->getAttribute($attribute) : null;
    }
1288802
public function getJsonConverter($className)
    {
        switch ($className) {
            case 'Puli\Manager\Api\Config\ConfigFile':
                return $this->container->getConfigFileConverter();

            case 'Puli\Manager\Api\Module\ModuleFile':
                return $this->container->getLegacyModuleFileConverter();

            case 'Puli\Manager\Api\Module\RootModuleFile':
                return $this->container->getLegacyRootModuleFileConverter();

            default:
                throw new InvalidArgumentException(sprintf(
                    'Could not find converter for class "%s".',
                    $className
                ));
        }
    }