/**
  * Creates current shopping list
  *
  * @param string $label
  *
  * @return ShoppingList
  */
 public function createCurrent($label = '')
 {
     $label = $label !== '' ? $label : $this->translator->trans('orob2b.shoppinglist.default.label');
     $shoppingList = new ShoppingList();
     $shoppingList->setOrganization($this->getAccountUser()->getOrganization())->setAccount($this->getAccountUser()->getAccount())->setAccountUser($this->getAccountUser())->setLabel($label);
     $this->setCurrent($this->getAccountUser(), $shoppingList);
     return $shoppingList;
 }
 /**
  * @param ObjectManager $manager
  * @param AccountUser   $accountUser
  * @param string        $label
  *
  * @return ShoppingList
  */
 protected function createShoppingList(ObjectManager $manager, AccountUser $accountUser, $label)
 {
     $shoppingList = new ShoppingList();
     $shoppingList->setOwner($accountUser);
     $shoppingList->setOrganization($accountUser->getOrganization());
     $shoppingList->setAccountUser($accountUser);
     $shoppingList->setAccount($accountUser->getCustomer());
     $shoppingList->setNotes('Some notes for ' . $label);
     $shoppingList->setLabel($label);
     $manager->persist($shoppingList);
 }
 /**
  * @param ObjectManager $manager
  * @param string        $name
  * @param AccountUser   $accountUser
  * @param bool          $isCurrent
  *
  * @return ShoppingList
  */
 protected function createShoppingList(ObjectManager $manager, AccountUser $accountUser, $name, $isCurrent = false)
 {
     $shoppingList = new ShoppingList();
     $shoppingList->setOrganization($accountUser->getOrganization());
     $shoppingList->setAccountUser($accountUser);
     $shoppingList->setAccount($accountUser->getAccount());
     $shoppingList->setLabel($name . '_label');
     $shoppingList->setNotes($name . '_notes');
     $shoppingList->setCurrent($isCurrent);
     $manager->persist($shoppingList);
     $this->addReference($name, $shoppingList);
     return $shoppingList;
 }
 /**
  * Create shopping list form
  *
  * @Route("/create", name="orob2b_shopping_list_frontend_create")
  * @Template("OroB2BShoppingListBundle:ShoppingList/Frontend:update.html.twig")
  * @Acl(
  *      id="orob2b_shopping_list_frontend_create",
  *      type="entity",
  *      class="OroB2BShoppingListBundle:ShoppingList",
  *      permission="CREATE",
  *      group_name="commerce"
  * )
  *
  * @param Request $request
  *
  * @return array|RedirectResponse
  */
 public function createAction(Request $request)
 {
     $shoppingList = new ShoppingList();
     /** @var AccountUser $accountUser */
     $accountUser = $this->getUser();
     $shoppingList->setOrganization($accountUser->getOrganization())->setAccount($accountUser->getAccount())->setAccountUser($accountUser);
     return $this->update($request, $shoppingList);
 }