/** * @param string $entityClass * @param string $key * @param null $column * @return StoredEntity|null * @throws NoReferenceException */ public function reference($entityClass, $key = null, $column = null) { if ($this->cachedReferences == null) { $this->cachedReferences = new ArrayHash(); } if ($this->isNewEntity()) { return null; } if ($key == null) { $columnToDiscoverReference = $entityClass; $reflectProperty = $this->getPropertyByColumnName($columnToDiscoverReference); if ($reflectProperty) { $entityClass = $this->getReferenceClassForProperty($reflectProperty); if (!$entityClass) { throw new NoReferenceException($columnToDiscoverReference); } $column = $columnToDiscoverReference; $key = $entityClass::getTableName($this->annotationReader); } } self::mustBeChildOf($entityClass, StoredEntity::class); if (!$this->cachedReferences->offsetExists($key)) { $reference = $entityClass::create($this, $this->row->getTable()->getReferencedTable($this->row, $key, $column)); $this->cachedReferences->offsetSet($key, $reference); } return $this->cachedReferences->offsetGet($key); }
public function offsetSet($key, $value) { if (!$value instanceof \UniMapper\Repository) { throw new \Exception("Repository must be instance of UniMapper\\Repository!"); } parent::offsetSet($value->getName(), $value); }
{ return $this->getTable()->where(array('nazov' => $kluc))->update(array('text' => $data)); } /** Vrati vsetky dostupne udaje podla registracie * @param int $id_reg min. uroven registracie * @return \Nette\Database\Table\Selection */ public function vypisUdaje($id_reg = 0) { return $this->getTable()->where("id_registracia <= ?", $id_reg); } /** Funkcia vrati celociselnu hodnotu udaju s nazvom * @param string $nazov Nazov udaju * @return int */ public function getUdajInt($nazov = "") { $p = $this->findOneBy(array('nazov' => $nazov)); return $p !== FALSE ? (int) $p->text : 0; } /** Funkcia pre ulozenie udaju * @param Nette\Utils\ArrayHash $values
public function createEntry(ArrayHash $values, array $ids) { try { foreach ($ids as $id) { $values->offsetSet("owner", $id); $e = new MotivationEntry((array) $values); $e->setEditor($this->getUser()->getIdentity()); $this->entryService->createEntry($e); } } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad($values->id, "this", $ex); } $this->redirect("default"); }
/** * Zpracovani formulare s clankem * @param Form $form * @param Nette\Utils\ArrayHash $values */ public function formSucceeded(Form $form, $values) { //nastaveni datumu zverejneni if (empty($values->publishDate)) { $date = new DateTime(); } else { $date = DateTime::createFromFormat('d. m. Y, H:i', $values->publishDate); } $values->offsetSet('publishDate', $date); //novy clanek nebo jeho editace $result = empty($values->id) ? $this->newArticle($values) : $this->editArticle($values); if ($result) { $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success'); } else { $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger'); } }