本文整理汇总了PHP中ClassInfo类的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo类的具体用法?PHP ClassInfo怎么用?PHP ClassInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Implement this method in the task subclass to
* execute via the TaskRunner
*/
public function run($request)
{
if (!($adminEmail = $this->config()->get('administrator_email'))) {
$contenders = $this->extend('feedMeAdminEmail') ?: [];
$adminEmail = reset($contenders);
}
if ($adminEmail) {
SS_Log::add_writer(new SS_LogEmailWriter($adminEmail, SS_Log::INFO));
}
// anything like a warning or above
SS_Log::add_writer(new SS_LogEmailWriter(Security::findAnAdministrator()->Email), SS_Log::WARN);
$excludedFeedClasses = $this->config()->get('excluded_feed_class_names');
// for each implementor of the FeedMeFeedInterface check if it's not excluded then for each
// instance of that model call feedMeImport on it.
$implementors = ClassInfo::implementorsOf('FeedMeFeedModelInterface');
foreach ($implementors as $className) {
// chance to disable a feed by setting config.excluded_feed_class_names
if (!in_array($className, $excludedFeedClasses)) {
/** @var FeedMeFeedModelExtension $feedModel */
foreach ($className::get() as $feedModel) {
$feedModel->feedMeImport();
}
}
}
}
开发者ID:CrackerjackDigital,项目名称:silverstripe-feedme,代码行数:29,代码来源:FeedSyncTask.php
示例2: index
public function index()
{
$subclasses = ClassInfo::subclassesFor($this->class);
unset($subclasses[$this->class]);
if ($subclasses) {
$subclass = array_pop($subclasses);
$task = new $subclass();
$task->index();
return;
}
// Check if access key exists
if (!isset($_REQUEST['Key'])) {
echo 'Error: Access validation failed. No "Key" specified.';
return;
}
// Check against access key defined in _config.php
if ($_REQUEST['Key'] != EMAIL_BOUNCEHANDLER_KEY) {
echo 'Error: Access validation failed. Invalid "Key" specified.';
return;
}
if (!$_REQUEST['Email']) {
echo "No email address";
return;
}
$this->recordBounce($_REQUEST['Email'], $_REQUEST['Date'], $_REQUEST['Time'], $_REQUEST['Message']);
}
开发者ID:helpfulrobot,项目名称:silverstripe-emailbouncehandler,代码行数:26,代码来源:Email_BounceHandler.php
示例3: __construct
/**
* Initializes context.
* Every scenario gets it's own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters)
{
parent::__construct($parameters);
$this->useContext('BasicContext', new BasicContext($parameters));
$this->useContext('LoginContext', new LoginContext($parameters));
$this->useContext('CmsFormsContext', new CmsFormsContext($parameters));
$this->useContext('CmsUiContext', new CmsUiContext($parameters));
$fixtureContext = new FixtureContext($parameters);
$fixtureContext->setFixtureFactory($this->getFixtureFactory());
$this->useContext('FixtureContext', $fixtureContext);
// Use blueprints to set user name from identifier
$factory = $fixtureContext->getFixtureFactory();
$blueprint = \Injector::inst()->create('FixtureBlueprint', 'Member');
$blueprint->addCallback('beforeCreate', function ($identifier, &$data, &$fixtures) {
if (!isset($data['FirstName'])) {
$data['FirstName'] = $identifier;
}
});
$factory->define('Member', $blueprint);
// Auto-publish pages
foreach (\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
$blueprint->addCallback('afterCreate', function ($obj, $identifier, &$data, &$fixtures) {
$obj->publish('Stage', 'Live');
});
$factory->define($class, $blueprint);
}
}
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:34,代码来源:FeatureContext.php
示例4: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('ConfiguredScheduleID');
$interval = $fields->dataFieldByName('Interval')->setDescription('Number of seconds between each run. e.g 3600 is 1 hour');
$fields->replaceField('Interval', $interval);
$dt = new DateTime();
$fields->replaceField('StartDate', DateField::create('StartDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y')));
$fields->replaceField('EndDate', DateField::create('EndDate')->setConfig('dateformat', 'dd/MM/yyyy')->setConfig('showcalendar', true)->setDescription('DD/MM/YYYY e.g. ' . $dt->format('d/m/y')));
if ($this->ID == null) {
foreach ($fields->dataFields() as $field) {
//delete all included fields
$fields->removeByName($field->Name);
}
$rangeTypes = ClassInfo::subclassesFor('ScheduleRange');
$fields->addFieldToTab('Root.Main', TextField::create('Title', 'Title'));
$fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Range Type', $rangeTypes));
} else {
$fields->addFieldToTab('Root.Main', ReadonlyField::create('ClassName', 'Type'));
}
if ($this->ClassName == __CLASS__) {
$fields->removeByName('ApplicableDays');
}
return $fields;
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-schedulizer,代码行数:25,代码来源:ScheduleRange.php
示例5: __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
示例6: 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
示例7: 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);
}
}
开发者ID:dnadesign,项目名称:silverstripe-consultations,代码行数:10,代码来源:ConsultationFormField.php
示例8: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
if ($this->owner->ID) {
// Relation handler for Blocks
$SConfig = GridFieldConfig_RelationEditor::create(25);
$SConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
$SConfig->addComponent(new GridFieldDeleteAction());
// If the copy button module is installed, add copy as option
if (class_exists('GridFieldCopyButton')) {
$SConfig->addComponent(new GridFieldCopyButton(), 'GridFieldDeleteAction');
}
$gridField = new GridField("Blocks", "Content blocks", $this->owner->Blocks(), $SConfig);
$classes = array_values(ClassInfo::subclassesFor($gridField->getModelClass()));
if (count($classes) > 1 && class_exists('GridFieldAddNewMultiClass')) {
$SConfig->removeComponentsByType('GridFieldAddNewButton');
$SConfig->addComponent(new GridFieldAddNewMultiClass());
}
if (self::$create_block_tab) {
$fields->addFieldToTab("Root.Blocks", $gridField);
} else {
// Downsize the content field
$fields->removeByName('Content');
$fields->addFieldToTab('Root.Main', HTMLEditorField::create('Content')->setRows(self::$contentarea_rows), 'Metadata');
$fields->addFieldToTab("Root.Main", $gridField, 'Metadata');
}
}
return $fields;
}
开发者ID:Design-Collective,项目名称:Silverstripe-Content-Blocks,代码行数:28,代码来源:ContentBlocksModule.php
示例9: updateSolrSearchableFields
/**
* Retrieve the existing searchable fields, appending our custom search index to enable it.
* @return array
*/
public function updateSolrSearchableFields(&$fields)
{
// Make sure the extension requirements have been met before enabling the custom search index.
if (ClassInfo::exists('QueuedJob')) {
$fields[$this->index] = true;
}
}
开发者ID:helpfulrobot,项目名称:silverstripe-solr,代码行数:11,代码来源:SiteTreePermissionIndexExtension.php
示例10: 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;
}
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:36,代码来源:LeftAndMainPageIconsExtension.php
示例11: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this()->hasExtension(HasBlocks::class_name())) {
/** @var \ManyManyList $existing */
$existing = $this()->{HasBlocks::relationship_name()}();
if ($this()->{self::SingleFieldName} || $this()->WasNew) {
if ($defaultBlockClasses = $this->getDefaultBlockClasses()) {
// get class names along with count of each expected
$expected = array_count_values($defaultBlockClasses);
$sort = $existing->count() + 1;
foreach ($expected as $blockClass => $expectedCount) {
if (!\ClassInfo::exists($blockClass)) {
continue;
}
$existingCount = $existing->filter('ClassName', $blockClass)->count();
if ($existingCount < $expectedCount) {
for ($i = $existingCount; $i < $expectedCount; $i++) {
// generate a default title for the block from lang
// e.g. ContentBlock.DefaultTitle
$templateVars = ['pagetitle' => $this()->{Title::SingleFieldName}, 'singular' => singleton($blockClass)->i18n_singular_name(), 'index' => $i + 1];
// try the block class.DefaultTitle and then Block.DefaultTitle
$title = _t("{$blockClass}.DefaultTitle", _t('Block.DefaultTitle', '{pagetitle} {singular} - {index}', $templateVars), $templateVars);
/** @var Block $block */
$block = new $blockClass();
$block->update(['Title' => $title]);
$block->write();
$existing->add($block, ['Sort' => $sort++]);
}
}
}
}
}
}
}
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:35,代码来源:AddDefaultBlocks.php
示例12: getAllowedClasses
/**
* 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 getAllowedClasses(\GridField $grid)
{
$result = array();
if ($this->useAllowedClasses) {
$classes = $this->useAllowedClasses;
$this->useAllowedClasses = null;
return $classes;
} else {
if (is_null($this->allowedClasses)) {
$classes = array_values(\ClassInfo::subclassesFor($grid->getModelClass()));
sort($classes);
} else {
$classes = $this->allowedClasses;
}
}
foreach ($classes as $class => $title) {
if (!is_string($class)) {
$class = $title;
$title = singleton($class)->i18n_singular_name();
}
if (!singleton($class)->canCreate()) {
continue;
}
$result[$class] = $title;
}
return $result;
}
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-gridfield-utils,代码行数:34,代码来源:AddNewInlineExtended_MultiClass.php
示例13: 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;
}
开发者ID:christopherbolt,项目名称:silverstripe-contentmodules,代码行数:28,代码来源:ModularPageExtension.php
示例14: 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;
}
开发者ID:spreadzz,项目名称:silverstripe-gridfieldextensions,代码行数:42,代码来源:GridFieldAddNewMultiClass.php
示例15: __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
示例16: 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")));
}
}
开发者ID:helpfulrobot,项目名称:silvershop-coloredvariations,代码行数:7,代码来源:ColoredProductAttributeAdmin.php
示例17: getModifier
/**
* Retrieve a modifier of a given class for the order.
* Modifier will be retrieved from database if it already exists,
* or created if it is always required.
*
* @param string $className
* @param boolean $forcecreate - force the modifier to be created.
*/
public function getModifier($className, $forcecreate = false)
{
if (!ClassInfo::exists($className)) {
user_error("Modifier class \"{$className}\" does not exist.");
}
//search for existing
$modifier = $className::get()->filter("OrderID", $this->order->ID)->first();
if ($modifier) {
//remove if no longer valid
if (!$modifier->valid()) {
//TODO: need to provide feedback message - why modifier was removed
$modifier->delete();
$modifier->destroy();
return null;
}
return $modifier;
}
$modifier = new $className();
if ($modifier->required() || $forcecreate) {
//create any modifiers that are required for every order
$modifier->OrderID = $this->order->ID;
$modifier->write();
$this->order->Modifiers()->add($modifier);
return $modifier;
}
return null;
}
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:35,代码来源:OrderTotalCalculator.php
示例18: AvailableWidgets
/**
*
* @return ArrayList
*/
public function AvailableWidgets()
{
$widgets = new ArrayList();
foreach ($this->widgetClasses as $widgetClass) {
$classes = ClassInfo::subclassesFor($widgetClass);
if (isset($classes['Widget'])) {
unset($classes['Widget']);
} else {
if (isset($classes[0]) && $classes[0] == 'Widget') {
unset($classes[0]);
}
}
foreach ($classes as $class) {
$available = Config::inst()->get($class, 'only_available_in');
if (!empty($available) && is_array($available)) {
if (in_array($this->Name, $available)) {
$widgets->push(singleton($class));
}
} else {
$widgets->push(singleton($class));
}
}
}
return $widgets;
}
开发者ID:hailwood,项目名称:silverstripe-widgets,代码行数:29,代码来源:WidgetAreaEditor.php
示例19: ShortcodeForm
/**
* Provides a GUI for the insert/edit shortcode popup
* @return Form
**/
public function ShortcodeForm()
{
if (!Permission::check('CMS_ACCESS_CMSMain')) {
return;
}
Config::inst()->update('SSViewer', 'theme_enabled', false);
// create a list of shortcodable classes for the ShortcodeType dropdown
$classList = ClassInfo::implementorsOf('Shortcodable');
$classes = array();
foreach ($classList as $class) {
$classes[$class] = singleton($class)->singular_name();
}
// load from the currently selected ShortcodeType or Shortcode data
$classname = false;
$shortcodeData = false;
if ($shortcode = $this->request->requestVar('Shortcode')) {
$shortcode = str_replace("", '', $shortcode);
//remove BOM inside string on cursor position...
$shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
if (isset($shortcodeData[0])) {
$shortcodeData = $shortcodeData[0];
$classname = $shortcodeData['name'];
}
} else {
$classname = $this->request->requestVar('ShortcodeType');
}
if ($shortcodeData) {
$headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
} else {
$headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
}
// essential fields
$fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
// attribute and object id fields
if ($classname) {
if (class_exists($classname)) {
$class = singleton($classname);
if (is_subclass_of($class, 'DataObject')) {
if (singleton($classname)->hasMethod('get_shortcodable_records')) {
$dataObjectSource = $classname::get_shortcodable_records();
} else {
$dataObjectSource = $classname::get()->map()->toArray();
}
$fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
}
if ($attrFields = $classname::shortcode_attribute_fields()) {
$fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
}
}
}
// actions
$actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
// form
$form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
if ($shortcodeData) {
$form->loadDataFrom($shortcodeData['atts']);
}
$this->extend('updateShortcodeForm', $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-shortcodable,代码行数:64,代码来源:ShortcodableController.php
示例20: get_all
/**
* Returns an array of all implementors of the `IIndicator` interface.
*
* @return IIndicator[] list of all implementors
*/
public static function get_all()
{
$indicators = \ClassInfo::implementorsOf(self::$interface_name);
return array_map(function ($indicatorName) {
return \Object::create($indicatorName);
}, $indicators);
}
开发者ID:helpfulrobot,项目名称:ntb-silverstripe-statistics,代码行数:12,代码来源:IndicatorFactory.php
注:本文中的ClassInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论