当前位置: 首页>>代码示例>>PHP>>正文


PHP AttributeInterface::isRequired方法代码示例

本文整理汇总了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;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:11,代码来源:NotBlankGuesser.php

示例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');
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:9,代码来源:AttributeConstraintGuesserSpec.php

示例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;
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:19,代码来源:AttributeConstraintGuesser.php

示例4:

 function it_does_not_guess_non_required(AttributeInterface $attribute)
 {
     $attribute->isRequired()->willReturn(false)->shouldBeCalled();
     $constraints = $this->guessConstraints($attribute);
     $constraints->shouldReturn([]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:6,代码来源:NotBlankGuesserSpec.php


注:本文中的Pim\Component\Catalog\Model\AttributeInterface::isRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。