本文整理汇总了PHP中ClassInfo::baseDataClass方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo::baseDataClass方法的具体用法?PHP ClassInfo::baseDataClass怎么用?PHP ClassInfo::baseDataClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo::baseDataClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAllChildrenIncludingDeleted
public function doAllChildrenIncludingDeleted($context = null)
{
if (!$this->owner) {
user_error('Hierarchy::doAllChildrenIncludingDeleted() called without $this->owner');
}
$baseClass = ClassInfo::baseDataClass($this->owner->class);
if ($baseClass) {
$stageChildren = $this->owner->stageChildren(true);
$stageChildren = $this->RemoveNewsPostsFromSiteTree($stageChildren);
// Add live site content that doesn't exist on the stage site, if required.
if ($this->owner->hasExtension('Versioned')) {
// Next, go through the live children. Only some of these will be listed
$liveChildren = $this->owner->liveChildren(true, true);
if ($liveChildren) {
$liveChildren = $this->RemoveNewsPostsFromSiteTree($liveChildren);
$merged = new ArrayList();
$merged->merge($stageChildren);
$merged->merge($liveChildren);
$stageChildren = $merged;
}
}
$this->owner->extend("augmentAllChildrenIncludingDeleted", $stageChildren, $context);
} else {
user_error("Hierarchy::AllChildren() Couldn't determine base class for '{$this->owner->class}'", E_USER_ERROR);
}
return $stageChildren;
}
示例2: stageChildren
public function stageChildren($showAll = false)
{
$children = new ArrayList();
$repo = $this->source->getRemoteRepository();
try {
if ($repo->isConnected()) {
$ssId = $this->getSS_ID();
if (!$ssId) {
$ssId = '0';
}
$kids = $repo->getChildren(array('ClassName' => ClassInfo::baseDataClass($this->getType()), 'ParentID' => $this->getSS_ID()));
if (!$kids) {
throw new Exception("No kids and null object returned for children of " . $this->getSS_ID());
}
// Even though it returns actual dataobjects, we need to wrap them for sanity and safety's sake
foreach ($kids as $childItem) {
$item = $this->source->getObject($childItem);
$children->push($item);
}
}
} catch (Exception $fre) {
SS_Log::log($fre, SS_Log::WARN);
return $children;
}
return $children;
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-connector,代码行数:26,代码来源:SilverStripeContentItem.php
示例3: 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;
}
示例4: testApplyReplationDeepInheretence
public function testApplyReplationDeepInheretence()
{
//test has_one relation
$newDQ = new DataQuery('DataQueryTest_E');
//apply a relation to a relation from an ancestor class
$newDQ->applyRelation('TestA');
$this->assertTrue($newDQ->query()->isJoinedTo('DataQueryTest_C'));
$this->assertContains('"DataQueryTest_A"."ID" = "DataQueryTest_C"."TestAID"', $newDQ->sql($params));
//test many_many relation
//test many_many with separate inheritance
$newDQ = new DataQuery('DataQueryTest_C');
$baseDBTable = ClassInfo::baseDataClass('DataQueryTest_C');
$newDQ->applyRelation('ManyTestAs');
//check we are "joined" to the DataObject's table (there is no distinction between FROM or JOIN clauses)
$this->assertTrue($newDQ->query()->isJoinedTo($baseDBTable));
//check we are explicitly selecting "FROM" the DO's table
$this->assertContains("FROM \"{$baseDBTable}\"", $newDQ->sql());
//test many_many with shared inheritance
$newDQ = new DataQuery('DataQueryTest_E');
$baseDBTable = ClassInfo::baseDataClass('DataQueryTest_E');
//check we are "joined" to the DataObject's table (there is no distinction between FROM or JOIN clauses)
$this->assertTrue($newDQ->query()->isJoinedTo($baseDBTable));
//check we are explicitly selecting "FROM" the DO's table
$this->assertContains("FROM \"{$baseDBTable}\"", $newDQ->sql(), 'The FROM clause is missing from the query');
$newDQ->applyRelation('ManyTestGs');
//confirm we are still joined to the base table
$this->assertTrue($newDQ->query()->isJoinedTo($baseDBTable));
//double check it is the "FROM" clause
$this->assertContains("FROM \"{$baseDBTable}\"", $newDQ->sql(), 'The FROM clause has been removed from the query');
//another (potentially less crude check) for checking "FROM" clause
$fromTables = $newDQ->query()->getFrom();
$this->assertEquals('"' . $baseDBTable . '"', $fromTables[$baseDBTable]);
}
示例5: onBeforeWrite
protected function onBeforeWrite()
{
if ($this->isChanged('ParentClass')) {
$this->ParentClass = ClassInfo::baseDataClass($this->ParentClass);
}
parent::onBeforeWrite();
}
示例6: getManipulatedData
public function getManipulatedData(GridField $gridField, SS_List $list)
{
if (!$list instanceof RelationList) {
user_error('GridFieldManyRelationHandler requires the GridField to have a RelationList. Got a ' . get_class($list) . ' instead.', E_USER_WARNING);
}
$state = $this->getState($gridField);
// We don't use setupState() as we need the list
if ($state->FirstTime) {
$state->RelationVal = array_values($list->getIdList()) ?: array();
}
if (!$state->ShowingRelation && $this->useToggle) {
return $list;
}
$query = clone $list->dataQuery();
try {
$query->removeFilterOn($this->cheatList->getForeignIDFilter($list));
} catch (InvalidArgumentException $e) {
/* NOP */
}
$orgList = $list;
$list = new DataList($list->dataClass());
$list = $list->setDataQuery($query);
if ($orgList instanceof ManyManyList) {
$joinTable = $this->cheatManyList->getJoinTable($orgList);
$baseClass = ClassInfo::baseDataClass($list->dataClass());
$localKey = $this->cheatManyList->getLocalKey($orgList);
$query->leftJoin($joinTable, "\"{$joinTable}\".\"{$localKey}\" = \"{$baseClass}\".\"ID\"");
$list = $list->setDataQuery($query);
}
return $list;
}
开发者ID:helpfulrobot,项目名称:arillo-gridfieldrelationhandler,代码行数:31,代码来源:GridFieldManyRelationHandler.php
示例7: find
/**
* @return array
*/
public function find()
{
$base_entity = singleton($this->table_name);
$relation_name = $this->alias->getName();
$class_name = ClassInfo::baseDataClass($this->table_name);
$subclasses = array_keys(ClassInfo::subclassesFor($class_name));
do {
// relationships ...
$has_many = Config::inst()->get($class_name, 'has_many');
$has_many_many = Config::inst()->get($class_name, 'many_many');
$has_one = Config::inst()->get($class_name, 'has_one');
$belongs_many_many = Config::inst()->get($class_name, 'belongs_many_many');
if (!is_null($has_many) && array_key_exists($relation_name, $has_many)) {
break;
}
if (!is_null($has_one) && array_key_exists($relation_name, $has_one)) {
break;
}
if (!is_null($has_many_many) && array_key_exists($relation_name, $has_many_many)) {
break;
}
if (!is_null($belongs_many_many) && array_key_exists($relation_name, $belongs_many_many)) {
break;
}
$class_name = array_pop($subclasses);
if (is_null($class_name)) {
// we arrive to the end of the hierarchy and didnt find any relation with that name
throw new InvalidArgumentException(sprintf(' relation %s does not exist for %s', $relation_name, $this->table_name));
}
$base_entity = singleton($class_name);
} while (true);
return array($base_entity, $has_one, $has_many, $has_many_many, $belongs_many_many);
}
示例8: handleBatchAction
public function handleBatchAction($request)
{
// This method can't be called without ajax.
if (!$request->isAjax()) {
$this->parentController->redirectBack();
return;
}
// Protect against CSRF on destructive action
if (!SecurityToken::inst()->checkRequest($request)) {
return $this->httpError(400);
}
$actions = $this->batchActions();
$actionClass = $actions[$request->param('BatchAction')]['class'];
$actionHandler = new $actionClass();
// Sanitise ID list and query the database for apges
$ids = preg_split('/ *, */', trim($request->requestVar('csvIDs')));
foreach ($ids as $k => $v) {
if (!is_numeric($v)) {
unset($ids[$k]);
}
}
if ($ids) {
if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
Translatable::disable_locale_filter();
}
$pages = DataObject::get($this->recordClass, sprintf('"%s"."ID" IN (%s)', ClassInfo::baseDataClass($this->recordClass), implode(", ", $ids)));
if (class_exists('Translatable') && SiteTree::has_extension('Translatable')) {
Translatable::enable_locale_filter();
}
$record_class = $this->recordClass;
if ($record_class::has_extension('Versioned')) {
// If we didn't query all the pages, then find the rest on the live site
if (!$pages || $pages->Count() < sizeof($ids)) {
foreach ($ids as $id) {
$idsFromLive[$id] = true;
}
if ($pages) {
foreach ($pages as $page) {
unset($idsFromLive[$page->ID]);
}
}
$idsFromLive = array_keys($idsFromLive);
$sql = sprintf('"%s"."ID" IN (%s)', $this->recordClass, implode(", ", $idsFromLive));
$livePages = Versioned::get_by_stage($this->recordClass, 'Live', $sql);
if ($pages) {
// Can't merge into a DataList, need to condense into an actual list first
// (which will retrieve all records as objects, so its an expensive operation)
$pages = new ArrayList($pages->toArray());
$pages->merge($livePages);
} else {
$pages = $livePages;
}
}
}
} else {
$pages = new ArrayList();
}
return $actionHandler->run($pages);
}
示例9: ItemEditForm
function ItemEditForm()
{
$form = parent::ItemEditForm();
$actions = $form->Actions();
$majorActions = CompositeField::create()->setName('MajorActions')->setTag('fieldset')->addExtraClass('ss-ui-buttonset');
$rootTabSet = new TabSet('ActionMenus');
$moreOptions = new Tab('MoreOptions', _t('SiteTree.MoreOptions', 'More options', 'Expands a view for more buttons'));
$rootTabSet->push($moreOptions);
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus');
// Render page information into the "more-options" drop-up, on the top.
$baseClass = ClassInfo::baseDataClass($this->record->class);
$live = Versioned::get_one_by_stage($this->record->class, 'Live', "\"{$baseClass}\".\"ID\"='{$this->record->ID}'");
$existsOnLive = $this->record->getExistsOnLive();
$published = $this->record->isPublished();
$moreOptions->push(new LiteralField('Information', $this->record->customise(array('Live' => $live, 'ExistsOnLive' => $existsOnLive))->renderWith('SiteTree_Information')));
$actions->removeByName('action_doSave');
$actions->removeByName('action_doDelete');
if ($this->record->canEdit()) {
if ($this->record->IsDeletedFromStage) {
if ($existsOnLive) {
$majorActions->push(FormAction::create('revert', _t('CMSMain.RESTORE', 'Restore')));
if ($this->record->canDelete() && $this->record->canDeleteFromLive()) {
$majorActions->push(FormAction::create('unpublish', _t('CMSMain.DELETEFP', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
}
} else {
if (!$this->record->isNew()) {
$majorActions->push(FormAction::create('restore', _t('CMSMain.RESTORE', 'Restore'))->setAttribute('data-icon', 'decline'));
} else {
$majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
$majorActions->push(FormAction::create('publish', _t('SiteTree.BUTTONPUBLISHED', 'Published'))->addExtraClass('ss-ui-alternate ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true));
}
}
} else {
if ($this->record->canDelete() && !$published) {
$moreOptions->push(FormAction::create('delete', _t('SiteTree.BUTTONDELETE', 'Delete draft'))->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
}
$majorActions->push(FormAction::create('save', _t('SiteTree.BUTTONSAVED', 'Saved'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'addpage')->setAttribute('data-text-alternate', _t('CMSMain.SAVEDRAFT', 'Save draft'))->setUseButtonTag(true));
}
}
$publish = FormAction::create('publish', $published ? _t('SiteTree.BUTTONPUBLISHED', 'Published') : _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setAttribute('data-icon', 'accept')->setAttribute('data-icon-alternate', 'disk')->setAttribute('data-text-alternate', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save & publish'))->setUseButtonTag(true);
if (!$published || $this->record->stagesDiffer('Stage', 'Live') && $published) {
$publish->addExtraClass('ss-ui-alternate');
}
if ($this->record->canPublish() && !$this->record->IsDeletedFromStage) {
$majorActions->push($publish);
}
if ($published && $this->record->canPublish() && !$this->record->IsDeletedFromStage && $this->record->canDeleteFromLive()) {
$moreOptions->push(FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true));
}
if ($this->record->stagesDiffer('Stage', 'Live') && !$this->record->IsDeletedFromStage && $this->record->isPublished() && $this->record->canEdit()) {
$moreOptions->push(FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'))->setDescription(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'))->setUseButtonTag(true));
}
$actions->push($majorActions);
$actions->push($rootTabSet);
if ($this->record->hasMethod('getCMSValidator')) {
$form->setValidator($this->record->getCMSValidator());
}
return $form;
}
开发者ID:helpfulrobot,项目名称:studiobonito-silverstripe-publishable,代码行数:59,代码来源:PublishableGridFieldDetailForm.php
示例10: augmentSQL
/**
* @param SQLQuery $query
* @param DataQuery $dataQuery
*/
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
{
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
if (class_exists('Subsite')) {
$currentSubsiteID = Subsite::currentSubsiteID();
$query->addWhere("\"{$baseTable}\".\"SubsiteID\" = '{$currentSubsiteID}'");
}
}
示例11: testBaseDataClass
/**
* @covers ClassInfo::baseDataClass()
*/
public function testBaseDataClass()
{
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_BaseClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_ChildClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GrandChildClass'));
$this->setExpectedException('InvalidArgumentException');
ClassInfo::baseDataClass('DataObject');
}
示例12: onAfterPublish
public function onAfterPublish()
{
if (isset($this->owner->temp__ChangeablePublishDateValue)) {
$this->owner->LastEdited = $this->owner->temp__ChangeablePublishDateValue;
unset($this->owner->temp__ChangeablePublishDateValue);
$table_name = ClassInfo::baseDataClass($this->owner->ClassName);
//Get the class name which holds the 'LastEdited' field. Might be for example 'SiteTree'.
DB::query('UPDATE ' . $table_name . " SET PublishDate = '" . Convert::raw2sql($this->owner->PublishDate) . "' WHERE ID = " . intval($this->owner->ID) . ' LIMIT 1');
}
}
开发者ID:Taitava,项目名称:silverstripe-changeablelasteditedvalue,代码行数:10,代码来源:ChangeableLastEditedValue.php
示例13: CustomersAlsoBought
/**
* Get the products customers also bought
* (Haha so many sub queries...)
*
* @return \SS_List
*/
public function CustomersAlsoBought()
{
if (($orderItemClass = $this->owner->config()->order_item) && ($orderItem = singleton($orderItemClass)) && ($buyableRel = $orderItem->owner->config()->buyable_relationship)) {
$buyableRel = $buyableRel . 'ID';
$baseClass = \ClassInfo::baseDataClass($this->owner);
// Had to use EXISTS because IN () not compatible with SS DataModel
return $this->owner->get()->where('EXISTS(' . \DataList::create($orderItemClass)->where('EXISTS(' . str_replace(['FROM "OrderAttribute"', '"OrderAttribute".', 'OrderAttribut||e'], ['FROM "OrderAttribute" AS "OrderAttribute1"', '"OrderAttribute1".', 'OrderAttribute'], \DataList::create($orderItemClass)->leftJoin('Order', "\"OrderAttribute\".\"OrderID\" = \"Order\".\"ID\"")->where("\"{$buyableRel}\" = {$this->owner->ID}")->where('"Order"."Status" != \'Cart\'')->where('"OrderAttribute1"."OrderID" = "OrderAttribut||e"."OrderID"')->dataQuery()->getFinalisedQuery(['"OrderAttribute"."OrderID"'])->sql()) . ')')->where("\"{$buyableRel}\" != " . $this->owner->ID)->where("\"{$baseClass}\".\"ID\" = \"{$orderItemClass}\".\"{$buyableRel}\"")->dataQuery()->getFinalisedQuery([$buyableRel])->sql() . ')');
}
return \ArrayList::create();
}
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-shop-recommended,代码行数:16,代码来源:HasRecommendedProducts.php
示例14: ViewCount
/**
* Return an existing or new ViewCount record.
*
* @return ViewCount
*/
public function ViewCount()
{
$data = array('RecordID' => $this->owner->ID, 'RecordClass' => ClassInfo::baseDataClass($this->owner->ClassName));
$count = ViewCount::get()->filter($data)->First();
if (!$count) {
$count = new ViewCount();
$count->update($data);
}
return $count;
}
示例15: testBaseDataClass
/**
* @covers ClassInfo::baseDataClass()
*/
public function testBaseDataClass()
{
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_BaseClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('classinfotest_baseclass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_ChildClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('CLASSINFOTEST_CHILDCLASS'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GrandChildClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GRANDChildClass'));
$this->setExpectedException('InvalidArgumentException');
ClassInfo::baseDataClass('DataObject');
}