Skip to content
Snippets Groups Projects
Select Git revision
  • 837c93b37236ad67efb10f0ef59b682069fbbbfb
  • master default protected
  • subtemplate
  • release_7.0.6
  • php84
  • 6.x
  • v5.x-test
  • 5x
  • 7.1.0
  • 7.0.6
  • 7.0.5
  • 7.0.4
  • 7.0.3
  • 7.0.2
  • 7.0.1
  • 7.0.0
  • 6.1.7
  • 6.1.6
  • 6.1.5
  • 6.1.4
  • 6.1.3
  • 6.1.2
  • 6.1.1
  • 6.1.0
  • 6.0.3
  • 6.0.2
  • 5.0.6
  • 6.0.1
28 results

TemplateControllerFactory.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    User.php 1.88 KiB
    <?php
    
    namespace ZfcUser\Mapper;
    
    use ZfcUser\Entity\UserInterface as UserEntityInterface;
    use Laminas\Hydrator\HydratorInterface;
    
    class User extends AbstractDbMapper implements UserInterface
    {
        protected $tableName  = 'user';
    
        public function findByEmail($email)
        {
            $select = $this->getSelect()
                           ->where(array('email' => $email));
            $entity = $this->select($select)->current();
    
            $this->getEventManager()->trigger('find', $this, array('entity' => $entity));
    
            return $entity;
        }
    
        public function findByUsername($username)
        {
            $select = $this->getSelect()
                           ->where(array('username' => $username));
            $entity = $this->select($select)->current();
    
            $this->getEventManager()->trigger('find', $this, array('entity' => $entity));
    
            return $entity;
        }
    
        public function findById($id)
        {
            $select = $this->getSelect()
                           ->where(array('user_id' => $id));
            $entity = $this->select($select)->current();
    
            $this->getEventManager()->trigger('find', $this, array('entity' => $entity));
    
            return $entity;
        }
    
        public function getTableName()
        {
            return $this->tableName;
        }
    
        public function setTableName($tableName)
        {
            $this->tableName = $tableName;
        }
    
        public function insert(UserEntityInterface $entity, $tableName = null, HydratorInterface $hydrator = null)
        {
            $result = parent::insert($entity, $tableName, $hydrator);
    
            $entity->setId($result->getGeneratedValue());
    
            return $result;
        }
    
        public function update(UserEntityInterface $entity, $where = null, $tableName = null, HydratorInterface $hydrator = null)
        {
            if (!$where) {
                $where = array('user_id' => $entity->getId());
            }
    
            return parent::update($entity, $where, $tableName, $hydrator);
        }
    }