Inheritance: extends AbstractObject
Example #1
1
 /**
  * @param array $data
  * @return \Zend_Filter_Input
  * @throws \Exception
  */
 public function register(array $data)
 {
     $argv = compact('data');
     $results = \Pimcore::getEventManager()->triggerUntil('member.register.validate', $this, $argv, function ($v) {
         return $v instanceof \Zend_Filter_Input;
     });
     $input = $results->last();
     if (!$input instanceof \Zend_Filter_Input) {
         throw new \Exception('No validate listener attached to "member.register.validate" event');
     }
     if (!$input->isValid()) {
         return $input;
     }
     try {
         $this->setValues($input->getUnescaped());
         $this->setRole($this->getClass()->getFieldDefinition('role')->getDefaultValue());
         $this->setKey(str_replace('@', '_at_', $this->getEmail()));
         $this->setParent(Folder::getByPath('/' . ltrim(Config::get('auth')->adapter->objectPath, '/')));
         $this->save();
         \Pimcore::getEventManager()->trigger('member.register.post', $this);
     } catch (\Exception $e) {
         if ($this->getId()) {
             $this->delete();
         }
         throw $e;
     }
     return $input;
 }
Example #2
0
 /**
  * @param string $path
  */
 public function removeObjectFolder($path)
 {
     $folder = Folder::getByPath($path);
     if ($folder) {
         $folder->delete();
     }
 }
 public function addFolderAction()
 {
     $success = false;
     $parent = Object::getById($this->getParam("parentId"));
     if ($parent->isAllowed("create")) {
         if (!Object\Service::pathExists($parent->getFullPath() . "/" . $this->getParam("key"))) {
             $folder = Object\Folder::create(array("o_parentId" => $this->getParam("parentId"), "o_creationDate" => time(), "o_userOwner" => $this->user->getId(), "o_userModification" => $this->user->getId(), "o_key" => $this->getParam("key"), "o_published" => true));
             $folder->setCreationDate(time());
             $folder->setUserOwner($this->getUser()->getId());
             $folder->setUserModification($this->getUser()->getId());
             try {
                 $folder->save();
                 $success = true;
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         }
     } else {
         \Logger::debug("prevented creating object id because of missing permissions");
     }
     $this->_helper->json(array("success" => $success));
 }
 public function removeFolders()
 {
     $blogFolder = Folder::getByPath('/coreshop');
     if ($blogFolder) {
         $blogFolder->delete();
     }
 }
 /**
  * @param OnlineShop_Framework_ICart $cart
  *
  * @return OnlineShop_Framework_AbstractOrder
  * @throws Exception
  * @throws OnlineShop_Framework_Exception_UnsupportedException
  */
 public function getOrCreateOrder(OnlineShop_Framework_ICart $cart)
 {
     $orderListClass = $this->orderClass . "_List";
     if (!\Pimcore\Tool::classExists($orderListClass)) {
         throw new Exception("Class {$orderListClass} does not exist.");
     }
     $cartId = get_class($cart) . "_" . $cart->getId();
     $orderList = new $orderListClass();
     $orderList->setCondition("cartId = ?", array($cartId));
     $orders = $orderList->load();
     if (count($orders) > 1) {
         throw new Exception("No unique order found for {$cartId}.");
     }
     if (count($orders) == 1) {
         $order = $orders[0];
     } else {
         //No Order found, create new one
         $tempOrdernumber = $this->createOrderNumber();
         $order = $this->getNewOrderObject();
         $order->setParent(\Pimcore\Model\Object\Folder::getById($this->parentFolderId));
         $order->setCreationDate(Zend_Date::now()->get());
         $order->setKey($tempOrdernumber);
         $order->setPublished(true);
         $order->setOrdernumber($tempOrdernumber);
         $order->setOrderdate(Zend_Date::now());
         $order->setCartId($cartId);
     }
     //check if pending payment. if one, do not update order from cart
     $orderAgent = OnlineShop_Framework_Factory::getInstance()->getOrderManager()->createOrderAgent($order);
     $paymentInfo = $orderAgent->startPayment(false);
     if ($paymentInfo) {
         return $order;
     }
     //update order from cart
     $order->setTotalPrice($cart->getPriceCalculator()->getGrandTotal()->getAmount());
     $modificationItems = new \Pimcore\Model\Object\Fieldcollection();
     foreach ($cart->getPriceCalculator()->getPriceModifications() as $name => $modification) {
         $modificationItem = new \Pimcore\Model\Object\Fieldcollection\Data\OrderPriceModifications();
         $modificationItem->setName($modification->getDescription() ? $modification->getDescription() : $name);
         $modificationItem->setAmount($modification->getAmount());
         $modificationItems->add($modificationItem);
     }
     $order->setPriceModifications($modificationItems);
     $env = OnlineShop_Framework_Factory::getInstance()->getEnvironment();
     //sets customer to order - if available
     // TODO refactor
     if (@\Pimcore\Tool::classExists("\\Pimcore\\Model\\Object\\Customer")) {
         $customer = \Pimcore\Model\Object\Customer::getById($env->getCurrentUserId());
         $order->setCustomer($customer);
     }
     // set order currency
     $currency = $cart->getPriceCalculator()->getGrandTotal()->getCurrency();
     $order->setCurrency($currency->getShortName());
     $order->save();
     //for each cart item and cart sub item create corresponding order items
     $orderItems = array();
     $i = 0;
     foreach ($cart->getItems() as $item) {
         $i++;
         $orderItem = $this->createOrderItem($item, $order);
         $orderItem->save();
         $subItems = $item->getSubItems();
         if (!empty($subItems)) {
             $orderSubItems = array();
             foreach ($subItems as $subItem) {
                 $orderSubItem = $this->createOrderItem($subItem, $orderItem);
                 $orderSubItem->save();
                 $orderSubItems[] = $orderSubItem;
             }
             $orderItem->setSubItems($orderSubItems);
             $orderItem->save();
         }
         $orderItems[] = $orderItem;
     }
     $order->setItems($orderItems);
     return $order;
 }
 private static function createObjects()
 {
     try {
         $objectFolder = AbstractObject::getByPath(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT);
         if (!is_object($objectFolder)) {
             $objectFolder = new Folder();
             $objectFolder->setKey(basename(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT));
             $objectFolder->setParent(AbstractObject::getByPath(dirname(Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT)));
             $objectFolder->save();
         }
         if (!$objectFolder instanceof Folder) {
             throw new \Exception('Can not use object path [' . Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT . '] as default participation folder.');
         }
     } catch (\Exception $exception) {
         throw new \Exception('Unable to create/use participation folder [' . Plugin::CONFIG_OBJECTFOLDERPATH_DEFAULT . ']: ' . $exception->getMessage());
     }
 }
Example #7
-1
 /**
  * @return OnlineShop_OfferTool_AbstractOffer
  * @throws Exception
  */
 protected function getNewOfferObject($tempOfferNumber)
 {
     if (!class_exists($this->offerClass)) {
         throw new Exception("Offer Class" . $this->offerClass . " does not exist.");
     }
     $offer = new $this->offerClass();
     /**
      * @var $offer OnlineShop_OfferTool_AbstractOffer
      */
     $offer->setParent(\Pimcore\Model\Object\Folder::getByPath($this->parentFolderPath));
     $offer->setCreationDate(Zend_Date::now()->get());
     $offer->setKey($tempOfferNumber);
     $offer->setPublished(true);
     $offer->setDateCreated(Zend_Date::now());
     return $offer;
 }