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


PHP ClassInfo::dataClassesFor方法代码示例

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


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

示例1: __construct

 function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     $classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
     foreach ($classes as $class) {
         $singleton = singleton($class);
         $manyManyRelations = $singleton->uninherited('many_many', true);
         if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
             $this->manyManyParentClass = $class;
             $manyManyTable = $class . '_' . $this->name;
             break;
         }
         $belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true);
         if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) {
             $this->manyManyParentClass = $class;
             $manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name;
             break;
         }
     }
     $tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
     $source = array_shift($tableClasses);
     $sourceField = $this->sourceClass;
     if ($this->manyManyParentClass == $sourceField) {
         $sourceField = 'Child';
     }
     $parentID = $this->controller->ID;
     $this->sourceJoin .= " LEFT JOIN `{$manyManyTable}` ON (`{$source}`.`ID` = `{$sourceField}ID` AND `{$this->manyManyParentClass}ID` = '{$parentID}')";
     $this->joinField = 'Checked';
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:29,代码来源:ManyManyComplexTableField.php

示例2: __construct

 /**
  * Most of the code below was copied from ManyManyComplexTableField.
  * Painful, but necessary, until PHP supports multiple inheritance.
  */
 function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     $manyManyTable = false;
     $classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
     foreach ($classes as $class) {
         if ($class != "Object") {
             $singleton = singleton($class);
             $manyManyRelations = $singleton->uninherited('many_many', true);
             if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
                 $this->manyManyParentClass = $class;
                 $manyManyTable = $class . '_' . $this->name;
                 break;
             }
             $belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true);
             if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) {
                 $this->manyManyParentClass = $class;
                 $manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name;
                 break;
             }
         }
     }
     if (!$manyManyTable) {
         user_error("I could not find the relation {$this}-name in " . $this->controllerClass() . " or any of its ancestors.", E_USER_WARNING);
     }
     $tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
     $source = array_shift($tableClasses);
     $sourceField = $this->sourceClass;
     if ($this->manyManyParentClass == $sourceField) {
         $sourceField = 'Child';
     }
     $parentID = $this->controller->ID;
     $this->sourceJoin .= " LEFT JOIN `{$manyManyTable}` ON (`{$source}`.`ID` = `{$sourceField}ID` AND `{$this->manyManyParentClass}ID` = '{$parentID}')";
     $this->joinField = 'Checked';
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:39,代码来源:ManyManyDataObjectManager.php

示例3: doPublish

 /**
  * Modified version of the SiteTree publish method.
  *
  * @return <type>
  */
 public function doPublish()
 {
     if (!$this->owner->canPublish()) {
         return false;
     }
     $class = $this->owner->class;
     $ownerId = $this->owner->ID;
     $dataClasses = ClassInfo::dataClassesFor($class);
     $dataClasses = array_values($dataClasses);
     $class = $dataClasses[count($dataClasses) - 1];
     $original = Versioned::get_one_by_stage("{$class}", "Live", "\"{$class}\".\"ID\" = {$ownerId}");
     if (!$original) {
         $original = new $class();
     }
     $this->owner->invokeWithExtensions('onBeforePublish', $original);
     // Handle activities undertaken by decorators
     $this->owner->Status = "Published";
     //$this->PublishedByID = Member::currentUser()->ID;
     $this->owner->write();
     $this->owner->publish("Stage", "Live");
     if ($this->owner->hasField('Sort')) {
         // find the table that actually defines the sortable field
         $class = get_class($this->owner);
         if ($this->owner->hasMethod('findClassDefiningSortField')) {
             $class = $this->owner->findClassDefiningSortField();
         }
         DB::query("UPDATE \"{$class}_Live\"\n\t\t\t\tSET \"Sort\" = (SELECT \"{$class}\".\"Sort\" FROM \"{$class}\" WHERE \"{$class}_Live\".\"ID\" = \"{$class}\".\"ID\")");
     }
     // Handle activities undertaken by decorators
     $this->owner->invokeWithExtensions('onAfterPublish', $original);
     return true;
 }
开发者ID:nyeholt,项目名称:silverstripe-publishableobjects,代码行数:37,代码来源:PublishableObject.php

