本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\AttributeInterface::getBackendType方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::getBackendType方法的具体用法?PHP AttributeInterface::getBackendType怎么用?PHP AttributeInterface::getBackendType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::getBackendType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAttribute
/**
* Sets the attribute
*
* @param AttributeInterface $attribute
*
* @throws ColumnLabelException
*/
public function setAttribute(AttributeInterface $attribute = null)
{
$this->attribute = $attribute;
if (null === $attribute) {
$this->locale = null;
$this->scope = null;
$this->suffixes = $this->rawSuffixes;
$this->propertyPath = lcfirst(Inflector::classify($this->name));
} else {
if (!in_array($attribute->getBackendType(), [AbstractAttributeType::BACKEND_TYPE_REF_DATA_OPTION, AbstractAttributeType::BACKEND_TYPE_REF_DATA_OPTIONS])) {
$this->propertyPath = $attribute->getBackendType();
} else {
$this->propertyPath = $attribute->getReferenceDataName();
}
$suffixes = $this->rawSuffixes;
if ($attribute->isLocalizable()) {
if (count($suffixes)) {
$this->locale = array_shift($suffixes);
} else {
throw new ColumnLabelException('The column "%column%" must contain a locale code', ['%column%' => $this->label]);
}
}
if ($attribute->isScopable()) {
if (count($suffixes)) {
$this->scope = array_shift($suffixes);
} else {
throw new ColumnLabelException('The column "%column%" must contain a scope code', ['%column%' => $this->label]);
}
}
$this->suffixes = $suffixes;
}
}
示例2: setAttribute
/**
* Sets the attribute
*
* @param AttributeInterface $attribute
*
* @throws ColumnLabelException
*/
public function setAttribute(AttributeInterface $attribute = null)
{
$this->attribute = $attribute;
if (null === $attribute) {
$this->locale = null;
$this->scope = null;
$this->suffixes = $this->rawSuffixes;
$this->propertyPath = lcfirst(Inflector::classify($this->name));
} else {
$this->propertyPath = $attribute->getBackendType();
$suffixes = $this->rawSuffixes;
if ($attribute->isLocalizable()) {
if (count($suffixes)) {
$this->locale = array_shift($suffixes);
} else {
throw new ColumnLabelException('The column "%column%" must contain a locale code', array('%column%' => $this->label));
}
}
if ($attribute->isScopable()) {
if (count($suffixes)) {
$this->scope = array_shift($suffixes);
} else {
throw new ColumnLabelException('The column "%column%" must contain a scope code', array('%column%' => $this->label));
}
}
$this->suffixes = $suffixes;
}
}
示例3:
function it_throws_an_exception_when_the_locale_is_not_provided($qb, AttributeInterface $attribute)
{
$attribute->getCode()->willReturn('my_code');
$attribute->getBackendType()->willReturn('options');
$attribute->getAttributeType()->willReturn('pim_catalog_simpleselect');
$this->shouldThrow('\\InvalidArgumentException')->duringAddAttributeSorter($attribute, 'desc', null, 'ecommerce');
}
示例4:
function it_returns_not_blank_and_datetime_constraints(AttributeInterface $attribute)
{
$attribute->isRequired()->willReturn(true);
$attribute->getBackendType()->willReturn(AbstractAttributeType::BACKEND_TYPE_DATETIME);
$constraints = $this->guessConstraints($attribute);
$constraints->shouldHaveCount(2);
$constraints->offsetGet(0)->shouldReturnAnInstanceOf('Symfony\\Component\\Validator\\Constraints\\NotBlank');
$constraints->offsetGet(1)->shouldReturnAnInstanceOf('Symfony\\Component\\Validator\\Constraints\\DateTime');
}
示例5: addData
/**
* {@inheritdoc}
*/
public function addData($data)
{
$backendType = $this->attribute->getBackendType();
if (substr($backendType, -1, 1) === 's') {
$backendType = substr($backendType, 0, strlen($backendType) - 1);
}
$name = 'add' . ucfirst($backendType);
return $this->{$name}($data);
}
示例6:
function it_normalizes_value_with_decimal_support_backend(ProductValueInterface $value, AttributeInterface $attribute)
{
$attribute->getCode()->willReturn('code');
$attribute->getBackendType()->willReturn('decimal');
$attribute->isLocalizable()->willReturn(false);
$attribute->isScopable()->willReturn(false);
$value->getData()->willReturn('42.42');
$value->getAttribute()->willReturn($attribute);
$this->normalize($value, 'mongodb_json', [])->shouldReturn(['code' => 42.42]);
}
示例7: addConstraint
/**
* @param ClassMetadata $metadata
* @param Constraint $constraint
* @param AttributeInterface $attribute
*/
protected function addConstraint(ClassMetadata $metadata, Constraint $constraint, AttributeInterface $attribute)
{
$target = $constraint->getTargets();
if (is_array($target)) {
throw new \LogicException('No support provided for constraint on many targets');
} elseif (Constraint::PROPERTY_CONSTRAINT === $target) {
$metadata->addPropertyConstraint($attribute->getBackendType(), $constraint);
} elseif (Constraint::CLASS_CONSTRAINT === $target) {
$metadata->addConstraint($constraint);
}
}
示例8: let
function let(QueryBuilder $qb, AttributeValidatorHelper $attrValidatorHelper, Expr $expr, AttributeInterface $image)
{
$this->beConstructedWith($attrValidatorHelper, ['pim_catalog_image', 'pim_catalog_file'], ['STARTS WITH', 'ENDS WITH', 'CONTAINS', 'DOES NOT CONTAIN', '=', 'EMPTY']);
$this->setQueryBuilder($qb);
$qb->getRootAlias()->willReturn('p');
$qb->expr()->willReturn($expr);
$image->getId()->willReturn(1);
$image->getCode()->willReturn('picture');
$image->isLocalizable()->willReturn(false);
$image->isScopable()->willReturn(false);
$image->getBackendType()->willReturn('media');
}
示例9:
function it_normalizes_a_product_value_into_mongodb_document($mongoFactory, $serializer, ProductValueInterface $value, AttributeInterface $attribute, \MongoDBRef $mongoDBRef, \MongoId $mongoId)
{
$context = ['_id' => $mongoId, 'collection_name' => 'product'];
$mongoFactory->createMongoId()->willReturn($mongoId);
$mongoFactory->createMongoDBRef('product', $mongoId)->willReturn($mongoDBRef);
$attribute->getId()->willReturn(123);
$attribute->getBackendType()->willReturn('text');
$value->getAttribute()->willReturn($attribute);
$value->getData()->willReturn('my description');
$value->getLocale()->willReturn(null);
$value->getScope()->willReturn(null);
$this->normalize($value, 'mongodb_document', $context)->shouldReturn(['_id' => $mongoId, 'attribute' => 123, 'entity' => $mongoDBRef, 'text' => 'my description']);
}
示例10:
function it_sets_the_locale_and_scope_when_denormalizing_values($serializer, AttributeInterface $attribute)
{
$attribute->getAttributeType()->willReturn('pim_catalog_number');
$attribute->getBackendType()->willReturn('decimal');
$attribute->isLocalizable()->willReturn(true);
$attribute->isScopable()->willReturn(true);
$serializer->denormalize(1, 'pim_catalog_number', 'json', Argument::type('array'))->shouldBeCalled()->willReturn(1);
$value = $this->denormalize(['value' => 1, 'locale' => 'en_US', 'scope' => 'ecommerce'], 'Pim\\Bundle\\CatalogBundle\\Model\\ProductValue', 'json', ['attribute' => $attribute]);
$value->shouldBeAnInstanceOf('Pim\\Bundle\\CatalogBundle\\Model\\ProductValue');
$value->getData()->shouldReturn(1);
$value->getLocale()->shouldReturn('en_US');
$value->getScope()->shouldReturn('ecommerce');
}
示例11: addAttributeSorter
/**
* {@inheritdoc}
*/
public function addAttributeSorter(AttributeInterface $attribute, $direction, $locale = null, $scope = null)
{
$aliasPrefix = 'sorter';
$joinAlias = $aliasPrefix . 'V' . $attribute->getCode();
$backendType = $attribute->getBackendType();
// join to value
$condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
$this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
$joinAliasMetric = $aliasPrefix . 'M' . $attribute->getCode();
$this->qb->leftJoin($joinAlias . '.' . $backendType, $joinAliasMetric);
$this->qb->addOrderBy($joinAliasMetric . '.baseData', $direction);
$idField = $this->qb->getRootAlias() . '.id';
$this->qb->addOrderBy($idField);
return $this;
}
示例12:
function it_adds_a_sorter_to_the_query($qb, AttributeInterface $metric)
{
$metric->getId()->willReturn(42);
$metric->getCode()->willReturn('metric_code');
$metric->getBackendType()->willReturn('metric');
$metric->isLocalizable()->willReturn(false);
$metric->isScopable()->willReturn(false);
$condition = "sorterVmetric_code.attribute = 42";
$qb->getRootAlias()->willReturn('r');
$qb->leftJoin('r.values', 'sorterVmetric_code', 'WITH', $condition)->shouldBeCalled();
$qb->leftJoin('sorterVmetric_code.metric', 'sorterMmetric_code')->shouldBeCalled();
$qb->addOrderBy('sorterMmetric_code.baseData', 'DESC')->shouldBeCalled();
$qb->addOrderBy('r.id')->shouldBeCalled();
$this->addAttributeSorter($metric, 'DESC');
}
示例13: guessConstraints
/**
* {@inheritdoc}
*/
public function guessConstraints(AttributeInterface $attribute)
{
$constraints = array();
if ($attribute->isRequired()) {
$constraints[] = new Constraints\NotBlank();
}
switch ($attribute->getBackendType()) {
case AbstractAttributeType::BACKEND_TYPE_DATE:
$constraints[] = new Constraints\Date();
break;
case AbstractAttributeType::BACKEND_TYPE_DATETIME:
$constraints[] = new Constraints\DateTime();
break;
}
return $constraints;
}
示例14:
function it_adds_an_equal_filter_on_an_attribute_in_the_query($qb, $attrValidatorHelper, AttributeInterface $attribute, Expr $expr)
{
$attribute->getBackendType()->willReturn('backend_type');
$attribute->getCode()->willReturn('code');
$attribute->getId()->willReturn(42);
$attribute->isLocalizable()->willReturn(false);
$attribute->isScopable()->willReturn(false);
$attrValidatorHelper->validateLocale($attribute, Argument::any())->shouldBeCalled();
$attrValidatorHelper->validateScope($attribute, Argument::any())->shouldBeCalled();
$qb->expr()->willReturn($expr);
$qb->getRootAlias()->willReturn('p');
$expr->eq(Argument::any(), true)->willReturn('filtercode.backend_type = true');
$expr->literal(true)->willReturn(true);
$qb->innerJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalled();
$this->addAttributeFilter($attribute, '=', true);
}
示例15: Expr
function it_adds_an_attribute_sorter_to_the_query($qb, AttributeInterface $sku)
{
$sku->getId()->willReturn(42);
$sku->getCode()->willReturn('sku');
$sku->getBackendType()->willReturn('varchar');
$sku->isLocalizable()->willReturn(false);
$sku->isScopable()->willReturn(false);
$qb->expr()->willReturn(new Expr());
$qb->getRootAlias()->willReturn('p');
$qb->getDQLPart('join')->willReturn([]);
$qb->resetDQLPart('join')->shouldBeCalled();
$condition = "sorterVsku.attribute = 42";
$qb->leftJoin('p.values', 'sorterVsku', 'WITH', $condition)->shouldBeCalled();
$qb->addOrderBy('sorterVsku.varchar', 'DESC')->shouldBeCalled();
$qb->getRootAlias()->willReturn('p');
$qb->addOrderBy("p.id")->shouldBeCalled();
$this->addAttributeSorter($sku, 'DESC');
}