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


PHP Versioned::get_including_deleted方法代码示例

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


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

示例1: testAllHistoricalChildren

	/**
	 * Test Hierarchy::AllHistoricalChildren().
	 */
	function testAllHistoricalChildren() {
		// Delete some objs
		$this->objFromFixture('HierarchyTest_Object', 'obj2b')->delete();
		$this->objFromFixture('HierarchyTest_Object', 'obj3a')->delete();
		$this->objFromFixture('HierarchyTest_Object', 'obj3')->delete();
	
		// Check that obj1-3 appear at the top level of the AllHistoricalChildren tree
		$this->assertEquals(array("Obj 1", "Obj 2", "Obj 3"), 
			singleton('HierarchyTest_Object')->AllHistoricalChildren()->column('Title'));
	
		// Check numHistoricalChildren
		$this->assertEquals(3, singleton('HierarchyTest_Object')->numHistoricalChildren());

		// Check that both obj 2 children are returned
		$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
		$this->assertEquals(array("Obj 2a", "Obj 2b"), 
			$obj2->AllHistoricalChildren()->column('Title'));

		// Check numHistoricalChildren
		$this->assertEquals(2, $obj2->numHistoricalChildren());

			
		// Obj 3 has been deleted; let's bring it back from the grave
		$obj3 = Versioned::get_including_deleted("HierarchyTest_Object", "\"Title\" = 'Obj 3'")->First();
	
		// Check that both obj 3 children are returned
		$this->assertEquals(array("Obj 3a", "Obj 3b"), 
			$obj3->AllHistoricalChildren()->column('Title'));
			
		// Check numHistoricalChildren
		$this->assertEquals(2, $obj3->numHistoricalChildren());
		
	}
开发者ID:redema,项目名称:sapphire,代码行数:36,代码来源:HierarchyTest.php

