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


PHP DataObject::onBeforeWrite方法代码示例

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


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

示例1: onBeforeWrite

 /**
  * Automatically set Code
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Code) {
         $this->Code = md5(rand(0, 10000));
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-downloadtoemail,代码行数:10,代码来源:EmailDownloadPage_Registration.php

示例2: onBeforeWrite

 public function onBeforeWrite()
 {
     if (!$this->AuthorID) {
         $this->AuthorID = Member::currentUserID();
     }
     parent::onBeforeWrite();
 }
开发者ID:antons-,项目名称:deploynaut,代码行数:7,代码来源:DNDataArchive.php

示例3: onBeforeWrite

 /**
  * Set the owner automatically if needed
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->OwnerID) {
         $this->OwnerID = Member::currentUserID();
     }
 }
开发者ID:markguinn,项目名称:silverstripe-wishlist,代码行数:10,代码来源:WishList.php

示例4: onBeforeWrite

 protected function onBeforeWrite()
 {
     if ($this->isChanged('ParentClass')) {
         $this->ParentClass = ClassInfo::baseDataClass($this->ParentClass);
     }
     parent::onBeforeWrite();
 }
开发者ID:rodneyway,项目名称:silverstripe-siteexporter,代码行数:7,代码来源:SiteExport.php

示例5: onBeforeWrite

 /**
  * Ensure a sort value is set
  */
 public function onBeforeWrite()
 {
     if (!$this->Sort) {
         $this->Sort = DB::query('SELECT MAX("Sort") + 1 FROM "WorkflowDefinition"')->value();
     }
     parent::onBeforeWrite();
 }
开发者ID:rodneyway,项目名称:advancedworkflow,代码行数:10,代码来源:WorkflowDefinition.php

示例6: onBeforeWrite

 /**
  * Sanitise the identifier and populate the variables list
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $slug = singleton('SiteTree')->generateURLSegment($this->Identifier);
     $original_slug = $slug;
     $i = 0;
     while ($t = PermamailTemplate::get()->filter(array("Identifier" => "{$slug}"))->exclude(array("ID" => $this->ID))->first()) {
         $i++;
         $slug = $original_slug . "-{$i}";
     }
     $this->Identifier = $slug;
     $reflector = EmailReflectionTemplate::create();
     $reflector->process($this->Content);
     $vars = array();
     foreach ($reflector->getTopLevelVars() as $var => $type) {
         $vars[$var] = false;
     }
     foreach ($reflector->getTopLevelBlocks() as $block) {
         $vars[$block->getName()] = $block->isLoop();
     }
     // Remove any variables that are no longer in the template
     if ($this->TestVariables()->exists()) {
         $this->TestVariables()->exclude(array('Variable' => array_keys($vars)))->removeAll();
     }
     $currentVars = $this->TestVariables()->column('Variable');
     foreach ($vars as $var => $isList) {
         if (!in_array($var, $currentVars)) {
             $v = PermamailTemplateVariable::create(array('Variable' => $var, 'PermamailTemplateID' => $this->ID, 'List' => $isList));
             $v->write();
         }
     }
 }
开发者ID:helpfulrobot,项目名称:smarcet-silverstripe-permamail,代码行数:35,代码来源:PermamailTemplate.php

示例7: onBeforeWrite

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (empty($this->EventDate)) {
         $this->EventDate = time();
     }
 }
开发者ID:pstaender,项目名称:ShopSystem,代码行数:7,代码来源:ShopOrderEvent.php

示例8: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($this->ID && !$this->Title) {
         throw new Exception("Invalid title");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-pdfrendition,代码行数:7,代码来源:ComposedPdf.php

示例9: onBeforeWrite

 /**
  * Generate the title if needed
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Title) {
         $this->Title = empty($this->Query) ? "Search" : "Search: {$this->Query}";
     }
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-search,代码行数:10,代码来源:SearchLog.php

示例10: onBeforeWrite

	/**
	 * These actions are performed when write() is called on this object.
	 */
	public function onBeforeWrite() {
		// save submitter if a Member is logged in
		$currentMember = Member::currentMember();
		if(!$this->SubmitterID && $currentMember) $this->SubmitterID = $currentMember->ID;
		
		parent::onBeforeWrite();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:10,代码来源:MultiFormSession.php

示例11: onBeforeWrite

 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->UniqueHash) {
         $this->UniqueHash = md5(strtotime('now') . '|' . rand());
     }
 }
开发者ID:helpfulrobot,项目名称:iqnection-pages-protectedminisite,代码行数:7,代码来源:ProtectedMiniSite.php

示例12: onBeforeWrite

 public function onBeforeWrite()
 {
     if ($this->ISBN != null && $this->Title == null) {
         $postURL = "https://www.googleapis.com/books/v1/volumes?q=isbn:" . $this->ISBN . "&key=" . self::$googlebooksapi_key;
         $json = json_decode(file_get_contents($postURL), true);
         $info = $json["items"][0]["volumeInfo"];
         if (array_key_exists('title', $info)) {
             $this->Title = $info['title'];
         }
         if (array_key_exists('subtitle', $info)) {
             $this->Subtitle = $info['subtitle'];
         }
         if (array_key_exists('thumbnail', $info['imageLinks'])) {
             $this->Thumbnail = $info['imageLinks']['thumbnail'];
         }
         if (array_key_exists('authors', $info)) {
             $this->Author = $info['authors'][0];
         }
         if (array_key_exists('pageCount', $info)) {
             $this->Pages = $info['pageCount'];
         }
         if (array_key_exists('publisher', $info)) {
             $this->Publisher = $info['publisher'];
         }
         if (array_key_exists('description', $info)) {
             $this->Description = $info['description'];
         }
     }
     parent::onBeforeWrite();
 }
开发者ID:helpfulrobot,项目名称:howardgrigg-simple-library,代码行数:30,代码来源:Resource.php

示例13: onBeforeWrite

 function onBeforeWrite()
 {
     $media = $this->Device;
     switch ($media) {
         case 'iphone':
             $this->setField('Media', '(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)');
             break;
         case 'iphone-tall':
             $this->setField('Media', '(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)');
             break;
         case 'iphone-retina':
             $this->setField('Media', '(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)');
             break;
         case 'ipad-portrait':
             $this->setField('Media', '(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)');
             break;
         case 'ipad-landscape':
             $this->setField('Media', '(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)');
             break;
         case 'ipad-retina-portrait':
             $this->setField('Media', '(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)');
             break;
         case 'ipad-retina-landscape':
             $this->setField('Media', '(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)');
             break;
     }
     parent::onBeforeWrite();
 }
开发者ID:helpfulrobot,项目名称:bramdeleeuw-silverstripe-webapp,代码行数:28,代码来源:WebAppStartupScreen.php

示例14: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Date) {
         $this->Date = date('Y-m-d H:i:s');
     }
 }
开发者ID:burnbright,项目名称:silverstripe-testimonials,代码行数:7,代码来源:Testimonial.php

示例15: onBeforeWrite

 /**
  * Hook on before write
  */
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->Title) {
         $this->Title = 'New ' . strtolower(self::$singular_name);
     }
 }
开发者ID:sentromedia,项目名称:letsfund,代码行数:10,代码来源:Block.php


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