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


PHP ClassInfo::ancestry方法代码示例

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


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

示例1: __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

示例2: bootstrapify

 public function bootstrapify()
 {
     $inline_fields = Config::inst()->get('BootstrapForm', 'inline_fields');
     foreach ($this->owner as $f) {
         if (isset($this->ignores[$f->getName()])) {
             continue;
         }
         if ($f instanceof CompositeField) {
             $f->getChildren()->bootstrapify();
             continue;
         }
         if (!in_array($f->class, $inline_fields)) {
             $f->addExtraClass('form-control');
         }
         $template = "Bootstrap{$f->class}_holder";
         if (SSViewer::hasTemplate($template)) {
             $f->setFieldHolderTemplate($template);
         } else {
             $f->setFieldHolderTemplate("BootstrapFieldHolder");
         }
         foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
             $bootstrapCandidate = "Bootstrap{$className}";
             $nativeCandidate = $className;
             if (SSViewer::hasTemplate($bootstrapCandidate)) {
                 $f->setTemplate($bootstrapCandidate);
                 break;
             } elseif (SSViewer::hasTemplate($nativeCandidate)) {
                 $f->setTemplate($nativeCandidate);
                 break;
             }
         }
     }
     return $this->owner;
 }
开发者ID:Jeremuelle,项目名称:silverstripe-bootstrap-forms,代码行数:34,代码来源:BootstrapFieldList.php

示例3: __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

示例4: __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

