当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::getCustomClass方法代码示例

本文整理汇总了PHP中Object::getCustomClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getCustomClass方法的具体用法?PHP Object::getCustomClass怎么用?PHP Object::getCustomClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object的用法示例。


在下文中一共展示了Object::getCustomClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createSubmissionLogForArchivedOrders

 protected function createSubmissionLogForArchivedOrders()
 {
     $lastOrderStep = OrderStep::get()->sort("Sort", "DESC")->First();
     $submissionLogClassName = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
     $obj = $submissionLogClassName::create();
     if (!is_a($obj, Object::getCustomClass("OrderStatusLog"))) {
         user_error('EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order") refers to a class that is NOT an instance of OrderStatusLog');
     }
     $orderStatusLogClassName = "OrderStatusLog";
     $offset = 0;
     $orders = $this->getOrdersForCreateSubmissionLogForArchivedOrders($lastOrderStep, $orderStatusLogClassName, $offset);
     while ($orders->count()) {
         foreach ($orders as $order) {
             $isSubmitted = $submissionLogClassName::get()->Filter(array("OrderID" => $order->ID))->count();
             if (!$isSubmitted) {
                 $obj = $submissionLogClassName::create();
                 $obj->OrderID = $order->ID;
                 //it is important we add this here so that we can save the 'submitted' version.
                 //this is particular important for the Order Item Links.
                 $obj->write();
                 $obj->OrderAsHTML = $order->ConvertToHTML();
                 $obj->write();
                 DB::alteration_message("creating submission log for Order #" . $obj->OrderID, "created");
             }
         }
         $offset += 100;
         $orders = $this->getOrdersForCreateSubmissionLogForArchivedOrders($lastOrderStep, $orderStatusLogClassName, $offset);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:29,代码来源:EcommerceTaskArchiveAllOrdersWithItems.php

示例2: run

 function run($request)
 {
     $tables = array("ProductGroup", "ProductGroup_Live", "Product", "Product_Live");
     if (class_exists("ProductVariation")) {
         $tables[] = "ProductVariation";
     }
     //todo: make list based on buyables rather than hard-coded.
     foreach ($tables as $tableName) {
         $classErrorCount = 0;
         $removeCount = 0;
         $updateClassCount = 0;
         $rowCount = DB::query("SELECT COUNT(\"ImageID\") FROM \"{$tableName}\" WHERE ImageID > 0;")->value();
         DB::alteration_message("<h2><strong>CHECKING {$tableName} ( {$rowCount} records ):</strong></h2>");
         $rows = DB::query("SELECT \"ImageID\", \"{$tableName}\".\"ID\" FROM \"{$tableName}\" WHERE ImageID > 0;");
         if ($rows) {
             foreach ($rows as $row) {
                 $remove = false;
                 $classErrorCount += DB::query("\r\n\t\t\t\t\t\tSELECT COUNT (\"File\".\"ID\")\r\n\t\t\t\t\t\tFROM \"File\"\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\"File\".\"ID\" = " . $row["ImageID"] . "\r\n\t\t\t\t\t\t\tAND  (\r\n\t\t\t\t\t\t\t \"ClassName\" = 'Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = 'ProductVariation_Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = ''\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t")->value();
                 DB::query("\r\n\t\t\t\t\t\tUPDATE \"File\"\r\n\t\t\t\t\t\tSET \"ClassName\" = 'Product_Image'\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\"File\".\"ID\" = " . $row["ImageID"] . "\r\n\t\t\t\t\t\t\tAND  (\r\n\t\t\t\t\t\t\t \"ClassName\" = 'Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = 'ProductVariation_Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = ''\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t");
                 $image = Product_Image::get()->byID($row["ImageID"]);
                 if (!$image) {
                     $remove = true;
                 } elseif (!$image->getTag()) {
                     $remove = true;
                 }
                 if ($remove) {
                     $removeCount++;
                     DB::query("UPDATE \"{$tableName}\" SET \"ImageID\" = 0 WHERE \"{$tableName}\".\"ID\" = " . $row["ID"] . " AND \"{$tableName}\".\"ImageID\" = " . $row["ImageID"] . ";");
                 } elseif (!is_a($image, Object::getCustomClass("Product_Image"))) {
                     $updateClassCount++;
                     $image = $image->newClassInstance("Product_Image");
                     $image - write();
                 }
             }
         }
         if ($classErrorCount) {
             DB::alteration_message("<strong>{$tableName}:</strong> there were {$classErrorCount} files with the wrong class names.  These have been fixed.", "deleted");
         } else {
             DB::alteration_message("<strong>{$tableName}:</strong> there were no files with the wrong class names. ", "created");
         }
         if ($removeCount) {
             DB::alteration_message("<strong>{$tableName}:</strong> Removed {$removeCount} image(s) from products and variations because they do not exist in the file-system or database", "deleted");
         } else {
             DB::alteration_message("<strong>{$tableName}:</strong> All product images are accounted for", "created");
         }
         if ($updateClassCount) {
             DB::alteration_message("<strong>{$tableName}:</strong> {$removeCount} image(s) did not match the requirement 'instanceOF Product_Image', this has been corrected.", "deleted");
         } else {
             DB::alteration_message("<strong>{$tableName}:</strong> All product images instancesOF Product_Image", "created");
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:52,代码来源:EcommerceTaskProductImageReset.php

示例3: onBeforeInit

 /**
  * standard SS method.
  * Runs before the Page::init method is called.
  *
  */
 function onBeforeInit()
 {
     $this->secureHostSwitcher();
     Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
     //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js");
     //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
     //todo: check if we even need this (via ShoppingCartsRequirements.ss)
     if ($this->owner->dataRecord) {
         if (is_a($this->owner->dataRecord, Object::getCustomClass("Product")) || is_a($this->owner->dataRecord, Object::getCustomClass("ProductGroup"))) {
             Session::set("ContinueShoppingLink", $this->owner->Link());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:18,代码来源:EcommerceSiteTreeExtension.php

示例4: doStep

 /**
  * Add a member to the order - in case he / she is not a shop admin.
  *
  * @param Order object
  * @return Boolean - true if run correctly.
  **/
 public function doStep(Order $order)
 {
     if (!$order->IsSubmitted()) {
         $className = $this->getRelevantLogEntryClassName();
         if (class_exists($className)) {
             //add currency if needed.
             $order->getHasAlternativeCurrency();
             $obj = $className::create();
             if (is_a($obj, Object::getCustomClass("OrderStatusLog"))) {
                 $obj->OrderID = $order->ID;
                 $obj->Title = $this->Name;
                 //it is important we add this here so that we can save the 'submitted' version.
                 //this is particular important for the Order Item Links.
                 //order write will also update all the OrderAttributes!
                 $obj->write();
                 $obj = OrderStatusLog::get()->byID($obj->ID);
                 $saved = false;
                 if ($this->SaveOrderAsSerializedObject) {
                     $obj->OrderAsString = $order->ConvertToString();
                     $saved = true;
                 }
                 if ($this->SaveOrderAsHTML || !$saved) {
                     $obj->OrderAsHTML = Convert::raw2sql($order->ConvertToHTML());
                 }
                 $obj->write();
             } else {
                 user_error('EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order") refers to a class that is NOT an instance of OrderStatusLog');
             }
         } else {
             user_error('EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order") refers to a non-existing class');
         }
         $order->LastEdited = "'" . SS_Datetime::now()->Rfc2822() . "'";
         //add member if needed...
         if (!$order->MemberID) {
             //lets see if we can find a member
             $memberOrderID = Session::get("Ecommerce_Member_For_Order");
             Session::clear("Ecommerce_Member_For_Order");
             Session::set("Ecommerce_Member_For_Order", 0);
             Session::save();
             if ($memberOrderID) {
                 $order->MemberID = $memberOrderID;
             }
         }
         $order->write($showDebug = false, $forceInsert = false, $forceWrite = true);
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:53,代码来源:OrderStep_Submitted.php

示例5: PageTypes

 /**
  * @return ArrayList
  */
 public function PageTypes()
 {
     $pageTypes = parent::PageTypes();
     $result = new ArrayList();
     $productClass = Object::getCustomClass("Product");
     $productGroupClass = Object::getCustomClass("Product");
     $acceptedClasses1 = ClassInfo::subclassesFor("ProductGroup");
     $acceptedClasses1[$productClass] = $productClass;
     $acceptedClasses2 = ClassInfo::subclassesFor($productGroupClass);
     $acceptedClasses2[$productGroupClass] = $productGroupClass;
     $acceptedClasses = $acceptedClasses1 + $acceptedClasses2;
     foreach ($pageTypes as $type) {
         if (in_array($type->ClassName, $acceptedClasses)) {
             $result->push($type);
         }
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:21,代码来源:CMSPageAddController_Products.php

示例6: __construct

 /**
  *@param $object - the buyable / OrderItem
  **/
 function __construct($object, $parameters = null)
 {
     Requirements::javascript("ecommerce/javascript/EcomQuantityField.js");
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if ($object instanceof BuyableModel) {
         $this->orderItem = ShoppingCart::singleton()->findOrMakeItem($object, $parameters);
         //provide a 0-quantity facade item if there is no such item in cart OR perhaps we should just store the product itself, and do away with the facade, as it might be unnecessary complication
         if (!$this->orderItem) {
             $className = $object->classNameForOrderItem();
             $this->orderItem = new $className($object->dataRecord, 0);
         }
     } elseif (is_a($object, Object::getCustomClass("OrderItem")) && $object->BuyableID) {
         $this->orderItem = $object;
     } else {
         user_error("EcomQuantityField: no/bad order item or buyable passed to constructor.", E_USER_WARNING);
     }
     $this->parameters = $parameters;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:21,代码来源:EcomQuantityField.php

示例7: run

 function run($request)
 {
     $arrayOfBuyables = EcommerceConfig::get("EcommerceDBConfig", "array_of_buyables");
     foreach ($arrayOfBuyables as $buyable) {
         $allproducts = $buyable::get();
         if ($allproducts->count()) {
             foreach ($allproducts as $product) {
                 DB::alteration_message("Deleting " . $product->ClassName . " ID = " . $product->ID, "deleted");
                 if (is_a($product, Object::getCustomClass("SiteTree"))) {
                     $product->deleteFromStage('Live');
                     $product->deleteFromStage('Stage');
                 } else {
                     $product->delete();
                 }
                 $product->destroy();
                 //TODO: remove versions
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:20,代码来源:EcommerceTaskDeleteProducts.php

示例8: dataObj

 public function dataObj()
 {
     if (is_numeric($this->itemID) && is_numeric($this->versionID)) {
         return Versioned::get_version(ClassInfo::baseDataClass(Object::getCustomClass($this->ctf->sourceClass())), $this->itemID, $this->versionID);
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-repeatorders,代码行数:6,代码来源:VersionedComplexTableField.php

示例9: get_members_by_permission

 /**
  * Returns all members for a specific permission.
  * 
  * @param $code String|array Either a single permission code, or a list of permission codes
  * @return DataObjectSet Returns a set of member that have the specified
  *                       permission.
  */
 public static function get_members_by_permission($code)
 {
     $toplevelGroups = self::get_groups_by_permission($code);
     if (!$toplevelGroups) {
         return false;
     }
     $groupIDs = array();
     foreach ($toplevelGroups as $group) {
         $familyIDs = $group->collateFamilyIDs();
         if (is_array($familyIDs)) {
             $groupIDs = array_merge($groupIDs, array_values($familyIDs));
         }
     }
     if (!count($groupIDs)) {
         return false;
     }
     $members = DataObject::get(Object::getCustomClass('Member'), $_filter = "\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")", $_sort = "", $_join = "LEFT JOIN \"Group_Members\" ON \"Member\".\"ID\" = \"Group_Members\".\"MemberID\" " . "LEFT JOIN \"Group\" ON \"Group_Members\".\"GroupID\" = \"Group\".\"ID\" ");
     return $members;
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:26,代码来源:Permission.php

示例10: addtogroup

	/**
	 * Add existing member to group rather than creating a new member
	 */
	function addtogroup() {
		$data = $_REQUEST;
		unset($data['ID']);
		$ctfID = isset($data['ctf']) ? $data['ctf']['ID'] : null;

		if(!is_numeric($ctfID)) {
			FormResponse::status_messsage(_t('MemberTableField.ADDINGFIELD', 'Adding failed'), 'bad');
		}

		$className = Object::getCustomClass($this->stat('data_class'));
		$record = new $className();

		$record->update($data);
		
		$valid = $record->validate();

		if($valid->valid()) {
			$record->write();
			$record->Groups()->add($ctfID);

			$this->sourceItems();

			// TODO add javascript to highlight added row (problem: might not show up due to sorting/filtering)
			FormResponse::update_dom_id($this->id(), $this->renderWith($this->template), true);
			FormResponse::status_message(_t('MemberTableField.ADDEDTOGROUP','Added member to group'), 'good');
		
		} else {
			FormResponse::status_message(Convert::raw2xml("I couldn't add that user to this group:\n\n" . $valid->starredlist()), 'bad');
		}

		return FormResponse::respond();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:35,代码来源:MemberTableField.php

示例11: create

 /**
  *
  * @param string $object
  *					A string representation of the class to create
  * @param array $params
  *					An array of parameters to be passed to the constructor
  */
 public function create($class, $params = array())
 {
     $class = Object::getCustomClass($class);
     $reflector = new ReflectionClass($class);
     return $reflector->newInstanceArgs($params);
 }
开发者ID:jareddreyer,项目名称:catalogue,代码行数:13,代码来源:SilverStripeInjectionCreator.php

示例12: addEcommerceDBConfigToConfigs

 /**
  * Adding EcommerceDBConfig values
  */
 protected function addEcommerceDBConfigToConfigs()
 {
     $ecommerceDBConfig = EcommerceDBConfig::current_ecommerce_db_config();
     $fields = $ecommerceDBConfig->fieldLabels();
     if ($fields) {
         foreach ($fields as $field => $description) {
             if ($field != "Title" && $field != "UseThisOne") {
                 $defaultsDefaults = $ecommerceDBConfig->stat("defaults");
                 $this->definitions["EcommerceDBConfig"][$field] = "{$description}. <br />see: <a href=\"/admin/shop/EcommerceDBConfig/EditForm/field/EcommerceDBConfig/item/" . $ecommerceDBConfig->ID . "/edit\">Ecommerce Configuration</a>";
                 $this->configs["EcommerceDBConfig"][$field] = $ecommerceDBConfig->{$field};
                 $this->databaseValues["EcommerceDBConfig"][$field] = true;
                 $this->defaults["EcommerceDBConfig"][$field] = isset($defaultsDefaults[$field]) ? $defaultsDefaults[$field] : "no default set";
                 $imageField = $field . "ID";
                 if (isset($ecommerceDBConfig->{$imageField})) {
                     if ($image = $ecommerceDBConfig->{$field}()) {
                         if ($image->exists() && is_a($image, Object::getCustomClass("Image"))) {
                             $this->configs["EcommerceDBConfig"][$field] = "[Image]  --- <img src=\"" . $image->Link() . "\" />";
                             $this->databaseValues["EcommerceDBConfig"][$field] = true;
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:28,代码来源:EcommerceTaskCheckConfiguration.php

示例13: hasSameContent

 /**
  * Check if two Order Items are the same.
  * Useful when adding two items to cart.
  *
  * @param OrderItem $orderItem
  * @return Boolean
  **/
 function hasSameContent(OrderItem $orderItem)
 {
     return is_a($orderItem, Object::getCustomClass("OrderItem")) && $this->BuyableID == $orderItem->BuyableID && $this->BuyableClassName == $orderItem->BuyableClassName && $this->Version == $orderItem->Version;
 }
开发者ID:abhibavishi,项目名称:silverstripe-ecommerce,代码行数:11,代码来源:OrderItem.php

示例14: FillWithLastAddressFromMember

 /**
  *@todo: are there times when the Shipping rather than the Billing address should be linked?
  * Copies the last address used by the member.
  *
  * @param Object (Member) $member
  * @param Boolean $write - should the address be written
  * @return DataObject (OrderAddress / ShippingAddress / BillingAddress)
  **/
 public function FillWithLastAddressFromMember(Member $member, $write = false)
 {
     $excludedFields = array("ID", "OrderID");
     $fieldPrefix = $this->fieldPrefix();
     if ($member && $member->exists()) {
         $oldAddress = $member->previousOrderAddress($this->baseClassLinkingToOrder(), $this->ID);
         if ($oldAddress) {
             $fieldNameArray = $this->getFieldNameArray($fieldPrefix);
             foreach ($fieldNameArray as $field) {
                 if (in_array($field, $excludedFields)) {
                     //do nothing
                 } elseif ($this->{$field}) {
                     //do nothing
                 } elseif (isset($oldAddress->{$field})) {
                     $this->{$field} = $oldAddress->{$field};
                 }
             }
         }
         //copy data from  member
         if (is_a($this, Object::getCustomClass("BillingAddress"))) {
             $this->Email = $member->Email;
         }
         $fieldNameArray = array("FirstName" => $fieldPrefix . "FirstName", "Surname" => $fieldPrefix . "Surname");
         foreach ($fieldNameArray as $memberField => $fieldName) {
             //NOTE, we always override the Billing Address (which does not have a fieldPrefix)
             if (!$this->{$fieldName} || is_a($this, Object::getCustomClass("BillingAddress"))) {
                 $this->{$fieldName} = $member->{$memberField};
             }
         }
     }
     if ($write) {
         $this->write();
     }
     return $this;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:43,代码来源:OrderAddress.php

示例15: importMembers

 /**
  * Import members from the uploaded file
  */
 protected function importMembers($id, $group, $cols, $setFields, $primaryColType = 'Email')
 {
     $startTime = time();
     $importData = Session::get("ImportFile.{$id}");
     $validColumns = array_keys(RecipientImportField::$column_types);
     $columnMap = array_flip($cols);
     // Debug::show($columnMap);
     // locate the primary column's index
     $primaryColumn = $columnMap[$primaryColType];
     // changed fields
     $changedFields = array();
     // intersect the list of valid columns with the column map to find the columns we need
     $importColumns = array_intersect($validColumns, $cols);
     // statistics
     $newMembers = 0;
     $changedMembers = 0;
     $skippedMembers = 0;
     // the class that the imported members will become
     $newMemberClass = Object::getCustomClass('Member');
     // for each row, add a new member or overwrite an existing member
     foreach ($importData as $newMemberRow) {
         // skip rows with an empty value for the primary column
         if (empty($newMemberRow[$primaryColumn])) {
             $skippedMembers++;
             continue;
         }
         // remember to check if the user has unsubscribed
         $trackChanges = true;
         // TODO: Write DataObject::update
         $member = $this->findMember($newMemberRow[$primaryColumn]);
         if (!$member) {
             $newMembers++;
             $trackChanges = false;
             $member = Object::create("Member");
         } else {
             // skip this member if the are unsubscribed
             if ($member->Unsubscribed) {
                 $skippedMembers++;
                 continue;
             }
             if ($member->class != $newMemberClass) {
                 $member->setClassName($newMemberClass);
             }
             $changedMembers++;
         }
         // add each of the valid columns
         foreach ($importColumns as $datum) {
             // perform any required conversions
             $newValue = trim($newMemberRow[$columnMap[$datum]]);
             $oldValue = trim($member->{$datum});
             // Debug::message( "$datum@{$columnMap[$datum]}" );
             // track the modifications to the member data
             if ($trackChanges && $newValue != $oldValue && $datum != $primaryColumn) {
                 $changedFields[] = array($newMemberRow[$primaryColumn], "{$datum}:\n{$oldValue}", "{$datum}:\n{$newValue}");
                 $numChangedFields++;
             }
             $member->{$datum} = $newValue;
         }
         // set any set fields
         if ($setFields) {
             foreach ($setFields as $fieldName => $fieldValue) {
                 $member->{$fieldName} = $fieldValue;
             }
         }
         // add member to group
         $member->write();
         $member->Groups()->add($group->ID);
     }
     $numChangedFields = count($changedFields);
     $this->notifyChanges($changedFields);
     // TODO Refresh window
     $customData = array('ID' => $id, "UploadForm" => $this->controller->UploadForm($id), 'ImportMessage' => 'Imported new members', 'NewMembers' => (string) $newMembers, 'ChangedMembers' => (string) $changedMembers, 'ChangedFields' => (string) $numChangedFields, 'SkippedRecords' => (string) $skippedMembers, 'Time' => time() - $startTime);
     return $this->customise($customData)->renderWith('Newsletter_RecipientImportField');
 }
开发者ID:nyeholt,项目名称:silverstripe-newsletter,代码行数:77,代码来源:RecipientImportField.php


注:本文中的Object::getCustomClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。