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


PHP DataObject类代码示例

本文整理汇总了PHP中DataObject的典型用法代码示例。如果您正苦于以下问题:PHP DataObject类的具体用法?PHP DataObject怎么用?PHP DataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handle

 function handle(DataObject $model)
 {
     $db = DB::Instance();
     $query = 'SELECT max(complaint_number) FROM ' . $model->getTableName() . ' WHERE usercompanyid=' . EGS_COMPANY_ID . ' AND "type"=' . $db->qstr($model->type);
     $current = $db->GetOne($query);
     return $current + 1;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:ComplaintNumberHandler.php

示例2: testAuthorizationPolicy

 /**
  * @covers AuthorizationPolicy
  */
 public function testAuthorizationPolicy()
 {
     $policy = new AuthorizationPolicy('some message');
     // Test advice.
     self::assertTrue($policy->hasAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
     self::assertFalse($policy->hasAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
     self::assertEquals('some message', $policy->getAdvice(AUTHORIZATION_ADVICE_DENY_MESSAGE));
     self::assertNull($policy->getAdvice(AUTHORIZATION_ADVICE_CALL_ON_DENY));
     // Test authorized context objects.
     self::assertFalse($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
     $someContextObject = new DataObject();
     $someContextObject->setData('test1', 'test1');
     $policy->addAuthorizedContextObject(ASSOC_TYPE_USER_GROUP, $someContextObject);
     self::assertTrue($policy->hasAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
     self::assertEquals($someContextObject, $policy->getAuthorizedContextObject(ASSOC_TYPE_USER_GROUP));
     self::assertEquals(array(ASSOC_TYPE_USER_GROUP => $someContextObject), $policy->getAuthorizedContext());
     // Test authorized context.
     $someOtherContextObject = new DataObject();
     $someOtherContextObject->setData('test2', 'test2');
     $authorizedContext = array(ASSOC_TYPE_USER_GROUP => $someOtherContextObject);
     $policy->setAuthorizedContext($authorizedContext);
     self::assertEquals($authorizedContext, $policy->getAuthorizedContext());
     // Test default policies.
     self::assertTrue($policy->applies());
     self::assertEquals(AUTHORIZATION_DENY, $policy->effect());
 }
开发者ID:mczirfusz,项目名称:pkp-lib,代码行数:29,代码来源:AuthorizationPolicyTest.php

示例3: convert

 public function convert(DataObject $object)
 {
     if ($object->hasMethod('toFilteredMap')) {
         return Convert::raw2json($object->toFilteredMap());
     }
     return Convert::raw2json($object->toMap());
 }
开发者ID:helpfulrobot,项目名称:silverstripe-webservices,代码行数:7,代码来源:DataObjectJsonConverter.php

示例4: getColumnContent

 /**
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  *
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     // No permission checks - handled through GridFieldDetailForm
     // which can make the form readonly if no edit permissions are available.
     $data = new ArrayData(array('Link' => $record->CMSEditLink()));
     return $data->renderWith('GridFieldEditButton');
 }
开发者ID:micmania1,项目名称:silverstripe-lumberjack,代码行数:14,代码来源:GridFieldSiteTreeEditButton.php

示例5: getColumnContent

 /**
  *
  * @param \GridField $gridField
  * @param \DataObject $record
  * @param string $columnName
  * @return string|null - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record instanceof \Payment) {
         return null;
     }
     if (!$record->canRefund()) {
         return null;
     }
     \Requirements::css('omnipay-ui/css/omnipay-ui-cms.css');
     \Requirements::javascript('omnipay-ui/javascript/omnipay-ui-cms.js');
     \Requirements::add_i18n_javascript('omnipay-ui/javascript/lang');
     $infoText = '';
     switch (GatewayInfo::refundMode($record->Gateway)) {
         case GatewayInfo::MULTIPLE:
             $infoText = 'MultiRefundInfo';
             break;
         case GatewayInfo::PARTIAL:
             $infoText = 'SingleRefundInfo';
             break;
         case GatewayInfo::FULL:
             $infoText = 'FullRefundInfo';
             break;
     }
     /** @var \Money $money */
     $money = $record->dbObject('Money');
     /** @var \GridField_FormAction $field */
     $field = \GridField_FormAction::create($gridField, 'RefundPayment' . $record->ID, false, 'refundpayment', array('RecordID' => $record->ID))->addExtraClass('gridfield-button-refund payment-dialog-button')->setAttribute('title', _t('GridFieldRefundAction.Title', 'Refund Payment'))->setAttribute('data-icon', 'button-refund')->setAttribute('data-dialog', json_encode(array('maxAmount' => $money->Nice(), 'maxAmountNum' => $money->getAmount(), 'hasAmountField' => $record->canRefund(null, true), 'infoTextKey' => $infoText, 'buttonTextKey' => 'RefundAmount')))->setDescription(_t('GridFieldRefundAction.Description', 'Refund a captured payment'));
     return $field->Field();
 }
开发者ID:bummzack,项目名称:silverstripe-omnipay-ui,代码行数:36,代码来源:GridFieldRefundAction.php

示例6: scaffoldFormField

 public function scaffoldFormField($title = null, $params = null)
 {
     if (empty($this->object)) {
         return null;
     }
     $relationName = substr($this->name, 0, -2);
     $hasOneClass = $this->object->hasOneComponent($relationName);
     if (empty($hasOneClass)) {
         return null;
     }
     $hasOneSingleton = singleton($hasOneClass);
     if ($hasOneSingleton instanceof File) {
         $field = new UploadField($relationName, $title);
         if ($hasOneSingleton instanceof Image) {
             $field->setAllowedFileCategories('image/supported');
         }
         return $field;
     }
     // Build selector / numeric field
     $titleField = $hasOneSingleton->hasField('Title') ? "Title" : "Name";
     $list = DataList::create($hasOneClass);
     // Don't scaffold a dropdown for large tables, as making the list concrete
     // might exceed the available PHP memory in creating too many DataObject instances
     if ($list->count() < 100) {
         $field = new DropdownField($this->name, $title, $list->map('ID', $titleField));
         $field->setEmptyString(' ');
     } else {
         $field = new NumericField($this->name, $title);
     }
     return $field;
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:31,代码来源:ForeignKey.php

示例7: testGetLinks

 public function testGetLinks()
 {
     $dataObject = new DataObject(array(), array(), array('mockLinkRel' => 'mockLinkUri'));
     $expect = array('mockLinkRel' => 'mockLinkUri');
     $actual = $dataObject->getLinks();
     $this->assertEquals($expect, $actual);
 }
开发者ID:bigpoint,项目名称:slim-bootstrap,代码行数:7,代码来源:DataObjectTest.php

示例8: walkRelationshipChain

 protected function walkRelationshipChain(DataObject $from, ArrayList $list, array $parts, $lastPart, $lastItem)
 {
     $part = array_shift($parts);
     if (!$from->hasMethod($part)) {
         // error, no such part of relationship chain
         return false;
     }
     if (count($parts)) {
         foreach ($from->{$part}() as $item) {
             $this->walkRelationshipChain($item, $list, $parts, $part, $item);
         }
     } else {
         $images = $from->{$part}()->toNestedArray();
         // mark the images with a source from relationship and ID
         /** @var Image $image */
         foreach ($images as &$image) {
             if ($lastItem instanceof Variation) {
                 $options = $lastItem->Options();
                 foreach ($options as $option) {
                     $image['ProductID'] = $lastItem->Product()->ID;
                     $image['VariationID'] = $lastItem->ID;
                     $image['OptionID'] = $option->ID;
                     $image['AttributeID'] = $option->AttributeID;
                 }
             }
         }
         $list->merge(new ArrayList($images));
     }
     return true;
 }
开发者ID:swipestreak,项目名称:gallery,代码行数:30,代码来源:Page.php

示例9: scaffoldFormField

 public function scaffoldFormField($title = null, $params = null)
 {
     if (empty($this->object)) {
         return null;
     }
     $relationName = substr($this->name, 0, -2);
     $hasOneClass = $this->object->hasOneComponent($relationName);
     if ($hasOneClass && singleton($hasOneClass) instanceof Image) {
         $field = new UploadField($relationName, $title);
         $field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     } elseif ($hasOneClass && singleton($hasOneClass) instanceof File) {
         $field = new UploadField($relationName, $title);
     } else {
         $titleField = singleton($hasOneClass)->hasField('Title') ? "Title" : "Name";
         $list = DataList::create($hasOneClass);
         // Don't scaffold a dropdown for large tables, as making the list concrete
         // might exceed the available PHP memory in creating too many DataObject instances
         if ($list->count() < 100) {
             $field = new DropdownField($this->name, $title, $list->map('ID', $titleField));
             $field->setEmptyString(' ');
         } else {
             $field = new NumericField($this->name, $title);
         }
     }
     return $field;
 }
开发者ID:sledziator,项目名称:silverstripe-framework,代码行数:26,代码来源:ForeignKey.php

示例10: alchemise

 /**
  * Automatically extracts and replaces the category, keywords and entities
  * for a data object.
  *
  * @param DataObject $object
  */
 public function alchemise(DataObject $object)
 {
     if (!$object->hasExtension('Alchemisable')) {
         throw new Exception('The object must have the Alchemisable extension.');
     }
     $text = $object->getContentForAlchemy();
     if (strlen($text) < $this->charLimit) {
         return;
     }
     $alchemyInfo = $object->AlchemyMetadata->getValues();
     if (!$alchemyInfo) {
         $alchemyInfo = array();
     }
     $cat = $this->getCategoryFor($text);
     $keywords = $this->getKeywordsFor($text);
     $entities = $this->getEntitiesFor($text);
     $alchemyInfo['Category'] = $cat;
     $alchemyInfo['Keywords'] = $keywords;
     $alchemyInfo['Entities'] = $entities;
     $object->AlchemyMetadata = $alchemyInfo;
     //		foreach (Alchemisable::entity_fields() as $field => $name) {
     //			$name = substr($field, 3);
     //
     //			if (array_key_exists($name, $entities)) {
     //				$object->$field = $entities[$name];
     //			} else {
     //				$object->$field = array();
     //			}
     //		}
 }
开发者ID:nyeholt,项目名称:silverstripe-alchemiser,代码行数:36,代码来源:AlchemyService.php

示例11: notifyCommentRecipient

 /**
  * Send comment notification to a given recipient
  *
  * @param Comment $comment
  * @param DataObject $parent Object with the {@see CommentNotifiable} extension applied
  * @param Member|string $recipient Either a member object or an email address to which notifications should be sent
  */
 public function notifyCommentRecipient($comment, $parent, $recipient)
 {
     $subject = $parent->notificationSubject($comment, $recipient);
     $sender = $parent->notificationSender($comment, $recipient);
     $template = $parent->notificationTemplate($comment, $recipient);
     // Validate email
     // Important in case of the owner being a default-admin or a username with no contact email
     $to = $recipient instanceof Member ? $recipient->Email : $recipient;
     if (!$this->isValidEmail($to)) {
         return;
     }
     // Prepare the email
     $email = new Email();
     $email->setSubject($subject);
     $email->setFrom($sender);
     $email->setTo($to);
     $email->setTemplate($template);
     $email->populateTemplate(array('Parent' => $parent, 'Comment' => $comment, 'Recipient' => $recipient));
     if ($recipient instanceof Member) {
         $email->populateTemplate(array('ApproveLink' => $comment->ApproveLink($recipient), 'HamLink' => $comment->HamLink($recipient), 'SpamLink' => $comment->SpamLink($recipient), 'DeleteLink' => $comment->DeleteLink($recipient)));
     }
     // Until invokeWithExtensions supports multiple arguments
     if (method_exists($this->owner, 'updateCommentNotification')) {
         $this->owner->updateCommentNotification($email, $comment, $recipient);
     }
     $this->owner->extend('updateCommentNotification', $email, $comment, $recipient);
     return $email->send();
 }
开发者ID:silverstripe,项目名称:comment-notifications,代码行数:35,代码来源:CommentNotifier.php

示例12: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if ($this->removeRelation) {
         $field = GridField_FormAction::create($gridField, 'UnlinkRelation' . $record->ID, false, "unlinkrelation", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-unlink')->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink"))->setAttribute('data-icon', 'chain--minus');
     } else {
         if (!$record->canDelete()) {
             return;
         }
         $field = GridField_FormAction::create($gridField, 'DeleteRecord' . $record->ID, false, "deleterecord", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-delete')->setAttribute('title', _t('GridAction.Delete', "Delete"))->setAttribute('data-icon', 'cross-circle')->setDescription(_t('GridAction.DELETE_DESCRIPTION', 'Delete'));
     }
     //add a class to the field to if it is the last gridfield in the list
     $numberOfRelations = $record->Pages()->Count();
     $field->addExtraClass('dms-delete')->setAttribute('data-pages-count', $numberOfRelations)->removeExtraClass('gridfield-button-delete');
     //remove the base gridfield behaviour
     //set a class telling JS what kind of warning to display when clicking the delete button
     if ($numberOfRelations > 1) {
         $field->addExtraClass('dms-delete-link-only');
     } else {
         $field->addExtraClass('dms-delete-last-warning');
     }
     //set a class to show if the document is hidden
     if ($record->isHidden()) {
         $field->addExtraClass('dms-document-hidden');
     }
     return $field->Field();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dms,代码行数:33,代码来源:DMSGridFieldDeleteAction.php

示例13: usedBy

 public static function usedBy($search_data = null, &$errors = array(), $defaults = null, $params = array())
 {
     $search = new SelectorItemSearch($defaults);
     $search->addSearchField('target_id', 'Target', 'hidden', '', 'hidden');
     // Search by Product
     $config = SelectorCollection::getTypeDetails($params['type']);
     $search->addSearchField('parent_id', implode('/', $config['itemFields']), 'treesearch', -1, 'basic');
     if (empty($search_data)) {
         $search_data = null;
     }
     $search->setSearchData($search_data, $errors, 'selectProduct');
     // Populate the parent_id field using the last selected value
     // it will be -1 if no previous selected value
     $parent_id = $search->getValue('parent_id');
     $cc = new ConstraintChain();
     if ($parent_id != '-1') {
         $cc->add(new Constraint('parent_id', '=', $parent_id));
     } else {
         $cc->add(new Constraint('parent_id', 'IS', 'NULL'));
     }
     $model = new DataObject('so_product_selector');
     $options = array($parent_id => 'Select an option');
     $options += $model->getAll($cc);
     $search->setOptions('parent_id', $options);
     if ($parent_id != '-1') {
         $data = array('target_id' => $search->getValue('target_id'));
         $search->setBreadcrumbs('parent_id', $model, 'parent_id', $parent_id, 'name', 'description', $data);
     }
     return $search;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:30,代码来源:SelectorItemSearch.php

示例14: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column 
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->canEdit()) {
         return;
     }
     $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit')));
     return $data->renderWith('GridFieldEditButton');
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:15,代码来源:GridFieldEditButton.php

示例15: getColumnContent

 /**
  *
  * @param GridField $gridField
  * @param DataObject $record
  * @param string $columnName
  * @return string - the HTML for the column
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     if (!$record->IsDeletedFromStage && $record->canDelete() && !$record->isPublished()) {
         $field = GridField_FormAction::create($gridField, 'DeleteFromStage' . $record->ID, false, "deletefromstage", array('RecordID' => $record->ID))->addExtraClass('gridfield-button-deletedraft')->setAttribute('title', _t('PublishableGridFieldAction.DELETE', 'Delete draft'))->setAttribute('data-icon', 'decline')->setDescription(_t('PublishableGridFieldAction.DELETE_DESC', 'Remove this item from the draft site'));
         return $field->Field();
     }
     return;
 }
开发者ID:helpfulrobot,项目名称:studiobonito-silverstripe-publishable,代码行数:15,代码来源:PublishableGridFieldDeleteAction.php


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