예제 #1
0
 /**
  * Update an entity.
  *
  * @param   object $entity The entity to insert
  *
  * @return  void
  */
 public function update($entity)
 {
     $identifier = $this->getIdentifier($entity);
     $data = $this->builder->reduce($entity);
     $this->connection->update($this->tableName, $data, $identifier);
     $this->builder->resolve($entity);
 }
예제 #2
0
 /**
  * resolve() adds the relations to an entity
  */
 public function testResolve()
 {
     $article = new Article();
     foreach ($this->articles[1] as $key => $value) {
         /** @noinspection PhpVariableVariableInspection */
         $article->{$key} = $value;
     }
     $this->builder->resolve($article);
     $this->assertObjectHasAttribute('parent', $article);
     /** @noinspection PhpUndefinedFieldInspection */
     $this->assertNull($article->parent);
     $this->assertObjectHasAttribute('children', $article);
     /** @noinspection PhpUndefinedFieldInspection */
     $this->assertInstanceOf(RepositoryInterface::class, $article->children);
     /** @noinspection PhpUndefinedFieldInspection */
     $this->assertEquals(Article::class, $article->children->getEntityClass());
     return $article;
 }
예제 #3
0
 /**
  * Update an entity.
  *
  * @param   object  $entity  The entity to insert
  *
  * @return  void
  */
 public function update($entity)
 {
     $this->gateway->update($this->tableName, $this->builder->reduce($entity), $this->getIdentifier($entity));
     $this->builder->resolve($entity);
 }