示例2: testGetIncludingDeleted

 /**
  * Test Versioned::get_including_deleted()
  */
 public function testGetIncludingDeleted()
 {
     // Get all ids of pages
     $allPageIDs = DataObject::get('VersionedTest_DataObject', "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC")->column('ID');
     // Modify a page, ensuring that the Version ID and Record ID will differ,
     // and then subsequently delete it
     $targetPage = $this->objFromFixture('VersionedTest_DataObject', 'page3');
     $targetPage->Content = 'To be deleted';
     $targetPage->write();
     $targetPage->delete();
     // Get all items, ignoring deleted
     $remainingPages = DataObject::get("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
     // Check that page 3 has gone
     $this->assertNotNull($remainingPages);
     $this->assertEquals(array("Page 1", "Page 2"), $remainingPages->column('Title'));
     // Get all including deleted
     $allPages = Versioned::get_including_deleted("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
     // Check that page 3 is still there
     $this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
     // Check that the returned pages have the correct IDs
     $this->assertEquals($allPageIDs, $allPages->column('ID'));
     // Check that this still works if we switch to reading the other stage
     Versioned::reading_stage("Live");
     $allPages = Versioned::get_including_deleted("VersionedTest_DataObject", "\"ParentID\" = 0", "\"VersionedTest_DataObject\".\"ID\" ASC");
     $this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
     // Check that the returned pages still have the correct IDs
     $this->assertEquals($allPageIDs, $allPages->column('ID'));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:31,代码来源:VersionedTest.php

示例3: run

 public function run()
 {
     $this->log("Upgrading formfield rules and custom settings");
     // List of rules that have been created in all stages
     $fields = Versioned::get_including_deleted('EditableFormField');
     foreach ($fields as $field) {
         $this->upgradeField($field);
     }
 }
开发者ID:camfindlay,项目名称:silverstripe-userforms,代码行数:9,代码来源:UserFormsUpgradeService.php

示例4: testBatchArchive

 /**
  * Test which pages can be published via batch actions
  */
 public function testBatchArchive()
 {
     $this->logInWithPermission('ADMIN');
     $pages = Versioned::get_including_deleted('Page');
     $ids = $pages->column('ID');
     $action = new CMSBatchAction_Archive();
     // Test applicable pages
     $applicable = $action->applicablePages($ids);
     $this->assertContains($this->idFromFixture('Page', 'published'), $applicable);
     $this->assertNotContains($this->idFromFixture('Page', 'archived'), $applicable);
     $this->assertContains($this->idFromFixture('Page', 'unpublished'), $applicable);
     $this->assertContains($this->idFromFixture('Page', 'modified'), $applicable);
 }
开发者ID:riddler7,项目名称:silverstripe-cms,代码行数:16,代码来源:CMSBatchActionsTest.php

示例5: testAllHistoricalChildren

 /**
  * Test Hierarchy::AllHistoricalChildren().
  */
 function testAllHistoricalChildren()
 {
     // Delete some pages
     $this->objFromFixture('Page', 'page2b')->delete();
     $this->objFromFixture('Page', 'page3a')->delete();
     $this->objFromFixture('Page', 'page3')->delete();
     // Check that page1-3 appear at the top level of the AllHistoricalChildren tree
     $this->assertEquals(array("Page 1", "Page 2", "Page 3"), singleton('Page')->AllHistoricalChildren()->column('Title'));
     // Check that both page 2 children are returned
     $page2 = $this->objFromFixture('Page', 'page2');
     $this->assertEquals(array("Page 2a", "Page 2b"), $page2->AllHistoricalChildren()->column('Title'));
     // Page 3 has been deleted; let's bring it back from the grave
     $page3 = Versioned::get_including_deleted("SiteTree", "Title = 'Page 3'")->First();
     // Check that both page 3 children are returned
     $this->assertEquals(array("Page 3a", "Page 3b"), $page3->AllHistoricalChildren()->column('Title'));
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:19,代码来源:HierarchyTest.php

示例6: testGetIncludingDeleted

 /**
  * Test Versioned::get_including_deleted()
  */
 function testGetIncludingDeleted()
 {
     // Delete a page
     $this->objFromFixture('Page', 'page3')->delete();
     // Get all items, ignoring deleted
     $remainingPages = DataObject::get("SiteTree", "\"ParentID\" = 0", "\"SiteTree\".\"ID\" ASC");
     // Check that page 3 has gone
     $this->assertNotNull($remainingPages);
     $this->assertEquals(array("Page 1", "Page 2"), $remainingPages->column('Title'));
     // Get all including deleted
     $allPages = Versioned::get_including_deleted("SiteTree", "\"ParentID\" = 0", "\"SiteTree\".\"ID\" ASC");
     // Check that page 3 is still there
     $this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
     // Check that this still works if we switch to reading the other stage
     Versioned::reading_stage("Live");
     $allPages = Versioned::get_including_deleted("SiteTree", "\"ParentID\" = 0", "\"SiteTree\".\"ID\" ASC");
     $this->assertEquals(array("Page 1", "Page 2", "Page 3"), $allPages->column('Title'));
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:21,代码来源:VersionedTest.php

示例7: AllHistoricalChildren

 /**
  * Return all the children that this page had, including pages that were deleted
  * from both stage & live.
  */
 public function AllHistoricalChildren()
 {
     $baseClass = ClassInfo::baseDataClass($this->owner->class);
     return Versioned::get_including_deleted($baseClass, "\"ParentID\" = " . (int) $this->owner->ID, "\"{$baseClass}\".\"ID\" ASC");
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:9,代码来源:Hierarchy.php

示例8: numHistoricalChildren

 /**
  * Return the number of children that this page ever had, including pages that were deleted
  */
 public function numHistoricalChildren()
 {
     if (!$this->owner->hasExtension('Versioned')) {
         throw new Exception('Hierarchy->AllHistoricalChildren() only works with Versioned extension applied');
     }
     return Versioned::get_including_deleted(ClassInfo::baseDataClass($this->owner->class), "\"ParentID\" = " . (int) $this->owner->ID)->count();
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:10,代码来源:Hierarchy.php

示例9: pagesIncluded

 function pagesIncluded()
 {
     $ids = array();
     // TODO Not very memory efficient, but usually not very many deleted pages exist
     $pages = Versioned::get_including_deleted('SiteTree');
     if ($pages) {
         foreach ($pages as $page) {
             $ids[] = array('ID' => $page->ID, 'ParentID' => $page->ParentID);
         }
     }
     return $ids;
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:12,代码来源:CMSSiteTreeFilter.php

示例10: getFilteredPages

 /**
  * Filters out all pages who's status is set to "Deleted".
  *
  * @see {@link SiteTree::getStatusFlags()}
  * @return SS_List
  */
 public function getFilteredPages()
 {
     $pages = Versioned::get_including_deleted('SiteTree');
     $pages = $this->applyDefaultFilters($pages);
     $pages = $pages->filterByCallback(function ($page) {
         // Doesn't exist on either stage or live
         return $page->getIsDeletedFromStage() && !$page->getExistsOnLive();
     });
     return $pages;
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:16,代码来源:CMSSiteTreeFilter.php

示例11: AllHistoricalChildren

 /**
  * Return all the children that this page had, including pages that were deleted
  * from both stage & live.
  */
 public function AllHistoricalChildren()
 {
     return Versioned::get_including_deleted(ClassInfo::baseDataClass($this->owner->class), "ParentID = " . (int) $this->owner->ID);
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:8,代码来源:Hierarchy.php

示例12: getPages

 /**
  * Safely query and return all pages queried
  *
  * @param array $ids
  * @return SS_List
  */
 protected function getPages($ids)
 {
     // Check empty set
     if (empty($ids)) {
         return new ArrayList();
     }
     $recordClass = $this->recordClass;
     // Bypass translatable filter
     if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) {
         Translatable::disable_locale_filter();
     }
     // Bypass versioned filter
     if ($recordClass::has_extension('Versioned')) {
         // Workaround for get_including_deleted not supporting byIDs filter very well
         // Ensure we select both stage / live records
         $pages = Versioned::get_including_deleted($recordClass, array('"RecordID" IN (' . DB::placeholders($ids) . ')' => $ids));
     } else {
         $pages = DataObject::get($recordClass)->byIDs($ids);
     }
     if (class_exists('Translatable') && $recordClass::has_extension('Translatable')) {
         Translatable::enable_locale_filter();
     }
     return $pages;
 }
开发者ID:XDdesigners,项目名称:silverstripe-framework,代码行数:30,代码来源:CMSBatchActionHandler.php

示例13: testBatchRestore

 public function testBatchRestore()
 {
     $this->logInWithPermission('ADMIN');
     $pages = Versioned::get_including_deleted('SiteTree');
     $action = new CMSBatchAction_Restore();
     $archivedID = $this->idFromFixture('SiteTree', 'archived');
     $archivedxID = $this->idFromFixture('SiteTree', 'archivedx');
     $archivedyID = $this->idFromFixture('SiteTree', 'archivedy');
     // Just restore one child
     $list = $pages->filter('RecordID', $archivedxID);
     $this->assertEquals(1, $list->count());
     $this->assertEquals($archivedID, $list->first()->ParentID);
     // Run restore
     $result = json_decode($action->run($list), true);
     $this->assertEquals(array($archivedxID => $archivedxID), $result['success']);
     $archivedx = SiteTree::get()->byID($archivedxID);
     $this->assertNotNull($archivedx);
     $this->assertEquals(0, $archivedx->ParentID);
     // Restore to root because parent is unrestored
     // Restore both remaining pages
     $list = $pages->filter('RecordID', array($archivedID, $archivedyID))->sort('Title');
     $this->assertEquals(2, $list->count());
     $this->assertEquals($archivedID, $list->first()->ParentID);
     // archivedy
     $this->assertEquals(0, $list->last()->ParentID);
     // archived (parent)
     // Run restore
     $result = json_decode($action->run($list), true);
     $this->assertEquals(array($archivedID => $archivedID, $archivedyID => $archivedyID), $result['success']);
     $archived = SiteTree::get()->byID($archivedID);
     $archivedy = SiteTree::get()->byID($archivedyID);
     $this->assertNotNull($archived);
     $this->assertNotNull($archivedy);
     $this->assertEquals($archivedID, $archivedy->ParentID);
     // Not restored to root, but to the parent
     $this->assertEquals(0, $archived->ParentID);
     // Root stays root
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:38,代码来源:CMSBatchActionsTest.php


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