本文整理汇总了PHP中DataExtension::onAfterWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP DataExtension::onAfterWrite方法的具体用法?PHP DataExtension::onAfterWrite怎么用?PHP DataExtension::onAfterWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtension
的用法示例。
在下文中一共展示了DataExtension::onAfterWrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterWrite
/**
* Untranslate all fields in a DataObject that are marked to be untranslatable.
*/
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->owner->UntranslatableFields_skipOnAfterWrite) {
return;
}
//Another object has started the saving process, so don't create an infinite recursion loop
$untranslatable_fields = $this->getUntranslatableFields();
if (empty($untranslatable_fields)) {
return;
}
//Should not translate this model at all (for some reason this extension has still been applied to this model, but there's nothing to do)
foreach ($this->owner->getTranslations() as $translated_object) {
$write = false;
foreach ($untranslatable_fields as $field_name) {
if ($translated_object->{$field_name} != $this->owner->{$field_name}) {
$translated_object->{$field_name} = $this->owner->{$field_name};
$write = true;
}
}
if ($write) {
$do_publish = $translated_object->hasMethod('Published') && $translated_object->Published();
if ($do_publish) {
die;
}
$translated_object->UntranslatableFields_skipOnAfterWrite = true;
$translated_object->write();
unset($translated_object->UntranslatableFields_skipOnAfterWrite);
#if ($do_publish) $translated_object->Publish(); //If an object was published before this modification, publish it again in order to make the changes public.
}
}
}
示例2: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if (!$this->owner->ExifRead) {
$this->processExifData();
}
}
示例3: onAfterWrite
/**
* Override to avoid Dup groups titles and slugs
*/
function onAfterWrite()
{
parent::onAfterWrite();
$exits_group = false;
$suffix = 1;
//get original values
$original_code = $this->owner->Code;
$original_title = $this->owner->Title;
//iterate until we get an unique slug and title
while (!$exits_group) {
$new_code = $this->owner->Code;
$new_title = $this->owner->Title;
$id = $this->owner->ID;
//check if group already exists...
$count = DB::query(" SELECT COUNT(*) FROM \"Group\" WHERE Code ='{$new_code}' AND ID <> {$id}")->value();
if ($count) {
//if exists , rename it
$this->owner->Code = $original_code . '-' . $suffix;
$this->owner->Title = $original_title . ' ' . $suffix;
} else {
DB::query("UPDATE \"Group\" SET Code= '{$new_code}', Title = '{$new_title}' WHERE ID = {$id} ");
$exits_group = true;
}
++$suffix;
}
}
示例4: onAfterWrite
/**
* Creates WidgetArea DataObjects in not aleready done.
*/
public function onAfterWrite()
{
parent::onAfterWrite();
$has_one = $this->owner->has_one();
// Loop over each WidgetArea
foreach ($has_one as $name => $class) {
if ($class == 'WidgetArea') {
// Create the WidgetArea if it not exist
$dbName = $name . 'ID';
// Can't use $this->owner->$name()->ID since it doesn't
// work with DataObjects, it works just with Pages. SS bug?
if ($this->owner->{$dbName} == 0) {
$wa = new WidgetArea();
$wa->write();
$this->owner->{$dbName} = $wa->ID;
if ($this->owner->hasExtension('Versioned')) {
$this->owner->writeWithoutVersion();
} else {
$dbg = $this->owner->{$name}();
$this->owner->write();
}
}
}
}
}
示例5: onAfterWrite
/**
* Update link mappings when replacing the default automated URL handling.
*/
public function onAfterWrite()
{
parent::onAfterWrite();
// Determine whether the default automated URL handling has been replaced.
if (Config::inst()->get('MisdirectionRequestFilter', 'replace_default')) {
// Determine whether the URL segment or parent ID has been updated.
$changed = $this->owner->getChangedFields();
if (isset($changed['URLSegment']['before']) && isset($changed['URLSegment']['after']) && $changed['URLSegment']['before'] != $changed['URLSegment']['after'] || isset($changed['ParentID']['before']) && isset($changed['ParentID']['after']) && $changed['ParentID']['before'] != $changed['ParentID']['after']) {
// The link mappings should only be created for existing pages.
$URL = isset($changed['URLSegment']['before']) ? $changed['URLSegment']['before'] : $this->owner->URLSegment;
if (strpos($URL, 'new-') !== 0) {
// Determine the page URL.
$parentID = isset($changed['ParentID']['before']) ? $changed['ParentID']['before'] : $this->owner->ParentID;
$parent = SiteTree::get_one('SiteTree', "SiteTree.ID = {$parentID}");
while ($parent) {
$URL = Controller::join_links($parent->URLSegment, $URL);
$parent = SiteTree::get_one('SiteTree', "SiteTree.ID = {$parent->ParentID}");
}
// Instantiate a link mapping for this page.
singleton('MisdirectionService')->createPageMapping($URL, $this->owner->ID);
// Purge any link mappings that point back to the same page.
$this->owner->regulateMappings($this->owner->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $this->owner->Link(), $this->owner->ID);
// Recursively create link mappings for any children.
$children = $this->owner->AllChildrenIncludingDeleted();
if ($children->count()) {
$this->owner->recursiveMapping($URL, $children);
}
}
}
}
}
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-misdirection,代码行数:34,代码来源:SiteTreeMisdirectionExtension.php
示例6: onAfterWrite
/**
*
*/
public function onAfterWrite()
{
$serializer = CacheHelper::get_serializer();
// update the cache
CacheHelper::get_cache()->save($serializer->serialize($this->owner), $this->key());
parent::onAfterWrite();
}
示例7: onAfterWrite
/**
* Generates the Android manifest.json file.
*
* @todo Information about permissions
*
* @return void
*/
public function onAfterWrite()
{
// parent
parent::onAfterWrite();
// @todo Add success & error states + messages
$this->generateAndroidManifest();
}
开发者ID:graphiques-digitale,项目名称:silverstripe-seo-icons,代码行数:14,代码来源:SEO_Icons_SiteConfig_DataExtension.php
示例8: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
$AvailableTypes = $this->AvailableSectionTypes();
foreach ($AvailableTypes as $key => $value) {
$ClassName = $AvailableTypes[$key]['classname'];
if ($AvailableTypes[$key]['presets'] !== null) {
foreach ($AvailableTypes[$key]['presets'] as $AdminTitle => $ShareStatus) {
$Section = $this->owner->Sections()->filter(array('ClassName' => $ClassName, 'UniqueConfigTitle' => $AdminTitle));
if ($Section->Count()) {
continue;
}
$ExistingSection = $ClassName::get()->filter(array('ClassName' => $ClassName, 'UniqueConfigTitle' => $AdminTitle))->first();
if ($ExistingSection && $ShareStatus == 'shared') {
$this->owner->Sections()->add($ExistingSection);
} else {
$newSection = $ClassName::create();
$newSection->UniqueConfigTitle = $AdminTitle;
$newSection->AdminTitle = $AdminTitle;
$newSection->Public = true;
$newSection->Write();
$this->owner->Sections()->add($newSection);
}
}
}
}
}
示例9: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if (in_array('Searchable', class_implements($this->owner->class))) {
if ($this->owner->IncludeInSearch()) {
if ($this->owner->hasExtension('Versioned')) {
$filterID = array('ID' => $this->owner->ID);
$filter = $filterID + $this->owner->getSearchFilter();
$do = Versioned::get_by_stage($this->owner->class, 'Live')->filter($filter)->first();
} else {
$filterID = "`{$this->owner->class}`.`ID`={$this->owner->ID}";
$do = DataObject::get($this->owner->class, $filterID, false)->filter($this->owner->getSearchFilter())->first();
}
if ($do) {
PopulateSearch::insert($do);
} else {
$this->deleteDo($this->owner);
}
} else {
$this->deleteDo($this->owner);
}
} else {
if ($this->owner instanceof SiteTree) {
if ($this->owner->ShowInSearch) {
PopulateSearch::insertPage($this->owner);
} else {
$this->deleteDo($this->owner);
}
}
}
}
示例10: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
//create supported versions for not versioned components
$supported_components = $this->owner->OpenStackComponents();
if ($supported_components && count($supported_components) > 0) {
$non_versioned_components = array();
foreach ($supported_components as $component) {
if (!$component->getSupportsVersioning()) {
//crete dumb version
array_push($non_versioned_components, $component->getIdentifier());
$old = $this->owner->SupportedApiVersions(" OpenStackComponentID = {$component->getIdentifier()} AND ApiVersionID = 0 ");
if (count($old) == 0) {
$new_supported_version = new OpenStackReleaseSupportedApiVersion();
$new_supported_version->OpenStackComponentID = $component->getIdentifier();
$new_supported_version->ReleaseID = $this->owner->getIdentifier();
$new_supported_version->ApiVersionID = 0;
$new_supported_version->write();
}
}
}
$to_delete = "";
if (count($non_versioned_components) > 0) {
$to_delete = implode(',', $non_versioned_components);
$to_delete = "AND OpenStackComponentID NOT IN ({$to_delete})";
}
DB::query("DELETE FROM OpenStackReleaseSupportedApiVersion WHERE ReleaseID = {$this->owner->getIdentifier()} AND ApiVersionID = 0 {$to_delete}");
}
}
示例11: onAfterWrite
/**
* Creation and association of assets folder,
* once a data object has been created (and is ready for it)
*/
function onAfterWrite()
{
parent::onAfterWrite();
//creation will only be considered if the object has no folder relation
if ($this->owner->AssetsFolderID == 0) {
//the default rules only require the object to have an ID
//but more sophisticated rules might require more - e.g. a title to be set
//thus we check if the object is ready for folder creation - if custom rules
//(UploadDirRulesInterface) have been set
if ($this->owner instanceof UploadDirRulesInterface) {
if (!$this->owner->getReadyForFolderCreation()) {
return false;
}
}
$url = null;
//check if the page we're having is implementing the UploadDirRulesInterface
//for rule customization
if ($this->owner instanceof UploadDirRulesInterface) {
$url = $this->owner->getCalcAssetsFolderDirectory();
} else {
//else use the default settings
$class = UploadDirRules::get_rules_class();
$url = $class::calc_full_directory_for_object($this->owner);
}
if ($url) {
//this creates the directory, and attaches it to the page,
//as well as saving the object one more time - with the attached folder
$this->findOrMakeAssetsFolder($url, true);
}
}
}
示例12: onAfterWrite
/**
* Update the fusion tag to reflect the change.
*/
public function onAfterWrite()
{
parent::onAfterWrite();
// Determine the field to use, based on the configuration defined tag types.
$write = 'Title';
$class = $this->owner->ClassName;
foreach (Config::inst()->get('FusionService', 'custom_tag_types') as $type => $field) {
if ($type === $class) {
$write = $field;
}
}
// Determine whether there's an existing fusion tag.
$changed = $this->owner->getChangedFields();
$existing = FusionTag::get()->filter('Title', $this->owner->{$write})->first();
if (is_null($this->owner->FusionTagID) && !$existing) {
// There is no fusion tag, therefore instantiate one using this tag.
$fusion = FusionTag::create();
$fusion->Title = $this->owner->{$write};
$fusion->TagTypes = serialize(array($class => $class));
$fusion->write();
// Update this tag to point to the fusion tag.
$this->owner->FusionTagID = $fusion->ID;
$this->owner->write();
} else {
if (is_null($this->owner->FusionTagID) && $existing) {
// There is a fusion tag, therefore append this tag type.
$types = unserialize($existing->TagTypes);
$types[$class] = $class;
$existing->TagTypes = serialize($types);
$existing->write();
// Update this tag to point to the fusion tag.
$this->owner->FusionTagID = $existing->ID;
$this->owner->write();
} else {
if (isset($changed[$write]) && !isset($changed['FusionTagID']) && $existing && $existing->ID != $this->owner->FusionTagID) {
// Update the fusion tag to remove this tag type.
$fusion = FusionTag::get()->byID($this->owner->FusionTagID);
$types = unserialize($fusion->TagTypes);
unset($types[$this->owner->ClassName]);
$fusion->TagTypes = !empty($types) ? serialize($types) : null;
$fusion->write();
// There is an existing fusion tag, therefore append this tag type.
$types = unserialize($existing->TagTypes);
$types[$class] = $class;
$existing->TagTypes = serialize($types);
$existing->write();
// Update this tag to point to the new fusion tag.
$this->owner->FusionTagID = $existing->ID;
$this->owner->write();
} else {
if (isset($changed[$write]) && !isset($changed['FusionTagID']) && ($existing = FusionTag::get()->byID($this->owner->FusionTagID))) {
// There is an update, therefore update the existing fusion tag to reflect the change.
$existing->Title = $changed[$write]['after'];
$existing->write();
}
}
}
}
}
示例13: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->isNewObject) {
$this->dataChangeTrackService->track($this->owner, $this->changeType);
$this->isNewObject = FALSE;
}
}
示例14: onAfterWrite
public function onAfterWrite()
{
// if new post
if ($this->owner->LastEdited == $this->owner->Created) {
$this->notifySubscribers();
}
parent::onAfterWrite();
}
示例15: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
// figure out which files we need to regenerate (or at least delete to allow for regeneration
// as Image will call deleteFormattedImages during onAfterUpload which means the
// updates below do NOT get triggered correctly
$this->cachedPaths = $this->findCachedPaths();
}