save() публичный Метод

Save an entity.
public save ( ) : boolean | integer
Результат boolean | integer
Пример #1
0
 /**
  * Called before each test method.
  */
 public function setUp()
 {
     _elgg_services()->hooks->backup();
     $this->entity = new \ElggObject();
     $this->entity->subtype = 'elgg_annotation_test';
     $this->entity->access_id = ACCESS_PUBLIC;
     $this->entity->save();
 }
Пример #2
0
 public function testSubtypeIsString()
 {
     $this->assertTrue($this->entity->save());
     $guid = $this->entity->guid;
     _elgg_invalidate_cache_for_entity($guid);
     $this->entity = null;
     $this->entity = get_entity($guid);
     $this->assertEqual('elgg_entity_test_subtype', $this->entity->subtype);
 }
Пример #3
0
 /**
  * Called before each test method.
  */
 public function setUp()
 {
     $this->original_hooks = _elgg_services()->hooks;
     _elgg_services()->hooks = new \Elgg\PluginHooksService();
     $this->entity = new \ElggObject();
     $this->entity->subtype = 'elgg_annotation_test';
     $this->entity->access_id = ACCESS_PUBLIC;
     $this->entity->save();
 }
Пример #4
0
 public function testSubtypePropertyReads()
 {
     $this->assertTrue($this->entity->save());
     $guid = $this->entity->guid;
     $subtype_prop = $this->entity->subtype;
     $this->assertIsA($subtype_prop, 'int');
     $this->assertEqual($subtype_prop, get_subtype_id('object', 'elgg_entity_test_subtype'));
     _elgg_invalidate_cache_for_entity($guid);
     $this->entity = null;
     $this->entity = get_entity($guid);
     $subtype_prop = $this->entity->subtype;
     $this->assertIsA($subtype_prop, 'int');
     $this->assertEqual($subtype_prop, get_subtype_id('object', 'elgg_entity_test_subtype'));
 }
Пример #5
0
 /**
  * Called before each test method.
  */
 public function setUp()
 {
     _elgg_services()->events->backup();
     $this->entity1 = new ElggObject();
     $this->entity1->subtype = 'elgg_relationship_test';
     $this->entity1->access_id = ACCESS_PUBLIC;
     $this->entity1->save();
     $this->entity2 = new ElggObject();
     $this->entity2->subtype = 'elgg_relationship_test';
     $this->entity2->access_id = ACCESS_PUBLIC;
     $this->entity2->save();
     $this->entity3 = new ElggObject();
     $this->entity3->subtype = 'elgg_relationship_test';
     $this->entity3->access_id = ACCESS_PUBLIC;
     $this->entity3->save();
 }
Пример #6
0
 /**
  * Called before each test method.
  */
 public function setUp()
 {
     $this->original_events = _elgg_services()->events;
     _elgg_services()->events = new Elgg\EventsService();
     $this->entity1 = new ElggObject();
     $this->entity1->subtype = 'elgg_relationship_test';
     $this->entity1->access_id = ACCESS_PUBLIC;
     $this->entity1->save();
     $this->entity2 = new ElggObject();
     $this->entity2->subtype = 'elgg_relationship_test';
     $this->entity2->access_id = ACCESS_PUBLIC;
     $this->entity2->save();
     $this->entity3 = new ElggObject();
     $this->entity3->subtype = 'elgg_relationship_test';
     $this->entity3->access_id = ACCESS_PUBLIC;
     $this->entity3->save();
 }
