本文整理汇总了PHP中ClassInfo::subclassesFor方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo::subclassesFor方法的具体用法?PHP ClassInfo::subclassesFor怎么用?PHP ClassInfo::subclassesFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo::subclassesFor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSource
function getSource()
{
if ($this->includeBaseClass) {
$classes[] = $this->sourceClass;
} else {
$classes = array();
}
$classes = $classes + ClassInfo::subclassesFor($this->sourceClass);
if (!count($this->availableClasses)) {
$this->availableClasses = $classes;
} elseif ($this->includeBaseClass) {
$this->availableClasses[] = $this->sourceClass;
}
$dropdownArray = array();
if ($this->getHasEmptyDefault()) {
$dropdownArray[""] = $this->emptyString;
}
if ($classes) {
foreach ($classes as $key => $className) {
if (class_exists($key)) {
if (in_array($className, $this->availableClasses)) {
$obj = singleton($className);
if ($obj) {
$dropdownArray[$className] = $obj->i18n_singular_name();
}
}
}
}
}
if (!count($dropdownArray)) {
$dropdownArray = array($this->sourceClass => _t("EcommerceClassNameOrTypeDropdownField.CAN_NOT_CREATE", "Can't create.") . $title);
}
return $dropdownArray;
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:34,代码来源:EcommerceClassNameOrTypeDropdownField.php
示例2: getClasses
/**
* Gets the classes that can be created using this button, defaulting to the model class and
* its subclasses.
*
* @param GridField $grid
* @return array a map of class name to title
*/
public function getClasses(GridField $grid)
{
$result = array();
if (is_null($this->classes)) {
$classes = array_values(ClassInfo::subclassesFor($grid->getModelClass()));
sort($classes);
} else {
$classes = $this->classes;
}
$kill_ancestors = array();
foreach ($classes as $class => $title) {
if (!is_string($class)) {
$class = $title;
$is_abstract = ($reflection = new ReflectionClass($class)) && $reflection->isAbstract();
if (!$is_abstract) {
$title = singleton($class)->i18n_singular_name();
}
} else {
$is_abstract = ($reflection = new ReflectionClass($class)) && $reflection->isAbstract();
}
if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor', Config::FIRST_SET)) {
$kill_ancestors[$ancestor_to_hide] = true;
}
if ($is_abstract || !singleton($class)->canCreate()) {
continue;
}
$result[$class] = $title;
}
if ($kill_ancestors) {
foreach ($kill_ancestors as $class => $bool) {
unset($result[$class]);
}
}
return $result;
}
示例3: getModularCMSFields
function getModularCMSFields($relationName = 'Modules', $title = 'Content Modules')
{
$fields = array();
$GLOBALS['_CONTENT_MODULE_PARENT_PAGEID'] = $this->owner->ID;
$area = $this->owner->obj($relationName);
if ($area && $area->exists()) {
$fields[] = HeaderField::create($relationName . 'Header', $title, 2);
$fields[] = GridField::create($relationName, $title, $area->Modules(), GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldOrderableRows('SortOrder'))->removeComponentsByType('GridFieldAddNewButton')->addComponent($add = new GridFieldAddNewMultiClass()));
if (($allowed_modules = $this->owner->Config()->get('allowed_modules')) && is_array($allowed_modules) && count($allowed_modules)) {
if (isset($allowed_modules[$relationName])) {
$add->setClasses($allowed_modules[$relationName]);
} else {
$add->setClasses($allowed_modules);
}
} else {
// Remove the base "ContentModule" from allowed modules.
$classes = array_values(ClassInfo::subclassesFor('ContentModule'));
sort($classes);
if (($key = array_search('ContentModule', $classes)) !== false) {
unset($classes[$key]);
}
$add->setClasses($classes);
}
} else {
$fields[] = LiteralField::create('SaveFirstToAddModules', '<div class="message">You must save first before you can add modules.</div>');
}
return $fields;
}
示例4: updateFieldConfiguration
/**
* Add an option to include in the comment
*/
public function updateFieldConfiguration(FieldList $fields)
{
if (in_array($this->owner->Parent()->Classname, ClassInfo::subclassesFor('Consultation'))) {
$comment = CheckboxField::create($this->owner->getSettingName('CommentField'), _t('CONSULTATION.INCLUDEINCOMMENT', 'Include this field in comment post'), $this->owner->getSetting('CommentField'));
$fields->push($comment);
}
}
示例5: containsFiles
/**
* Returns true if the folder contains files
* @return boolean
*/
public function containsFiles()
{
if (!$this->owner instanceof Folder) {
return false;
}
return (bool) DB::query("SELECT COUNT(*) FROM File WHERE ParentID = " . (int) $this->owner->ID . " AND ClassName NOT IN ('" . implode("','", array_values(ClassInfo::subclassesFor('Folder'))) . "')")->value();
}
开发者ID:hamishcampbell,项目名称:silverstripe-securefiles,代码行数:11,代码来源:SecureFileTokenPermissionDecorator.php
示例6: updateCMSFields
function updateCMSFields(FieldList $fields)
{
if ($attributes = $fields->fieldByName("ProductAttributeType")) {
$attributes->getConfig()->removeComponentsByType("GridFieldAddNewButton")->addComponent($multiclass = new GridFieldAddNewMultiClass());
$multiclass->setClasses(array_values(ClassInfo::subclassesFor("ProductAttributeType")));
}
}
示例7: get_all_tests
/**
* @return Array
*/
public static function get_all_tests()
{
ManifestBuilder::load_test_manifest();
$tests = ClassInfo::subclassesFor('SapphireTest');
array_shift($tests);
return $tests;
}
示例8: testEveryFieldTransformsDisabledAsClone
public function testEveryFieldTransformsDisabledAsClone()
{
$fieldClasses = ClassInfo::subclassesFor('FormField');
foreach ($fieldClasses as $fieldClass) {
$reflectionClass = new ReflectionClass($fieldClass);
if (!$reflectionClass->isInstantiable()) {
continue;
}
$constructor = $reflectionClass->getMethod('__construct');
if ($constructor->getNumberOfRequiredParameters() > 1) {
continue;
}
if ($fieldClass == 'CompositeField' || is_subclass_of($fieldClass, 'CompositeField')) {
continue;
}
if ($fieldClass = 'NullableField') {
$instance = new $fieldClass(new TextField("{$fieldClass}_instance"));
} else {
$instance = new $fieldClass("{$fieldClass}_instance");
}
$isDisabledBefore = $instance->isDisabled();
$disabledInstance = $instance->performDisabledTransformation();
$this->assertEquals($isDisabledBefore, $instance->isDisabled(), "FormField class {$fieldClass} retains its disabled state after calling performDisabledTransformation()");
$this->assertTrue($disabledInstance->isDisabled(), "FormField class {$fieldClass} returns a valid disabled representation as of isDisabled()");
$this->assertNotSame($disabledInstance, $instance, "FormField class {$fieldClass} returns a valid cloned disabled representation");
}
}
示例9: getItems
/**
* @return SS_List of SilverStripeNavigatorItem
*/
function getItems() {
$items = array();
$classes = ClassInfo::subclassesFor('SilverStripeNavigatorItem');
array_shift($classes);
// Sort menu items according to priority
$i = 0;
foreach($classes as $class) {
// Skip base class
if($class == 'SilverStripeNavigatorItem') continue;
$i++;
$item = new $class($this->record);
if(!$item->canView()) continue;
// This funny litle formula ensures that the first item added with the same priority will be left-most.
$priority = $item->getPriority() * 100 - 1;
// Ensure that we can have duplicates with the same (default) priority
while(isset($items[$priority])) $priority++;
$items[$priority] = $item;
}
ksort($items);
return new ArrayList($items);
}
示例10: createreport
/**
* Create a new report
*
* @param array $data
* @param Form $form
*/
public function createreport($data, $form)
{
// assume a user's okay if they can edit the reportholder
// @TODO have a new create permission here?
if ($this->data()->canEdit()) {
$type = $data['ReportType'];
$classes = ClassInfo::subclassesFor('AdvancedReport');
if (!in_array($type, $classes)) {
throw new Exception("Invalid report type");
}
$report = new ReportPage();
$report->Title = $data['ReportName'];
$report->MetaDescription = isset($data['ReportDescription']) ? $data['ReportDescription'] : '';
$report->ReportType = $type;
$report->ParentID = $this->data()->ID;
$oldMode = Versioned::get_reading_mode();
Versioned::reading_stage('Stage');
$report->write();
$report->doPublish();
Versioned::reading_stage('Live');
$this->redirect($report->Link());
} else {
$form->sessionMessage(_t('ReporHolder.NO_PERMISSION', 'You do not have permission to do that'), 'warning');
$this->redirect($this->data()->Link());
}
}
示例11: getOwnerPage
/**
* Return an ArrayList of pages with the Element Page Extension
*
* @return ArrayList
*/
public function getOwnerPage()
{
$originalMode = Versioned::current_stage();
Versioned::reading_stage('Stage');
foreach (get_declared_classes() as $class) {
if (is_subclass_of($class, 'SiteTree')) {
$object = singleton($class);
$classes = ClassInfo::subclassesFor('ElementPageExtension');
$isElemental = false;
foreach ($classes as $extension) {
if ($object->hasExtension($extension)) {
$isElemental = true;
}
}
if ($isElemental) {
$page = $class::get()->filter('ElementAreaID', $this->ID);
if ($page && $page->exists()) {
Versioned::reading_stage($originalMode);
return $page->first();
}
}
}
}
Versioned::reading_stage($originalMode);
return false;
}
示例12: Modules
/**
* Model classes, grouped by Module
*/
function Modules() {
$classes = ClassInfo::subclassesFor('DataObject');
array_shift($classes);
$modules = array();
foreach($classes as $class) {
$model = new ModelViewer_Model($class);
if(!isset($modules[$model->Module])) $modules[$model->Module] = new DataObjectSet();
$modules[$model->Module]->push($model);
}
ksort($modules);
unset($modules['userforms']);
if($this->module) {
$modules = array($this->module => $modules[$this->module]);
}
$output = new DataObjectSet();
foreach($modules as $moduleName => $models) {
$output->push(new ArrayData(array(
'Link' => 'dev/viewmodel/' . $moduleName,
'Name' => $moduleName,
'Models' => $models,
)));
}
return $output;
}
示例13: ReplaceFileFields
/**
* ReplaceFileFields
*/
public static function ReplaceFileFields()
{
if (Config::inst()->get('CloudinaryConfigs', 'replace_relationships')) {
$arrRelationships = array('has_one', 'has_many', 'many_many');
$classes = ClassInfo::subclassesFor('DataObject');
foreach ($classes as $className) {
foreach ($arrRelationships as $relationType) {
if ($relation = Config::inst()->get($className, $relationType)) {
if (in_array('File', $relation) || in_array('Image', $relation)) {
$updateRelations = array();
foreach ($relation as $field => $type) {
$newType = $type;
if ($type == 'File') {
$newType = 'CloudinaryFile';
}
if ($type == 'Image') {
$newType = 'CloudinaryImage';
}
$updateRelations[$field] = $newType;
}
Config::inst()->update($className, $relationType, $updateRelations);
}
}
}
}
}
}
示例14: getManagedModels
function getManagedModels()
{
$classes = $this->stat('managed_models');
if (is_string($classes)) {
$matches = explode(",", $classes);
foreach ($matches as $key => $value) {
$matches[$key] = substr($value, 10);
}
// remove "decorator:"
if (is_array($matches)) {
$classes = array();
foreach (ClassInfo::subclassesFor('DataObject') as $class) {
$add = false;
// used to guarantee that if multiple matches on a class it's not added multiple times.
foreach ($matches as $match) {
if (Object::has_extension($class, $match)) {
$add = true;
}
}
if ($add) {
$classes[] = $class;
}
}
if (count($class) > 1) {
array_unshift($classes, 'All');
}
} else {
$classes = array($classes);
}
}
return $classes;
}
示例15: generatePageIconsCss
/**
* Include CSS for page icons. We're not using the JSTree 'types' option
* because it causes too much performance overhead just to add some icons.
*
* @return String CSS
*/
public function generatePageIconsCss()
{
$css = '';
$classes = ClassInfo::subclassesFor('SiteTree');
foreach ($classes as $class) {
$obj = singleton($class);
$iconSpec = $obj->stat('icon');
if (!$iconSpec) {
continue;
}
// Legacy support: We no longer need separate icon definitions for folders etc.
$iconFile = is_array($iconSpec) ? $iconSpec[0] : $iconSpec;
// Legacy support: Add file extension if none exists
if (!pathinfo($iconFile, PATHINFO_EXTENSION)) {
$iconFile .= '-file.gif';
}
$iconPathInfo = pathinfo($iconFile);
// Base filename
$baseFilename = $iconPathInfo['dirname'] . '/' . $iconPathInfo['filename'];
$fileExtension = $iconPathInfo['extension'];
$selector = ".page-icon.class-{$class}, li.class-{$class} > a .jstree-pageicon";
if (Director::fileExists($iconFile)) {
$css .= "{$selector} { background: transparent url('{$iconFile}') 0 0 no-repeat; }\n";
} else {
// Support for more sophisticated rules, e.g. sprited icons
$css .= "{$selector} { {$iconFile} }\n";
}
}
return $css;
}