本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface::valueExists方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductRepositoryInterface::valueExists方法的具体用法?PHP ProductRepositoryInterface::valueExists怎么用?PHP ProductRepositoryInterface::valueExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface
的用法示例。
在下文中一共展示了ProductRepositoryInterface::valueExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_checks_value_existence(ProductRepositoryInterface $productRepository, ProductValueInterface $value)
{
$productRepository->valueExists($value)->willReturn(true);
$this->valueExists($value)->shouldReturn(true);
$productRepository->valueExists($value)->willReturn(false);
$this->valueExists($value)->shouldReturn(false);
}
示例2: checkUniqueValues
/**
* Checks the uniqueness of product values that should be unique
* As the uniqueness check is normally executed against the database
* and imported products have not been persisted yet, this effectively
* checks that the items in the current batch don't contain duplicate values
* for unique attributes.
*
* @param object $entity
* @param array $columnsInfo
* @param array $data
*
* @throws DuplicateProductValueException When duplicate values are encountered
*/
protected function checkUniqueValues($entity, array $columnsInfo, array $data)
{
foreach ($columnsInfo as $columnInfo) {
if ($columnInfo->getAttribute()) {
$value = $this->getProductValue($entity, $columnInfo);
if ($value->getAttribute()->isUnique()) {
$code = $value->getAttribute()->getCode();
$valueData = (string) $value;
if ($valueData !== '') {
if ($this->productRepository->valueExists($value)) {
throw new DuplicateProductValueException($code, $valueData, $data);
}
$this->uniqueValues[$code] = isset($this->uniqueValues[$code]) ? $this->uniqueValues[$code] : [];
if (isset($this->uniqueValues[$code][$valueData])) {
throw new DuplicateProductValueException($code, $valueData, $data);
} else {
$this->uniqueValues[$code][$valueData] = "";
}
}
}
}
}
}
示例3: valueExists
/**
* Check if a product value with a specific value already exists
*
* @param ProductValueInterface $value
*
* @return bool
*
* @deprecated will be removed in 1.5, please use ProductRepositoryInterface::valueExists
*/
public function valueExists(ProductValueInterface $value)
{
return $this->productRepository->valueExists($value);
}
示例4:
function it_does_not_validate_with_empty_value(ProductRepositoryInterface $productRepository, ProductValueInterface $value, ExecutionContextInterface $context, Constraint $constraint)
{
$productRepository->valueExists($value)->shouldNotBeCalled();
$context->buildViolation(Argument::any())->shouldNotBeCalled();
$this->validate("", $constraint)->shouldReturn(null);
}
示例5: alreadyExists
/**
* @param ProductValueInterface $productValue
*
* @return bool
*/
protected function alreadyExists(ProductValueInterface $productValue)
{
return $this->repository->valueExists($productValue);
}