示例4: __construct

	function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {

		Deprecation::notice('3.0', 'Use GridField with GridFieldConfig_RelationEditor');

		parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
		
		$classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
		foreach($classes as $class) {
			$singleton = singleton($class);
			$manyManyRelations = $singleton->uninherited('many_many', true);
			if(isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
				$this->manyManyParentClass = $class;
				$manyManyTable = $class . '_' . $this->name;
				break;
			}
			$belongsManyManyRelations = $singleton->uninherited( 'belongs_many_many', true );
			 if( isset( $belongsManyManyRelations ) && array_key_exists( $this->name, $belongsManyManyRelations ) ) {
				$this->manyManyParentClass = $class;
				$manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name;
				break;
			}
		}
		$tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
		$source = array_shift($tableClasses);
		$sourceField = $this->sourceClass;
		if($this->manyManyParentClass == $sourceField)
			$sourceField = 'Child';
		$parentID = $this->controller->ID;
		
		$this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"$manyManyTable\".\"{$sourceField}ID\" AND \"{$this->manyManyParentClass}ID\" = '$parentID')";
		
		$this->joinField = 'Checked';
	}
开发者ID:redema,项目名称:sapphire,代码行数:33,代码来源:ManyManyComplexTableField.php

示例5: __construct

 function __construct($controller, $name, $sourceClass, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     //Sort by heirarchy, depending on number of parents indent
     $classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
     foreach ($classes as $class) {
         $singleton = singleton($class);
         $manyManyRelations = $singleton->uninherited('many_many', true);
         if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
             $this->manyManyParentClass = $class;
             $this->manyManyTable = $class . '_' . $this->name;
             break;
         }
         $belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true);
         if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) {
             $singleton = singleton($belongsManyManyRelations[$this->name]);
             $manyManyRelations = $singleton->uninherited('many_many', true);
             $this->manyManyParentClass = $class;
             $relation = array_flip($manyManyRelations);
             $this->manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $relation[$class];
             break;
         }
     }
     $tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
     $source = array_shift($tableClasses);
     $sourceField = $this->sourceClass;
     if ($this->manyManyParentClass == $sourceField) {
         $sourceField = 'Child';
     }
     $parentID = $this->controller->ID;
     $this->sourceJoin .= " LEFT JOIN \"{$this->manyManyTable}\" ON (\"{$source}\".\"ID\" = \"{$this->manyManyTable}\".\"{$sourceField}ID\" AND \"{$this->manyManyTable}\".\"{$this->manyManyParentClass}ID\" = '{$parentID}')";
     $this->joinField = 'Checked';
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:33,代码来源:BelongsManyManyComplexTableField.php

