本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\AttributeInterface::getDateMin方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeInterface::getDateMin方法的具体用法?PHP AttributeInterface::getDateMin怎么用?PHP AttributeInterface::getDateMin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Model\AttributeInterface
的用法示例。
在下文中一共展示了AttributeInterface::getDateMin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_adds_violation_when_date_min_is_not_valid($context, AttributeInterface $attribute, ValidDateRange $constraint)
{
$date = new \DateTime();
$attribute->getDateMin()->willReturn('not_a_date');
$attribute->getDateMax()->willReturn($date);
$context->addViolationAt('dateMin', $constraint->invalidDateMessage)->shouldBeCalled();
$this->validate($attribute, $constraint);
}
示例2: guessConstraints
/**
* {@inheritdoc}
*/
public function guessConstraints(AttributeInterface $attribute)
{
$constraints = array();
if ('pim_catalog_date' === $attribute->getAttributeType()) {
$min = $attribute->getDateMin();
$max = $attribute->getDateMax();
} else {
$min = $attribute->getNumberMin();
$max = $attribute->getNumberMax();
if (false === $attribute->isNegativeAllowed() && ($min === null || $min < 0)) {
$min = 0;
}
}
if (null !== $min || null !== $max) {
$constraints[] = new Range(array('min' => $min, 'max' => $max));
}
return $constraints;
}
示例3:
function it_does_not_guess_minmax_date(AttributeInterface $attribute)
{
$attribute->getAttributeType()->willReturn('pim_catalog_date');
$attribute->getDateMin()->willReturn(null);
$attribute->getDateMax()->willReturn(null);
$attribute->getNumberMin()->shouldNotBeCalled();
$attribute->getNumberMax()->shouldNotBeCalled();
$attribute->isNegativeAllowed()->shouldNotBeCalled();
$constraints = $this->guessConstraints($attribute);
$constraints->shouldReturn([]);
}
示例4: getVersionedData
/**
* Get extra data to store in version
*
* @param AttributeInterface $attribute
*
* @return array
*/
protected function getVersionedData(AttributeInterface $attribute)
{
$dateMin = is_null($attribute->getDateMin()) ? '' : $attribute->getDateMin()->format(\DateTime::ISO8601);
$dateMax = is_null($attribute->getDateMax()) ? '' : $attribute->getDateMax()->format(\DateTime::ISO8601);
return ['available_locales' => $this->normalizeAvailableLocales($attribute), 'localizable' => $attribute->isLocalizable(), 'scope' => $attribute->isScopable() ? self::CHANNEL_SCOPE : self::GLOBAL_SCOPE, 'options' => $this->normalizeOptions($attribute), 'sort_order' => (int) $attribute->getSortOrder(), 'required' => (int) $attribute->isRequired(), 'max_characters' => (string) $attribute->getMaxCharacters(), 'validation_rule' => (string) $attribute->getValidationRule(), 'validation_regexp' => (string) $attribute->getValidationRegexp(), 'wysiwyg_enabled' => (string) $attribute->isWysiwygEnabled(), 'number_min' => (string) $attribute->getNumberMin(), 'number_max' => (string) $attribute->getNumberMax(), 'decimals_allowed' => (string) $attribute->isDecimalsAllowed(), 'negative_allowed' => (string) $attribute->isNegativeAllowed(), 'date_min' => $dateMin, 'date_max' => $dateMax, 'metric_family' => (string) $attribute->getMetricFamily(), 'default_metric_unit' => (string) $attribute->getDefaultMetricUnit(), 'max_file_size' => (string) $attribute->getMaxFileSize()];
}