LeanMapper\Entity::makeAlive PHP Method

makeAlive() public method

Provides dependencies
public makeAlive ( leanmapper\IEntityFactory $entityFactory = null, Connection $connection = null, leanmapper\IMapper $mapper = null )
$entityFactory leanmapper\IEntityFactory
$connection Connection
$mapper leanmapper\IMapper
    public function makeAlive(IEntityFactory $entityFactory = null, Connection $connection = null, IMapper $mapper = null)
    {
        $entityFactory === null or $this->setEntityFactory($entityFactory);
        $mapper === null or $this->useMapper($mapper);
        $connection === null or $this->row->setConnection($connection);
        if ($this->entityFactory === null) {
            throw new InvalidStateException('Missing entity factory in entity ' . get_called_class() . '.');
        }
        if ($this->mapper === null) {
            throw new InvalidStateException('Missing mapper in entity ' . get_called_class() . '.');
        }
        if (!$this->row->hasConnection()) {
            throw new InvalidStateException('Missing connection in Result in entity ' . get_called_class() . '.');
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @param \LeanMapper\Entity $entity
  * @param $id
  * @return void
  */
 public function makeAlive(\LeanMapper\Entity $entity, $id)
 {
     \Nette\Utils\Validators::assert($id, 'numericint:1..');
     $entity->makeAlive($this->entityFactory, $this->connection, $this->mapper);
     $entity->attach($id);
 }
All Usage Examples Of LeanMapper\Entity::makeAlive