本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface::findOneByWithValues方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductRepositoryInterface::findOneByWithValues方法的具体用法?PHP ProductRepositoryInterface::findOneByWithValues怎么用?PHP ProductRepositoryInterface::findOneByWithValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Repository\ProductRepositoryInterface
的用法示例。
在下文中一共展示了ProductRepositoryInterface::findOneByWithValues方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findProductOr404
/**
* Find a product by its id or return a 404 response
*
* @param string $id the product id
*
* @throws NotFoundHttpException
*
* @return ProductInterface
*/
protected function findProductOr404($id)
{
$product = $this->productRepository->findOneByWithValues($id);
if (!$product) {
throw new NotFoundHttpException(sprintf('Product with id %s could not be found.', (string) $id));
}
return $product;
}
示例2: addCurrentProduct
/**
* Inject current product in the datagrid configuration
*/
protected function addCurrentProduct()
{
$path = $this->getSourcePath(self::CURRENT_PRODUCT_KEY);
$id = $this->requestParams->get('product', null);
$product = null !== $id ? $this->productRepository->findOneByWithValues($id) : null;
$this->configuration->offsetSetByPath($path, $product);
}
示例3: getCurrentProduct
/**
* @return ProductInterface
*/
protected function getCurrentProduct()
{
$productId = $this->extractor->getDatagridParameter('product');
if (!$productId) {
throw new \LogicException('The current product type must be configured');
}
$product = $this->productRepository->findOneByWithValues($productId);
return $product;
}
示例4: findProductOr404
/**
* Find a product by its id or return a 404 response
*
* @param string $id the product id
*
* @throws NotFoundHttpException
*
* @return ProductInterface
*/
protected function findProductOr404($id)
{
$product = $this->productRepository->findOneByWithValues($id);
$product = $this->objectFilter->filterObject($product, 'pim.internal_api.product.view') ? null : $product;
if (!$product) {
throw new NotFoundHttpException(sprintf('Product with id %s could not be found.', $id));
}
return $product;
}
示例5: findPrevious
/**
* Find previous sequential edit entity
*
* @param SequentialEdit $sequentialEdit
* @param int $currentKey
*
* @return null|ProductInterface
*/
protected function findPrevious(SequentialEdit $sequentialEdit, $currentKey)
{
$previous = null;
$objectSet = $sequentialEdit->getObjectSet();
while ($currentKey-- > 0 && null === $previous) {
$previous = $this->productRepository->findOneByWithValues($objectSet[$currentKey]);
}
return $previous;
}
示例6: findProductOr404
/**
* Find a product by its id or return a 404 response
*
* @param int $id the product id
*
* @throws NotFoundHttpException
*
* @return ProductInterface
*/
protected function findProductOr404($id)
{
$product = $this->productRepository->findOneByWithValues($id);
if (!$product) {
throw $this->createNotFoundException(sprintf('Product with id %s could not be found.', (string) $id));
}
// With this version of the form we need to add missing values from family
$this->productBuilder->addMissingProductValues($product);
$this->productBuilder->addMissingAssociations($product);
return $product;
}
示例7: find
/**
* Find a product by id
* Also ensure that it contains all required values
*
* @param int $id
*
* @deprecated will be removed in 1.6
*
* @return ProductInterface|null
*/
public function find($id)
{
$product = $this->productRepository->findOneByWithValues($id);
return $product;
}