protected function WishlistController::getFormObject in Commerce Wishlist 8.3
Gets the form object for the given operation.
Parameters
string $operation: The operation.
Return value
\Drupal\Core\Entity\EntityFormInterface The form object.
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Thrown if no wishlist with the code specified in the URL could be found.
2 calls to WishlistController::getFormObject()
- WishlistController::shareForm in src/
Controller/ WishlistController.php - Builds the share form.
- WishlistController::userForm in src/
Controller/ WishlistController.php - Builds the user form.
File
- src/
Controller/ WishlistController.php, line 187
Class
- WishlistController
- Provides the wishlist pages.
Namespace
Drupal\commerce_wishlist\ControllerCode
protected function getFormObject($operation) {
$code = $this->routeMatch
->getRawParameter('code');
/** @var \Drupal\commerce_wishlist\WishlistStorageInterface $wishlist_storage */
$wishlist_storage = $this->entityTypeManager
->getStorage('commerce_wishlist');
$wishlist = $wishlist_storage
->loadByCode($code);
if (!$wishlist) {
throw new NotFoundHttpException();
}
$form_object = $this->entityTypeManager
->getFormObject('commerce_wishlist', $operation);
$form_object
->setEntity($wishlist);
return $form_object;
}