本文整理汇总了PHP中ClassInfo类的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo类的具体用法?PHP ClassInfo怎么用?PHP ClassInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
}
示例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']);
}
示例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);
}
}
示例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';
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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++]);
}
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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';
}