/** * @param string $table * @param null $callback * @return static */ public function getReferencedSource($table, $callback = null) { if (!$this->context) { throw new InvalidStateException('For get referenced source need context in constructor.'); } return parent::getReferencedSource($table, $callback ? $callback : function () use($table) { $tableStructure = $this->getDataStructure()->getTableStructure($table); $source = new static($tableStructure->getName(), $tableStructure->getPrimaryKey(), $this->context->table($table), $this->context); $source->setDataStructure($tableStructure); return $source; }); }
public function getReferencedSource($table, $callback = null) { return parent::getReferencedSource($table, $callback ? $callback : function () use($table) { if (!isset($this->referencedData[$table])) { throw new InvalidStateException('Array with key does not exists in secon __construct parameter.'); } $tableStructure = $this->getDataStructure()->getTableStructure($table); return new static($tableStructure->getName(), $tableStructure->getPrimaryKey(), $this->referencedData[$table]); }); }
public function getReferencedSource($table, $callback = null, $tablePrefix = '_a0') { return parent::getReferencedSource($table, $callback ? $callback : function () use($table, $tablePrefix) { $tableStructure = $this->getDataStructure()->getTableStructure($table); $source = new static($tableStructure->getName(), $tableStructure->getPrimaryKey(), $this->getQueryBuilder()->getEntityManager()->createQueryBuilder()->select($tablePrefix)->from($table, $tablePrefix)); $source->setDataStructure($tableStructure); return $source; }); }