Overview

Namespaces

  • Faulancer
    • Controller
    • Exception
    • Form
      • Validator
        • Type
    • Helper
      • Reflection
    • Http
    • Mail
    • ORM
      • User
    • Service
      • Factory
    • ServiceLocator
    • Session
    • View
      • Helper

Classes

  • AuthenticatorService
  • Config
  • ControllerService
  • DbService
  • DispatcherService
  • HttpService
  • JsonResponseService
  • RequestService
  • ResponseService
  • SessionManagerService
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 
<?php
/**
 * Class DbService | DbService.php
 * @package Faulancer\Service
 * @author  Florian Knapp <office@florianknapp.de>
 */
namespace Faulancer\Service;

use ORM\EntityFetcher;
use ORM\EntityManager;
use Faulancer\ORM\Entity;
use Faulancer\ServiceLocator\ServiceInterface;

/**
 * Class DbService
 */
class DbService implements ServiceInterface
{

    /** @var EntityManager */
    protected $entityManager;

    /**
     * ORM constructor.
     *
     * @param EntityManager $entityManager
     */
    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    /**
     * @return EntityManager
     */
    public function getManager()
    {
        return $this->entityManager;
    }

    /**
     * Return the EntityFetcher
     *
     * @param string       $entity
     * @param integer|null $primaryKey
     * @return Entity|EntityFetcher
     * @codeCoverageIgnore Is covered by tflori/orm
     */
    public function fetch(string $entity, $primaryKey = null)
    {
        return $this->entityManager->fetch($entity, $primaryKey);
    }

    /**
     * Save an entity
     *
     * @param Entity $entity
     * @codeCoverageIgnore Is covered by tflori/orm
     */
    public function save(Entity $entity)
    {
        $entity->save($this->entityManager);
    }

}
API documentation generated by ApiGen