本文整理汇总了PHP中Pimcore\File::getValidFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getValidFilename方法的具体用法?PHP File::getValidFilename怎么用?PHP File::getValidFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\File
的用法示例。
在下文中一共展示了File::getValidFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processHtml
/**
* @param $body
* @return mixed
*/
public static function processHtml($body)
{
$processedPaths = array();
preg_match_all("@\\<link[^>]*(rel=\"stylesheet/less\")[^>]*\\>@msUi", $body, $matches);
if (is_array($matches)) {
foreach ($matches[0] as $tag) {
preg_match("/href=\"([^\"]+)*\"/", $tag, $href);
if (array_key_exists(1, $href) && !empty($href[1])) {
$source = $href[1];
$source = preg_replace("/\\?_dc=[\\d]+/", "", $source);
if (is_file(PIMCORE_ASSET_DIRECTORY . $source)) {
$path = PIMCORE_ASSET_DIRECTORY . $source;
} else {
if (is_file(PIMCORE_DOCUMENT_ROOT . $source)) {
$path = PIMCORE_DOCUMENT_ROOT . $source;
}
}
// add the same file only one time
if (in_array($path, $processedPaths)) {
continue;
}
$newFile = PIMCORE_TEMPORARY_DIRECTORY . "/less___" . File::getValidFilename(str_replace(".less", "", $source)) . "-" . filemtime($path) . ".css";
if (!is_file($newFile)) {
$compiledContent = self::compile($path, $source);
File::put($newFile, $compiledContent);
}
$body = str_replace($tag, str_replace("stylesheet/less", "stylesheet", str_replace($source, str_replace(PIMCORE_DOCUMENT_ROOT, "", $newFile), $tag)), $body);
}
}
}
return $body;
}
示例2: setName
/**
* @param string $name
* @return $this|void
* @throws DAV\Exception\Forbidden
* @throws \Exception
*/
function setName($name)
{
if ($this->asset->isAllowed("rename")) {
$user = AdminTool::getCurrentUser();
$this->asset->setUserModification($user->getId());
$this->asset->setFilename(\Pimcore\File::getValidFilename($name));
$this->asset->save();
} else {
throw new DAV\Exception\Forbidden();
}
return $this;
}
示例3: move
/**
* Moves a file/directory
*
* @param string $sourcePath
* @param string $destinationPath
* @return void
*/
public function move($sourcePath, $destinationPath)
{
$nameParts = explode("/", $sourcePath);
$nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
$sourcePath = implode("/", $nameParts);
$nameParts = explode("/", $destinationPath);
$nameParts[count($nameParts) - 1] = File::getValidFilename($nameParts[count($nameParts) - 1]);
$destinationPath = implode("/", $nameParts);
try {
if (dirname($sourcePath) == dirname($destinationPath)) {
$asset = null;
if ($asset = Asset::getByPath("/" . $destinationPath)) {
// If we got here, this means the destination exists, and needs to be overwritten
$sourceAsset = Asset::getByPath("/" . $sourcePath);
$asset->setData($sourceAsset->getData());
$sourceAsset->delete();
}
// see: Asset\WebDAV\File::delete() why this is necessary
$log = Asset\WebDAV\Service::getDeleteLog();
if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
$asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
if ($asset) {
$sourceAsset = Asset::getByPath("/" . $sourcePath);
$asset->setData($sourceAsset->getData());
$sourceAsset->delete();
}
}
if (!$asset) {
$asset = Asset::getByPath("/" . $sourcePath);
}
$asset->setFilename(basename($destinationPath));
} else {
$asset = Asset::getByPath("/" . $sourcePath);
$parent = Asset::getByPath("/" . dirname($destinationPath));
$asset->setPath($parent->getFullPath() . "/");
$asset->setParentId($parent->getId());
}
$user = \Pimcore\Tool\Admin::getCurrentUser();
$asset->setUserModification($user->getId());
$asset->save();
} catch (\Exception $e) {
\Logger::error($e);
}
}
示例4: importProcessAction
public function importProcessAction()
{
$success = true;
$parentId = $this->getParam("parentId");
$job = $this->getParam("job");
$id = $this->getParam("id");
$mappingRaw = \Zend_Json::decode($this->getParam("mapping"));
$class = Object\ClassDefinition::getById($this->getParam("classId"));
$skipFirstRow = $this->getParam("skipHeadRow") == "true";
$fields = $class->getFieldDefinitions();
$file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
// currently only csv supported
// determine type
$dialect = Tool\Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
$count = 0;
if (($handle = fopen($file, "r")) !== false) {
$data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
}
if ($skipFirstRow && $job == 1) {
//read the next row, we need to skip the head row
$data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
}
$tmpFile = $file . "_tmp";
$tmpHandle = fopen($tmpFile, "w+");
while (!feof($handle)) {
$buffer = fgets($handle);
fwrite($tmpHandle, $buffer);
}
fclose($handle);
fclose($tmpHandle);
unlink($file);
rename($tmpFile, $file);
// prepare mapping
foreach ($mappingRaw as $map) {
if ($map[0] !== "" && $map[1] && !empty($map[2])) {
$mapping[$map[2]] = $map[0];
} else {
if ($map[1] == "published (system)") {
$mapping["published"] = $map[0];
} else {
if ($map[1] == "type (system)") {
$mapping["type"] = $map[0];
}
}
}
}
// create new object
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
$className = Tool::getModelClassMapping($className);
$parent = Object::getById($this->getParam("parentId"));
$objectKey = "object_" . $job;
if ($this->getParam("filename") == "id") {
$objectKey = null;
} else {
if ($this->getParam("filename") != "default") {
$objectKey = File::getValidFilename($data[$this->getParam("filename")]);
}
}
$overwrite = false;
if ($this->getParam("overwrite") == "true") {
$overwrite = true;
}
if ($parent->isAllowed("create")) {
$intendedPath = $parent->getFullPath() . "/" . $objectKey;
if ($overwrite) {
$object = Object::getByPath($intendedPath);
if (!$object instanceof Object\Concrete) {
//create new object
$object = new $className();
} else {
if ($object instanceof Object\Concrete and !$object instanceof $className) {
//delete the old object it is of a different class
$object->delete();
$object = new $className();
} else {
if ($object instanceof Object\Folder) {
//delete the folder
$object->delete();
$object = new $className();
} else {
//use the existing object
}
}
}
} else {
$counter = 1;
while (Object::getByPath($intendedPath) != null) {
$objectKey .= "_" . $counter;
$intendedPath = $parent->getFullPath() . "/" . $objectKey;
$counter++;
}
$object = new $className();
}
$object->setClassId($this->getParam("classId"));
$object->setClassName($this->getParam("className"));
$object->setParentId($this->getParam("parentId"));
$object->setKey($objectKey);
$object->setCreationDate(time());
$object->setUserOwner($this->getUser()->getId());
$object->setUserModification($this->getUser()->getId());
//.........这里部分代码省略.........
示例5: objectFormAction
public function objectFormAction()
{
$success = false;
// getting parameters is very easy ... just call $this->getParam("yorParamKey"); regardless if's POST or GET
if ($this->getParam("firstname") && $this->getParam("lastname") && $this->getParam("email") && $this->getParam("terms")) {
$success = true;
// for this example the class "person" and "inquiry" is used
// first we create a person, then we create an inquiry object and link them together
// check for an existing person with this name
$person = Object\Person::getByEmail($this->getParam("email"), 1);
if (!$person) {
// if there isn't an existing, ... create one
$filename = \Pimcore\File::getValidFilename($this->getParam("email"));
// first we need to create a new object, and fill some system-related information
$person = new Object\Person();
$person->setParent(Object::getByPath("/crm/inquiries"));
// we store all objects in /crm
$person->setKey($filename);
// the filename of the object
$person->setPublished(true);
// yep, it should be published :)
// of course this needs some validation here in production...
$person->setGender($this->getParam("gender"));
$person->setFirstname($this->getParam("firstname"));
$person->setLastname($this->getParam("lastname"));
$person->setEmail($this->getParam("email"));
$person->setDateRegister(new \DateTime());
$person->save();
}
// now we create the inquiry object and link the person in it
$inquiryFilename = \Pimcore\File::getValidFilename(date("Y-m-d") . "~" . $person->getEmail());
$inquiry = new Object\Inquiry();
$inquiry->setParent(Object::getByPath("/inquiries"));
// we store all objects in /inquiries
$inquiry->setKey($inquiryFilename);
// the filename of the object
$inquiry->setPublished(true);
// yep, it should be published :)
// now we fill in the data
$inquiry->setMessage($this->getParam("message"));
$inquiry->setPerson($person);
$inquiry->setDate(new \DateTime());
$inquiry->setTerms((bool) $this->getParam("terms"));
$inquiry->save();
} elseif ($this->getRequest()->isPost()) {
$this->view->error = true;
}
// do some validation & assign the parameters to the view
foreach (["firstname", "lastname", "email", "message", "terms"] as $key) {
if ($this->getParam($key)) {
$this->view->{$key} = htmlentities(strip_tags($this->getParam($key)));
}
}
// assign the status to the view
$this->view->success = $success;
}
示例6: importUrlAction
public function importUrlAction()
{
$success = true;
$data = Tool::getHttpData($this->getParam("url"));
$filename = basename($this->getParam("url"));
$parentId = $this->getParam("id");
$parentAsset = Asset::getById(intval($parentId));
$filename = File::getValidFilename($filename);
$filename = $this->getSafeFilename($parentAsset->getFullPath(), $filename);
if (empty($filename)) {
throw new \Exception("The filename of the asset is empty");
}
// check for duplicate filename
$filename = $this->getSafeFilename($parentAsset->getFullPath(), $filename);
if ($parentAsset->isAllowed("create")) {
$asset = Asset::create($parentId, array("filename" => $filename, "data" => $data, "userOwner" => $this->user->getId(), "userModification" => $this->user->getId()));
$success = true;
} else {
\Logger::debug("prevented creating asset because of missing permissions");
}
$this->_helper->json(array("success" => $success));
}
示例7: getUniqueKey
/**
* @param $item \Pimcore\Model\Asset
* @param int $nr
* @return string
* @throws \Exception
*/
public static function getUniqueKey($item, $nr = 0)
{
$list = new Listing();
$key = \Pimcore\File::getValidFilename($item->getKey());
if (!$key) {
throw new \Exception("No item key set.");
}
if ($nr) {
if ($item->getType() == 'folder') {
$key = $key . '_' . $nr;
} else {
$keypart = substr($key, 0, strrpos($key, '.'));
$extension = str_replace($keypart, '', $key);
$key = $keypart . '_' . $nr . $extension;
}
}
$parent = $item->getParent();
if (!$parent) {
throw new \Exception("You have to set a parent folder to determine a unique Key");
}
if (!$item->getId()) {
$list->setCondition('parentId = ? AND `filename` = ? ', [$parent->getId(), $key]);
} else {
$list->setCondition('parentId = ? AND `filename` = ? AND id != ? ', [$parent->getId(), $key, $item->getId()]);
}
$check = $list->loadIdList();
if (!empty($check)) {
$nr++;
$key = self::getUniqueKey($item, $nr);
}
return $key;
}
示例8: createFolderByPath
/**
* @param $path
* @param array $options
* @return null
* @throws \Exception
*/
public static function createFolderByPath($path, $options = array())
{
$calledClass = get_called_class();
if ($calledClass == __CLASS__) {
throw new \Exception("This method must be called from a extended class. e.g Asset\\Service, Object\\Service, Document\\Service");
}
$type = str_replace('\\Service', '', $calledClass);
$type = "\\" . ltrim($type, "\\");
$folderType = $type . '\\Folder';
$lastFolder = null;
$pathsArray = array();
$parts = explode('/', $path);
$parts = array_filter($parts, "\\Pimcore\\Model\\Element\\Service::filterNullValues");
$sanitizedPath = "/";
foreach ($parts as $part) {
$sanitizedPath = $sanitizedPath . File::getValidFilename($part) . "/";
}
if (!($foundElement = $type::getByPath($sanitizedPath))) {
foreach ($parts as $part) {
$pathsArray[] = $pathsArray[count($pathsArray) - 1] . '/' . File::getValidFilename($part);
}
for ($i = 0; $i < count($pathsArray); $i++) {
$currentPath = $pathsArray[$i];
if (!$type::getByPath($currentPath) instanceof $type) {
$parentFolderPath = $i == 0 ? '/' : $pathsArray[$i - 1];
$parentFolder = $type::getByPath($parentFolderPath);
$folder = new $folderType();
$folder->setParent($parentFolder);
if ($parentFolder) {
$folder->setParentId($parentFolder->getId());
} else {
$folder->setParentId(1);
}
$key = substr($currentPath, strrpos($currentPath, '/') + 1, strlen($currentPath));
if (method_exists($folder, 'setKey')) {
$folder->setKey($key);
}
if (method_exists($folder, 'setFilename')) {
$folder->setFilename($key);
}
if (method_exists($folder, 'setType')) {
$folder->setType('folder');
}
$folder->setPath($currentPath);
$folder->setUserModification(0);
$folder->setUserOwner(1);
$folder->setCreationDate(time());
$folder->setModificationDate(time());
$folder->setValues($options);
$folder->save();
$lastFolder = $folder;
}
}
} else {
return $foundElement;
}
return $lastFolder;
}
示例9: getValidFilenameAction
public function getValidFilenameAction()
{
$this->_helper->json(array("filename" => File::getValidFilename($this->getParam("value"))));
}
示例10: createOrderItem
/**
* @param \OnlineShop_Framework_ICartItem $item
* @param OnlineShop_Framework_AbstractOrder |OnlineShop_Framework_AbstractOrderItem $parent
*
* @return OnlineShop_Framework_AbstractOrderItem
* @throws Exception
* @throws OnlineShop_Framework_Exception_UnsupportedException
*/
protected function createOrderItem(OnlineShop_Framework_ICartItem $item, $parent)
{
$orderItemListClass = $this->orderItemClass . "_List";
if (!class_exists($orderItemListClass)) {
throw new Exception("Class {$orderItemListClass} does not exist.");
}
$key = \Pimcore\File::getValidFilename($item->getProduct()->getId() . "_" . $item->getItemKey());
$orderItemList = new $orderItemListClass();
$orderItemList->setCondition("o_parentId = ? AND o_key = ?", array($parent->getId(), $key));
$orderItems = $orderItemList->load();
if (count($orderItems) > 1) {
throw new Exception("No unique order item found for {$key}.");
}
if (count($orderItems) == 1) {
$orderItem = $orderItems[0];
} else {
$orderItem = $this->getNewOrderItemObject();
$orderItem->setParent($parent);
$orderItem->setPublished(true);
$orderItem->setKey($key);
}
$orderItem->setAmount($item->getCount());
$orderItem->setProduct($item->getProduct());
if ($item->getProduct()) {
$orderItem->setProductName($item->getProduct()->getOSName());
$orderItem->setProductNumber($item->getProduct()->getOSProductNumber());
}
$orderItem->setComment($item->getComment());
$price = 0;
if (is_object($item->getTotalPrice())) {
$price = $item->getTotalPrice()->getAmount();
}
$orderItem->setTotalPrice($price);
// save active pricing rules
$priceInfo = $item->getPriceInfo();
if ($priceInfo instanceof OnlineShop_Framework_Pricing_IPriceInfo && method_exists($orderItem, 'setPricingRules')) {
$priceRules = new \Pimcore\Model\Object\Fieldcollection();
foreach ($priceInfo->getRules() as $rule) {
$priceRule = new \Pimcore\Model\Object\Fieldcollection\Data\PricingRule();
$priceRule->setRuleId($rule->getId());
$priceRule->setName($rule->getName());
$priceRules->add($priceRule);
}
$orderItem->setPricingRules($priceRules);
$orderItem->save();
}
return $orderItem;
}
示例11: subscribe
/**
* @param $params
* @return mixed
* @throws \Exception
*/
public function subscribe($params)
{
$onlyCreateVersion = false;
$className = $this->getClassName();
$object = new $className();
// check for existing e-mail
$existingObject = $className::getByEmail($params["email"], 1);
if ($existingObject) {
// if there's an existing user with this email address, do not overwrite the contents, but create a new
// version which will be published as soon as the contact gets verified (token/email)
$object = $existingObject;
$onlyCreateVersion = true;
//throw new \Exception("email address '" . $params["email"] . "' already exists");
}
if (!array_key_exists("email", $params)) {
throw new \Exception("key 'email' is a mandatory parameter");
}
$object->setValues($params);
if (!$object->getParentId()) {
$object->setParentId(1);
}
$object->setNewsletterActive(true);
$object->setCreationDate(time());
$object->setModificationDate(time());
$object->setUserModification(0);
$object->setUserOwner(0);
$object->setPublished(true);
$object->setKey(\Pimcore\File::getValidFilename($object->getEmail() . "~" . substr(uniqid(), -3)));
if (!$onlyCreateVersion) {
$object->save();
}
// generate token
$token = base64_encode(\Zend_Json::encode(["salt" => md5(microtime()), "email" => $object->getEmail(), "id" => $object->getId()]));
$token = str_replace("=", "~", $token);
// base64 can contain = which isn't safe in URL's
$object->setProperty("token", "text", $token);
if (!$onlyCreateVersion) {
$object->save();
} else {
$object->saveVersion(true, true);
}
$this->addNoteOnObject($object, "subscribe");
return $object;
}
示例12: setName
/**
* @param string $name
* @return $this|void
* @throws DAV\Exception\Forbidden
* @throws \Exception
*/
function setName($name)
{
if ($this->asset->isAllowed("rename")) {
$this->asset->setFilename(File::getValidFilename($name));
$this->asset->save();
} else {
throw new DAV\Exception\Forbidden();
}
return $this;
}
示例13: addAction
public function addAction()
{
$success = false;
$errorMessage = "";
// check for permission
$parentDocument = Document::getById(intval($this->getParam("parentId")));
if ($parentDocument->isAllowed("create")) {
$intendedPath = $parentDocument->getRealFullPath() . "/" . $this->getParam("key");
if (!Document\Service::pathExists($intendedPath)) {
$createValues = ["userOwner" => $this->getUser()->getId(), "userModification" => $this->getUser()->getId(), "published" => false];
$createValues["key"] = File::getValidFilename($this->getParam("key"));
// check for a docType
$docType = Document\DocType::getById(intval($this->getParam("docTypeId")));
if ($docType) {
$createValues["template"] = $docType->getTemplate();
$createValues["controller"] = $docType->getController();
$createValues["action"] = $docType->getAction();
$createValues["module"] = $docType->getModule();
} elseif ($this->getParam("translationsBaseDocument")) {
$translationsBaseDocument = Document::getById($this->getParam("translationsBaseDocument"));
$createValues["template"] = $translationsBaseDocument->getTemplate();
$createValues["controller"] = $translationsBaseDocument->getController();
$createValues["action"] = $translationsBaseDocument->getAction();
$createValues["module"] = $translationsBaseDocument->getModule();
} elseif ($this->getParam("type") == "page" || $this->getParam("type") == "snippet" || $this->getParam("type") == "email") {
$createValues["controller"] = Config::getSystemConfig()->documents->default_controller;
$createValues["action"] = Config::getSystemConfig()->documents->default_action;
}
if ($this->getParam("inheritanceSource")) {
$createValues["contentMasterDocumentId"] = $this->getParam("inheritanceSource");
}
switch ($this->getParam("type")) {
case "page":
$document = Document\Page::create($this->getParam("parentId"), $createValues, false);
$document->setTitle($this->getParam('title', null));
$document->setProperty("navigation_name", "text", $this->getParam('name', null), false);
$document->save();
$success = true;
break;
case "snippet":
$document = Document\Snippet::create($this->getParam("parentId"), $createValues);
$success = true;
break;
case "email":
//ckogler
$document = Document\Email::create($this->getParam("parentId"), $createValues);
$success = true;
break;
case "link":
$document = Document\Link::create($this->getParam("parentId"), $createValues);
$success = true;
break;
case "hardlink":
$document = Document\Hardlink::create($this->getParam("parentId"), $createValues);
$success = true;
break;
case "folder":
$document = Document\Folder::create($this->getParam("parentId"), $createValues);
$document->setPublished(true);
try {
$document->save();
$success = true;
} catch (\Exception $e) {
$this->_helper->json(["success" => false, "message" => $e->getMessage()]);
}
break;
default:
$classname = "\\Pimcore\\Model\\Document\\" . ucfirst($this->getParam("type"));
// this is the fallback for custom document types using prefixes
// so we need to check if the class exists first
if (!\Pimcore\Tool::classExists($classname)) {
$oldStyleClass = "\\Document_" . ucfirst($this->getParam("type"));
if (\Pimcore\Tool::classExists($oldStyleClass)) {
$classname = $oldStyleClass;
}
}
if (Tool::classExists($classname)) {
$document = $classname::create($this->getParam("parentId"), $createValues);
try {
$document->save();
$success = true;
} catch (\Exception $e) {
$this->_helper->json(["success" => false, "message" => $e->getMessage()]);
}
break;
} else {
\Logger::debug("Unknown document type, can't add [ " . $this->getParam("type") . " ] ");
}
break;
}
} else {
$errorMessage = "prevented adding a document because document with same path+key [ {$intendedPath} ] already exists";
\Logger::debug($errorMessage);
}
} else {
$errorMessage = "prevented adding a document because of missing permissions";
\Logger::debug($errorMessage);
}
if ($success) {
if ($this->getParam("translationsBaseDocument")) {
//.........这里部分代码省略.........
示例14: checkoutAction
public function checkoutAction()
{
$id_customer = $_POST['id_customer'];
$return_array = array();
try {
// get cart open
$carts = new Object\Carts\Listing();
$carts->setCondition("Customer__id = " . $id_customer . " and Status = 'open'");
$carts->setLimit(1);
$cart = array();
if ($carts->Count() > 0) {
foreach ($carts as $c) {
$cart = $c;
}
// count detail on cart
$carts_detail = new Object\CartsDetail\Listing();
$carts_detail->setCondition("Carts__id = " . $cart->o_id);
$n_detail = $carts_detail->count();
if ($n_detail > 0) {
// get object customer
$customer = Object::getById($id_customer);
$now = date("Y-m-d,H-i");
$get_time_now = new Pimcore_Date($now);
$newOrder = Object\Orders::create();
$newOrder->setKey(\Pimcore\File::getValidFilename('order_' . $id_customer . '_' . $now));
//to get and set ID PARENT FOLDER
$id_folder = new Object_List();
$id_folder->setCondition("o_key='orders-management'");
$o_Pid = 0;
foreach ($id_folder as $parent) {
$oidParent = $parent->getO_id();
}
$newOrder->setParentId($oidParent);
$newOrder->setCarts($cart);
$newOrder->setCustomer($customer);
$newOrder->setOrderDate($get_time_now);
$newOrder->setPublished(1);
$newOrder->save();
//Set log checkout cart
$base_url = Website_P1GlobalFunction::getBaseUrl();
$url_api = $base_url . '/core/log/set';
$id_activity = Website_P1GlobalFunction::getActivities("customer_checkout_cart");
$array_object = json_encode(array("id_order" => $newOrder->o_id));
$data = array("user" => $id_customer, "activities" => $id_activity, "object" => $array_object);
$setLogCheckout = json_decode(Website_P1GlobalFunction::CallAPI("post", $url_api, $data));
$cart->setstatus("close");
$cart->save();
//Set log close cart
$id_activity = Website_P1GlobalFunction::getActivities("customer_close_cart");
$array_object = json_encode(array("id_cart" => $cart->o_id));
$data = array("user" => $id_customer, "activities" => $id_activity, "object" => $array_object);
$setLogClose = json_decode(Website_P1GlobalFunction::CallAPI("post", $url_api, $data));
if ($setLogClose->status == "Success" && $setLogCheckout->status == "Success") {
$return_data = json_encode(array("id_cart" => $cart->o_id, "id_order" => $newOrder->o_id));
$return_array['status'] = 'success';
$return_array['message'] = 'success';
$return_array['data'] = $return_data;
} else {
$return_array['status'] = 'Failed';
$return_array['message'] = 'Failed checkout cart';
$return_array['data'] = '';
}
} else {
$return_array['status'] = 'failed';
$return_array['message'] = 'Cart is empty';
$return_array['data'] = '';
}
} else {
$return_array['status'] = 'failed';
$return_array['message'] = 'Customer not have cart open';
$return_array['data'] = '';
}
} catch (Exception $ex) {
$return_array['status'] = 'failed';
$return_array['message'] = 'Internal service error';
$return_array['data'] = '';
}
$return_json = $this->_helper->json($return_array);
$this->sendResponse($return_json);
}
示例15: getReview
protected function getReview(Object\OnlineShopConfiguration $configuration, $uid, $email, $creationDate)
{
$db = \Pimcore\Resource::get();
$list = new Object\TrustedShopReview\Listing();
$list->setCondition("uid = " . $db->quote($uid));
$list->setLimit(1);
$list->setUnpublished(true);
$list = $list->load();
if ($list) {
$item = $list[0];
} else {
$item = new Object\TrustedShopReview();
$item->setPublished(1);
}
$item->setKey(Pimcore\File::getValidFilename($email . "_" . $uid));
return $item;
}