Пример #7
0
 /**
  * @expectedException InvalidParameterException
  */
 public function testSaveWithoutType()
 {
     $db = $this->getMock('\\Elgg\\Database', array('getData', 'getTablePrefix', 'sanitizeString'), array(), '', false);
     $db->expects($this->any())->method('sanitizeString')->will($this->returnArgument(0));
     _elgg_services()->setValue('db', $db);
     // requires type to be set
     $this->obj->save();
 }
 /**
  * Updates entity information with user input values
  * @return \ElggEntity|false
  */
 public function update()
 {
     hypePrototyper()->prototype->saveStickyValues($this->action);
     // first handle attributes
     foreach ($this->fields as $field) {
         if ($field->getDataType() == 'attribute') {
             $this->entity = $field->handle($this->entity);
         }
     }
     if (!$this->entity->save()) {
         return false;
     }
     foreach ($this->fields as $field) {
         if ($field->getDataType() !== 'attribute') {
             $this->entity = $field->handle($this->entity);
         }
     }
     if (!$this->entity->save()) {
         return false;
     }
     hypePrototyper()->prototype->clearStickyValues($this->action);
     return $this->entity;
 }
 /**
  * Saves this user to the database.
  * @return true|false
  */
 public function save()
 {
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // Now save specific stuff
     return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'), $this->get('code'));
 }
Пример #10
0
 /**
  * Saves site-specific attributes.
  *
  * @internal Site attributes are saved in the sites_entity table.
  *
  * @return bool
  */
 public function save()
 {
     global $CONFIG;
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // make sure the site guid is set (if not, set to self)
     if (!$this->get('site_guid')) {
         $guid = $this->get('guid');
         update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid={$guid}\n\t\t\t\tWHERE guid={$guid}");
     }
     // Now save specific stuff
     return create_site_entity($this->get('guid'), $this->get('name'), $this->get('description'), $this->get('url'));
 }
Пример #11
0
 /**
  * Override the save function.
  *
  * @return bool
  */
 public function save()
 {
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // Now save specific stuff
     _elgg_disable_caching_for_entity($this->guid);
     $ret = create_group_entity($this->get('guid'), $this->get('name'), $this->get('description'));
     _elgg_enable_caching_for_entity($this->guid);
     return $ret;
 }
Пример #12
0
 /**
  * Saves object-specific attributes.
  *
  * @internal Object attributes are saved in the objects_entity table.
  *
  * @return bool
  */
 public function save()
 {
     // Save ElggEntity attributes
     if (!parent::save()) {
         return false;
     }
     // Save ElggObject-specific attributes
     _elgg_disable_caching_for_entity($this->guid);
     $ret = create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'));
     _elgg_enable_caching_for_entity($this->guid);
     return $ret;
 }
Пример #13
0
 /**
  * Override the save function.
  * @return true|false
  */
 public function save()
 {
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // Now save specific stuff
     return create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'), $this->get('container_guid'));
 }
Пример #14
0
 /**
  * Override the save function.
  *
  * @return bool
  */
 public function save()
 {
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // Now save specific stuff
     return create_group_entity($this->get('guid'), $this->get('name'), $this->get('description'));
 }
Пример #15
0
 /** @override */
 public function save()
 {
     global $CONFIG;
     // Save generic stuff
     $result = parent::save();
     if (!$result) {
         return false;
     }
     // make sure the site guid is set (if not, set to self)
     if (!$this->get('site_guid')) {
         $guid = (int) $this->get('guid');
         update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid={$guid} WHERE guid={$guid}");
     }
     return $result;
 }
 /**
  * Saves object-specific attributes.
  *
  * @internal Object attributes are saved in the objects_entity table.
  *
  * @return bool
  */
 public function save()
 {
     // Save ElggEntity attributes
     if (!parent::save()) {
         return false;
     }
     // Save ElggObject-specific attributes
     return create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'), $this->get('container_guid'));
 }
Пример #17
0
 /**
  * Saves this user to the database.
  *
  * @return bool
  */
 public function save()
 {
     // Save generic stuff
     if (!parent::save()) {
         return false;
     }
     // Now save specific stuff
     _elgg_disable_caching_for_entity($this->guid);
     $ret = create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'), $this->get('code'));
     _elgg_enable_caching_for_entity($this->guid);
     return $ret;
 }