本文整理汇总了PHP中Pim\Component\Catalog\Model\AttributeInterface::isRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::isRequired方法的具体用法?PHP AttributeInterface::isRequired怎么用?PHP AttributeInterface::isRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Component\Catalog\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::isRequired方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guessConstraints
/**
* {@inheritdoc}
*/
public function guessConstraints(AttributeInterface $attribute)
{
$constraints = [];
if ($attribute->isRequired()) {
$constraints[] = new Assert\NotBlank();
}
return $constraints;
}
示例2:
function it_returns_not_blank_and_datetime_constraints(AttributeInterface $attribute)
{
$attribute->isRequired()->willReturn(true);
$attribute->getBackendType()->willReturn(AttributeTypes::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');
}
示例3: guessConstraints
/**
* {@inheritdoc}
*/
public function guessConstraints(AttributeInterface $attribute)
{
$constraints = [];
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;
}
示例4:
function it_does_not_guess_non_required(AttributeInterface $attribute)
{
$attribute->isRequired()->willReturn(false)->shouldBeCalled();
$constraints = $this->guessConstraints($attribute);
$constraints->shouldReturn([]);
}