Beispiel #1
0
 /**
  * @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;
     });
 }
Beispiel #2
0
 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]);
     });
 }
Beispiel #3
0
 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;
     });
 }