本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase::save方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase::save方法的具体用法?PHP ConfigEntityBase::save怎么用?PHP ConfigEntityBase::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityBase
的用法示例。
在下文中一共展示了ConfigEntityBase::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* {@inheritdoc}
*/
public function save()
{
// Make sure we don't have any save exceptions before building menu
// definitions.
$return = parent::save();
foreach ($this->getLinks([], TRUE) as $link_key => $link_def) {
$this->getMenuLinkManager()->addDefinition($link_key, $link_def);
}
return $return;
}
示例2: save
/**
* Overrides Drupal\Core\Entity\Entity::save().
*/
public function save()
{
// Check if everything is valid.
if (!$this->isValid()) {
throw new InvalidBreakpointException('Invalid data detected.');
}
parent::save();
}
示例3: save
/**
* {@inheritdoc}
*/
public function save($create_creation_state = TRUE)
{
// Create the machine_name for new states.
// N.B.: Keep machine_name in WorkflowState and ~ListBuilder aligned.
$sid = $this->id();
$wid = $this->wid;
if (empty($sid) || $sid == WORKFLOW_CREATION_STATE_NAME) {
if ($label = $this->label()) {
// Format the machine_name. @todo Use a proper machine_name regex.
$sid = str_replace(' ', '_', strtolower($label));
} else {
workflow_debug(__FILE__, __FUNCTION__, __LINE__);
// @todo D8-port: still test this snippet.
$sid = 'state_' . $this->id();
}
$this->set('id', implode('_', [$wid, $sid]));
}
return parent::save();
}
示例4: save
/**
* Given information, update or insert a new workflow.
*
* This also handles importing, rebuilding, reverting from Features,
* as defined in workflow.features.inc.
* TODO D8: clean up this function, since we are config entity now.
* todo D7: reverting does not refresh States and transitions, since no
* machine_name was present. As of 7.x-2.3, the machine_name exists in
* Workflow and WorkflowConfigTransition, so rebuilding is possible.
*
* When changing this function, test with the following situations:
* - maintain Workflow in Admin UI;
* - clone Workflow in Admin UI;
* - create/revert/rebuild Workflow with Features; @see workflow.features.inc
* - save Workflow programmatic;
*
* @inheritdoc
*/
public function save()
{
$status = parent::save();
// Are we saving a new Workflow?
// Make sure a Creation state exists.
if ($status == SAVED_NEW) {
$state = $this->getCreationState();
}
return $status;
}
示例5: save
public function save()
{
$workflow = $this->getWorkflow();
// To avoid double posting, check if this (new) transition already exist.
if (empty($this->id())) {
if ($workflow) {
$config_transitions = $workflow->getTransitionsByStateId($this->from_sid, $this->to_sid);
$config_transition = reset($config_transitions);
if ($config_transition) {
$this->set('id', $config_transition->id());
}
}
}
// Create the machine_name. This can be used to rebuild/revert the Feature in a target system.
if (empty($this->id())) {
$wid = $workflow->id();
$this->set('id', implode('', [$wid, substr($this->from_sid, strlen($wid)), substr($this->to_sid, strlen($wid))]));
}
$status = parent::save();
if ($status) {
// Save in current workflow for the remainder of this page request.
// Keep in sync with Workflow::getTransitions() !
if ($workflow) {
$workflow->transitions[$this->id()] = $this;
// $workflow->sortTransitions();
}
}
return $status;
}
示例6: save
/**
* {@inheritdoc}
*/
public function save()
{
$return = parent::save();
// Rebuild route information when browsers that register routes
// are created/updated.
\Drupal::service('router.builder')->rebuild();
return $return;
}
示例7: save
/**
* Overrides Drupal\config\ConfigEntityBase::save().
*/
public function save()
{
// Check if everything is valid.
if (!$this->isValid()) {
throw new InvalidBreakpointException('Invalid data detected.');
}
// Set the label if none is set.
if (empty($this->label)) {
$this->label = $this->name;
}
// Remove unused multipliers.
$this->multipliers = array_filter($this->multipliers);
// Always add '1x' multiplier, use array_key_exists since the value might
// be NULL.
if (!array_key_exists('1x', $this->multipliers)) {
$this->multipliers = array('1x' => '1x') + $this->multipliers;
}
return parent::save();
}
示例8: save
/**
* Overrides Drupal\Core\Entity::save().
*/
public function save()
{
// Only save the keys, but return the full objects.
$breakpoint_group = $this->getBreakpointGroup();
if ($breakpoint_group && is_object($breakpoint_group)) {
$this->setBreakpointGroup($breakpoint_group->id());
}
// Split the breakpoint ids into their different parts, as dots as
// identifiers are not possible.
$loaded_mappings = $this->mappings;
$this->mappings = array();
foreach ($loaded_mappings as $breakpoint_id => $mapping) {
list($source_type, $source, $name) = explode('.', $breakpoint_id);
$this->mappings[$source_type][$source][$name] = $mapping;
}
parent::save();
$this->loadBreakpointGroup();
$this->loadAllMappings();
}