Example #1
0
	/**
	 * @expectedException Nette\InvalidArgumentException
	 */
	public function testUpdateInvalidValues()
	{
		$entity = new Service\EntityMock;
		$entity->setData("bar");
		$this->service->update($entity, NULL);
	}
Example #2
0
	/**
	 * @param \Nella\Models\IEntity
	 * @param array|\Traversable
	 * @param bool
	 * @return \Nella\Models\IEntity
	 * @throws \Nette\InvalidArgumentException
	 * @throws \Nella\Models\Exception
	 * @throws \Nella\Models\EmptyValueException
	 * @throws \Nella\Models\DuplicateEntryException
	 */
	public function update(IEntity $entity, $values = NULL, $withoutFlush = FALSE)
	{
		try {
			if ($values) {
				parent::update($entity, $values);
			}
			$em = $this->getEntityManager();
			//$em->persist($entity); // maybe need
			if (!$withoutFlush) {
				$em->flush();
			}
			return $entity;
		} catch (\PDOException $e) {
			$this->processPDOException($e);
		}
	}