示例5: __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->controller->ClassName));
     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;
         }
     }
     $source = $this->sourceClass;
     $sourceField = $this->sourceClass;
     if ($this->manyManyParentClass == $source) {
         $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:ramziammar,项目名称:websites,代码行数:28,代码来源:ManyManyComplexTableField.php

示例6: determineFolderName

 /**
  * Description
  * @return string
  */
 protected function determineFolderName()
 {
     // Grab paths
     $paths = Config::inst()->get(__CLASS__, 'upload_paths');
     // Grab ancestry from top-down
     $className = get_class($this->record);
     $classes = array_reverse(ClassInfo::ancestry($className));
     $path = $className;
     // Loop over ancestry and break out if we have a match
     foreach ($classes as $class) {
         if (array_key_exists($class, $paths)) {
             $path = $paths[$class];
             break;
         }
     }
     // If there are any parameters which require matching, search for them
     $matches = array();
     preg_match_all('/\\$[a-zA-Z0-9]+?/U', $path, $matches);
     // Replace with field values
     foreach ($matches[0] as $match) {
         $field = str_replace("\$", "", $match);
         $value = FileNameFilter::create()->filter($this->record->getField($field));
         $path = str_replace($match, $value, $path);
     }
     $this->folderName = $path;
     return $path;
 }
开发者ID:Marketo,项目名称:SilverStripe-ContextAwareUploadField,代码行数:31,代码来源:ContextAwareUploadField.php

示例7: controller_for

 /**
  * Get the appropriate {@link CatalogueProductController} or
  * {@link CatalogueProductController} for handling the relevent
  * object.
  *
  * @param $object Either Product or Category object
  * @param string $action
  * @return CatalogueController
  */
 protected static function controller_for($object, $action = null)
 {
     if ($object->class == 'CatalogueProduct') {
         $controller = "CatalogueProductController";
     } elseif ($object->class == 'CatalogueCategory') {
         $controller = "CatalogueCategoryController";
     } else {
         $ancestry = ClassInfo::ancestry($object->class);
         while ($class = array_pop($ancestry)) {
             if (class_exists($class . "_Controller")) {
                 break;
             }
         }
         // Find the controller we need, or revert to a default
         if ($class !== null) {
             $controller = "{$class}_Controller";
         } elseif (ClassInfo::baseDataClass($object->class) == "CatalogueProduct") {
             $controller = "CatalogueProductController";
         } elseif (ClassInfo::baseDataClass($object->class) == "CatalogueCategory") {
             $controller = "CatalogueCategoryController";
         }
     }
     if ($action && class_exists($controller . '_' . ucfirst($action))) {
         $controller = $controller . '_' . ucfirst($action);
     }
     return class_exists($controller) ? Injector::inst()->create($controller, $object) : $object;
 }
开发者ID:alialamshahi,项目名称:silverstripe-catalogue-prowall,代码行数:36,代码来源:CatalogueURLController.php

示例8: foreignIDFilter

 protected function foreignIDFilter($id = null)
 {
     if ($id === null) {
         $id = $this->getForeignID();
     }
     $class = $this->dataClass;
     $class_type = $class::create();
     $has_field = !is_null($class_type->hasOwnTableDatabaseField($this->foreignKey));
     if (!$has_field) {
         foreach (ClassInfo::ancestry($class_type) as $parent_class) {
             if (in_array($parent_class, array('ViewableData', 'Object', 'DataObject'))) {
                 continue;
             }
             $class_type_parent = $parent_class::create();
             $has_field = !is_null($class_type_parent->hasOwnTableDatabaseField($this->foreignKey));
             if ($has_field) {
                 $class = $parent_class;
                 break;
             }
         }
     }
     // Apply relation filter
     if (is_array($id)) {
         return "\"{$class}\".\"{$this->foreignKey}\" IN ('" . implode("', '", array_map('Convert::raw2sql', $id)) . "')";
     } else {
         if ($id !== null) {
             return "\"{$class}\".\"{$this->foreignKey}\" = '" . Convert::raw2sql($id) . "'";
         }
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:30,代码来源:CustomHasManyList.php

示例9: locateConfigFor

 public function locateConfigFor($name)
 {
     // Check direct or cached result
     $config = $this->configFor($name);
     if ($config !== null) {
         return $config;
     }
     // do parent lookup if it's a class
     if (class_exists($name)) {
         $parents = array_reverse(array_keys(ClassInfo::ancestry($name)));
         array_shift($parents);
         foreach ($parents as $parent) {
             // have we already got for this?
             $config = $this->configFor($parent);
             if ($config !== null) {
                 // Cache this result
                 $this->configs[$name] = $config;
                 return $config;
             }
         }
     }
     // there is no parent config, so we'll record that as false so we don't do the expensive
     // lookup through parents again
     $this->configs[$name] = false;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:25,代码来源:SilverStripeServiceConfigurationLocator.php

示例10: locateConfigFor

 public function locateConfigFor($name)
 {
     if (isset($this->configs[$name])) {
         return $this->configs[$name];
     }
     $config = Config::inst()->get('Injector', $name);
     if ($config) {
         $this->configs[$name] = $config;
         return $config;
     }
     // do parent lookup if it's a class
     if (class_exists($name)) {
         $parents = array_reverse(array_keys(ClassInfo::ancestry($name)));
         array_shift($parents);
         foreach ($parents as $parent) {
             // have we already got for this?
             if (isset($this->configs[$parent])) {
                 return $this->configs[$parent];
             }
             $config = Config::inst()->get('Injector', $parent);
             if ($config) {
                 $this->configs[$name] = $config;
                 return $config;
             } else {
                 $this->configs[$parent] = false;
             }
         }
         // there is no parent config, so we'll record that as false so we don't do the expensive
         // lookup through parents again
         $this->configs[$name] = false;
     }
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:32,代码来源:SilverStripeServiceConfigurationLocator.php

示例11: apply_bootstrap_to_fieldlist

 /**
  * Changes the templates of all the {@link FormField}
  * objects in a given {@link FieldList} object to those
  * that work the Bootstrap framework
  *
  * @param FieldList $fields
  */
 public static function apply_bootstrap_to_fieldlist($fields)
 {
     foreach ($fields as $f) {
         // If we have a Tabset, bootstrapify all Tabs
         if ($f instanceof TabSet) {
             self::apply_bootstrap_to_fieldlist($f->Tabs());
         }
         // If we have a Tab, bootstrapify all its Fields
         if ($f instanceof Tab) {
             self::apply_bootstrap_to_fieldlist($f->Fields());
         }
         $template = "Bootstrap{$f->class}_holder";
         if (SSViewer::hasTemplate($template)) {
             $f->setFieldHolderTemplate($template);
         } else {
             $f->setFieldHolderTemplate("BootstrapFieldHolder");
         }
         foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
             $bootstrapCandidate = "Bootstrap{$className}";
             $nativeCandidate = $className;
             if (SSViewer::hasTemplate($bootstrapCandidate)) {
                 $f->setTemplate($bootstrapCandidate);
                 break;
             } elseif (SSViewer::hasTemplate($nativeCandidate)) {
                 $f->setTemplate($nativeCandidate);
                 break;
             }
         }
     }
 }
开发者ID:reflektera,项目名称:silverstripe-bootstrap-forms,代码行数:37,代码来源:BootstrapForm.php

示例12: transform

 public function transform(FormField $field)
 {
     // Look for a performXXTransformation() method on the field itself.
     // performReadonlyTransformation() is a pretty commonly applied method.
     // Otherwise, look for a transformXXXField() method on this object.
     // This is more commonly done in custom transformations
     // We iterate through each array simultaneously, looking at [0] of both, then [1] of both.
     // This provides a more natural failover scheme.
     $transNames = array_reverse(array_values(ClassInfo::ancestry($this->class)));
     $fieldClasses = array_reverse(array_values(ClassInfo::ancestry($field->class)));
     $len = max(sizeof($transNames), sizeof($fieldClasses));
     for ($i = 0; $i < $len; $i++) {
         // This is lets fieldClasses be longer than transNames
         if ($transName = $transNames[$i]) {
             if ($field->hasMethod('perform' . $transName)) {
                 $funcName = 'perform' . $transName;
                 //echo "<li>$field->class used $funcName";
                 return $field->{$funcName}($this);
             }
         }
         // And this one does the reverse.
         if ($fieldClass = $fieldClasses[$i]) {
             if ($this->hasMethod('transform' . $fieldClass)) {
                 $funcName = 'transform' . $fieldClass;
                 //echo "<li>$field->class used $funcName";
                 return $this->{$funcName}($field);
             }
         }
     }
     user_error("FormTransformation:: Can't perform '{$this->class}' on '{$field->class}'", E_USER_ERROR);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:31,代码来源:FormTransformation.php

示例13: bootstrapify

 /**
  * Transforms all fields in the FieldList to use Bootstrap templates
  * @return FieldList
  */
 public function bootstrapify()
 {
     foreach ($this->owner as $f) {
         if (isset($this->ignores[$f->getName()])) {
             continue;
         }
         // If we have a Tabset, bootstrapify all Tabs
         if ($f instanceof TabSet) {
             $f->Tabs()->bootstrapify();
         }
         // If we have a Tab, bootstrapify all its Fields
         if ($f instanceof Tab) {
             $f->Fields()->bootstrapify();
         }
         $template = "Bootstrap{$f->class}_holder";
         if (SSViewer::hasTemplate($template)) {
             $f->setFieldHolderTemplate($template);
         } else {
             $f->setFieldHolderTemplate("BootstrapFieldHolder");
         }
         foreach (array_reverse(ClassInfo::ancestry($f)) as $className) {
             $bootstrapCandidate = "Bootstrap{$className}";
             $nativeCandidate = $className;
             if (SSViewer::hasTemplate($bootstrapCandidate)) {
                 $f->setTemplate($bootstrapCandidate);
                 break;
             } elseif (SSViewer::hasTemplate($nativeCandidate)) {
                 $f->setTemplate($nativeCandidate);
                 break;
             }
         }
     }
     return $this->owner;
 }
开发者ID:helpfulrobot,项目名称:unclecheese-bootstrap-forms,代码行数:38,代码来源:BootstrapFieldList.php

示例14: testAncestry

 /**
  * @covers ClassInfo::ancestry()
  */
 public function testAncestry()
 {
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass');
     $expect = ArrayLib::valuekey(array('Object', 'ViewableData', 'DataObject', 'ClassInfoTest_BaseClass', 'ClassInfoTest_ChildClass'));
     $this->assertEquals($expect, $ancestry);
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass', true);
     $this->assertEquals(array('ClassInfoTest_BaseClass' => 'ClassInfoTest_BaseClass'), $ancestry, '$tablesOnly option excludes memory-only inheritance classes');
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:11,代码来源:ClassInfoTest.php

示例15: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     $ancestry = ClassInfo::ancestry($this->owner->ClassName);
     if (!in_array('RedirectorPage', $ancestry) && !in_array('VirtualPage', $ancestry)) {
         $blocks = $this->owner->Blocks();
         $blocks_grid = $this->gridBuilder('Blocks', $blocks, '', true, 'GridFieldConfig_RelationEditor');
         $docked_grid = $this->gridBuilder('DockedBlocks', $this->dockedBlocks(), '');
         $fields->addFieldToTab('Root.MyBlocks', $blocks_grid);
         $fields->addFieldToTab('Root.DockedBlocks', $docked_grid);
     }
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:11,代码来源:BlockinPage.php


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