mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 02:36:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Grocy\Controllers;
 | |
| 
 | |
| use \Grocy\Services\RecipesService;
 | |
| 
 | |
| class RecipesApiController extends BaseApiController
 | |
| {
 | |
| 	public function __construct(\Slim\Container $container)
 | |
| 	{
 | |
| 		parent::__construct($container);
 | |
| 		$this->RecipesService = new RecipesService();
 | |
| 	}
 | |
| 
 | |
| 	protected $RecipesService;
 | |
| 
 | |
| 	public function AddNotFulfilledProductsToShoppingList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
 | |
| 	{
 | |
| 		$requestBody = $request->getParsedBody();
 | |
| 		$excludedProductIds = null;
 | |
| 
 | |
| 		if ($requestBody !== null && array_key_exists('excludedProductIds', $requestBody))
 | |
| 		{
 | |
| 			$excludedProductIds = $requestBody['excludedProductIds'];
 | |
| 		}
 | |
| 		
 | |
| 		$this->RecipesService->AddNotFulfilledProductsToShoppingList($args['recipeId'], $excludedProductIds);
 | |
| 		return $this->EmptyApiResponse($response);
 | |
| 	}
 | |
| 
 | |
| 	public function ConsumeRecipe(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
 | |
| 	{
 | |
| 		try
 | |
| 		{
 | |
| 			$this->RecipesService->ConsumeRecipe($args['recipeId']);
 | |
| 			return $this->EmptyApiResponse($response);
 | |
| 		}
 | |
| 		catch (\Exception $ex)
 | |
| 		{
 | |
| 			return $this->GenericErrorResponse($response, $ex->getMessage());
 | |
| 		}
 | |
| 	}
 | |
| }
 |