示例6: testDataClassesFor

 /**
  * @covers ClassInfo::dataClassesFor()
  */
 public function testDataClassesFor()
 {
     $expect = array('ClassInfoTest_BaseDataClass' => 'ClassInfoTest_BaseDataClass', 'ClassInfoTest_HasFields' => 'ClassInfoTest_HasFields');
     $classes = array('ClassInfoTest_BaseDataClass', 'ClassInfoTest_NoFields', 'ClassInfoTest_HasFields');
     foreach ($classes as $class) {
         $this->assertEquals($expect, ClassInfo::dataClassesFor($class));
     }
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:11,代码来源:ClassInfoTest.php

示例7: onBeforeWrite

 /**
  * Assign a sort number when object is written
  * @see DataExtension::onBeforeWrite()
  */
 public function onBeforeWrite()
 {
     if (!$this->owner->ID && !$this->owner->SortOrder || !$this->owner->SortOrder) {
         $classes = ClassInfo::dataClassesFor($this->owner->ClassName);
         $sql = new SQLQuery('count(ID)', array_shift($classes));
         $val = $sql->execute()->value();
         $this->owner->SortOrder = is_numeric($val) ? $val + 1 : 1;
     }
 }
开发者ID:vinstah,项目名称:body,代码行数:13,代码来源:Sortable.php

示例8: onBeforeWrite

 /**
  * Assign a sort number when object is written
  * @see DataExtension::onBeforeWrite()
  */
 public function onBeforeWrite()
 {
     if (!$this->owner->exists() || !$this->owner->SortOrder) {
         $classes = ClassInfo::dataClassesFor($this->owner->ClassName);
         $sql = new SQLQuery('MAX("SortOrder")', '"' . array_shift($classes) . '"');
         $val = $sql->execute()->value();
         $this->owner->SortOrder = is_numeric($val) ? $val + 1 : 1;
     }
 }
开发者ID:helpfulrobot,项目名称:bummzack-sortablefile,代码行数:13,代码来源:Sortable.php

示例9: allFieldsForClass

 public static function allFieldsForClass($class)
 {
     $dataClasses = ClassInfo::dataClassesFor($class);
     $fields = array();
     foreach ($dataClasses as $dataClass) {
         $fields = array_merge($fields, array_keys(DataObject::database_fields($dataClass)));
     }
     return array_combine($fields, $fields);
 }
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:9,代码来源:ExcelImportExport.php

示例10: testDataClassesFor

 /**
  * @covers ClassInfo::dataClassesFor()
  */
 public function testDataClassesFor()
 {
     $expect = array('ClassInfoTest_BaseDataClass' => 'ClassInfoTest_BaseDataClass', 'ClassInfoTest_HasFields' => 'ClassInfoTest_HasFields', 'ClassInfoTest_WithRelation' => 'ClassInfoTest_WithRelation');
     $classes = array('ClassInfoTest_BaseDataClass', 'ClassInfoTest_NoFields', 'ClassInfoTest_HasFields');
     $this->assertEquals($expect, ClassInfo::dataClassesFor($classes[0]));
     $this->assertEquals($expect, ClassInfo::dataClassesFor($classes[1]));
     $expect = array('ClassInfoTest_BaseDataClass' => 'ClassInfoTest_BaseDataClass', 'ClassInfoTest_HasFields' => 'ClassInfoTest_HasFields');
     $this->assertEquals($expect, ClassInfo::dataClassesFor($classes[2]));
 }
开发者ID:nicocin,项目名称:silverstripe-framework,代码行数:12,代码来源:ClassInfoTest.php

示例11: applyBaseTableFields

 /**
  * @refactor move to SQLQuery
  * @todo fix hack
  */
 protected function applyBaseTableFields()
 {
     $classes = ClassInfo::dataClassesFor($this->modelClass);
     $fields = array("`" . ClassInfo::baseDataClass($this->modelClass) . '`.*');
     if ($this->modelClass != $classes[0]) {
         $fields[] = '`' . $classes[0] . '`.*';
     }
     //$fields = array_keys($model->db());
     $fields[] = '`' . $classes[0] . '`.ClassName AS RecordClassName';
     return $fields;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:15,代码来源:SearchContext.php

示例12: build

 /**
  * @return JoinSpecification[]
  */
 public function build()
 {
     $specs = array();
     $relation_name = $this->alias->getName();
     $child_class = $this->relations[$relation_name];
     $child_hierarchy = ClassInfo::dataClassesFor($child_class);
     $base_child_class = array_shift($child_hierarchy);
     $class_name = ClassInfo::baseDataClass($this->base_entity);
     $specs[] = new JoinSpecification($child_class, $child_class . '.ID = ' . $class_name . '.' . $relation_name . 'ID');
     $this->base_table = $base_child_class;
     return $specs;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:15,代码来源:HasOneJoinStrategy.php

示例13: __construct

	/**
	 * Most of the code below was copied from ManyManyComplexTableField.
	 * Painful, but necessary, until PHP supports multiple inheritance.
	 */
	

		
	function __construct($controller, $name, $sourceClass, $fileFieldName = null, $fieldList = null, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {

		parent::__construct($controller, $name, $sourceClass, $fileFieldName, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
		$manyManyTable = false;
		$classes = array_reverse(ClassInfo::ancestry($this->controllerClass()));
		foreach($classes as $class) {
			if($class != "Object") {
				$singleton = singleton($class);
				$manyManyRelations = $singleton->uninherited('many_many', true);
				if(isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) {
					$this->manyManyParentClass = $class;
					$manyManyTable = $class . '_' . $this->name;
					break;
				}
				$belongsManyManyRelations = $singleton->uninherited( 'belongs_many_many', true );
				 if( isset( $belongsManyManyRelations ) && array_key_exists( $this->name, $belongsManyManyRelations ) ) {
					$this->manyManyParentClass = $class;
					
					// @modification http://open.silverstripe.org/ticket/5194
					$manyManyClass = $belongsManyManyRelations[$this->name];
					$manyManyRelations = singleton($manyManyClass)->uninherited('many_many', true);
					foreach($manyManyRelations as $manyManyRelationship => $manyManyChildClass)
						if ($manyManyChildClass == $class)
							break;
					
					$manyManyTable = $manyManyClass . '_' . $manyManyRelationship;
					break;
				}
			}
		}
		if(!$manyManyTable) user_error("I could not find the relation $this->name in " . $this->controllerClass() . " or any of its ancestors.",E_USER_WARNING);		
		$this->manyManyTable = $manyManyTable;
		$tableClasses = ClassInfo::dataClassesFor($this->sourceClass);
		$source = array_shift($tableClasses);
		$sourceField = $this->sourceClass;
		if($this->manyManyParentClass == $sourceField)
			$sourceField = 'Child';
		$parentID = $this->controller->ID;
		
		$this->sourceJoin .= " LEFT JOIN \"$manyManyTable\" ON (\"$source\".\"ID\" = \"{$sourceField}ID\" AND \"$manyManyTable\".\"{$this->manyManyParentClass}ID\" = '$parentID')";
		
		$this->joinField = 'Checked';
		if(isset($_REQUEST['ctf'][$this->Name()]['only_related']))
		  $this->OnlyRelated = $_REQUEST['ctf'][$this->Name()]['only_related'];

		$this->addPermission('only_related');
		
		// If drag-and-drop is enabled, we need to turn on the only related filter
		if($this->ShowAll() && SortableDataObject::is_sortable_many_many($this->sourceClass()))
			  $this->OnlyRelated = '1';
		
	}
开发者ID:notioncollective,项目名称:stationid,代码行数:59,代码来源:ManyManyFileDataObjectManager.php

示例14: build

 /**
  * @return JoinSpecification[]
  */
 public function build()
 {
     $specs = array();
     $relation_name = $this->alias->getName();
     $class_name = ClassInfo::baseDataClass($this->base_entity);
     $child_class = $this->relations[$relation_name];
     $child_hierarchy = ClassInfo::dataClassesFor($child_class);
     $base_child_class = array_shift($child_hierarchy);
     $join_field = $this->base_entity->getRemoteJoinField($relation_name, 'has_many');
     $specs[] = new JoinSpecification($base_child_class, $base_child_class . '.' . $join_field . ' = ' . $class_name . '.ID');
     $this->base_table = $base_child_class;
     $this->query->addAndCondition(QueryCriteria::equal("{$base_child_class}.ClassName", $child_class));
     return $specs;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:17,代码来源:HasManyJoinStrategy.php

示例15: onAfterWrite

    public function onAfterWrite()
    {
        parent::onAfterWrite();
        $ID = $this->owner->ID;
        $className = $this->owner->ClassName;
        $subClasses = ClassInfo::dataClassesFor($className);
        $versionsToDelete = array();
        $version_limit = Config::inst()->get('VersionTruncator', 'version_limit');
        if (is_numeric($version_limit)) {
            $search = DB::query('SELECT "RecordID", "Version" FROM "SiteTree_versions"
				 WHERE "RecordID" = ' . $ID . ' AND "ClassName" = \'' . $className . '\'
				 AND "PublisherID" > 0
				 ORDER BY "LastEdited" DESC LIMIT ' . $version_limit . ', 200');
            foreach ($search as $row) {
                array_push($versionsToDelete, array('RecordID' => $row['RecordID'], 'Version' => $row['Version']));
            }
        }
        $draft_limit = Config::inst()->get('VersionTruncator', 'draft_limit');
        if (is_numeric($draft_limit)) {
            $search = DB::query('SELECT "RecordID", "Version" FROM "SiteTree_versions"
				 WHERE "RecordID" = ' . $ID . ' AND "ClassName" = \'' . $className . '\'
				 AND "PublisherID" = 0
				 ORDER BY "LastEdited" DESC LIMIT ' . $draft_limit . ', 200');
            foreach ($search as $row) {
                array_push($versionsToDelete, array('RecordID' => $row['RecordID'], 'Version' => $row['Version']));
            }
        }
        $delete_old_page_types = Config::inst()->get('VersionTruncator', 'delete_old_page_types');
        if ($delete_old_page_types) {
            $search = DB::query('SELECT "RecordID", "Version" FROM "SiteTree_versions"
				 WHERE "RecordID" = ' . $ID . ' AND "ClassName" != \'' . $className . '\'');
            foreach ($search as $row) {
                array_push($versionsToDelete, array('RecordID' => $row['RecordID'], 'Version' => $row['Version']));
            }
        }
        /* If versions to delete, start deleting */
        if (count($versionsToDelete) > 0) {
            $affected_tables = array();
            foreach ($subClasses as $subclass) {
                $versionsTable = $subclass . '_versions';
                foreach ($versionsToDelete as $d) {
                    DB::query('DELETE FROM "' . $versionsTable . '"' . ' WHERE "RecordID" = ' . $d['RecordID'] . ' AND "Version" = ' . $d['Version']);
                    if (DB::affectedRows() == 1) {
                        array_push($affected_tables, $versionsTable);
                    }
                }
            }
            $this->vacuumTables($affected_tables);
        }
    }
开发者ID:helpfulrobot,项目名称:axllent-silverstripe-version-truncator,代码行数:50,代码来源:VersionTruncator.php


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