<?php
/**
 *
 * @author：llbjj
 * @DateTime：2022/5/4 13:26
 * @Description：
 *
 */

namespace Application\Mvc\Controller\Plugins;
use Application\Service\DB\Db;
use Application\Service\DB\Item\PatientFormContentUpdatedLog;
use Laminas\Mvc\Controller\Plugin\AbstractPlugin;
use Psr\Container\ContainerInterface;

class LocalService extends AbstractPlugin
{
    protected $container;
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function __get($name)
    {
        if (Db::isInTransaction()) {
            return $this->container->build($name);
        }

        return $this->container->get($name);
    }

    /**
     * @param string $chainIndex
     * @return PatientFormContentUpdatedLog
     */
    public function patientFormContentUpdatedLog(string $index = ''): PatientFormContentUpdatedLog
    {
        return $this->container->build('patientFormContentUpdatedLog', [
            'index' => is_numeric($index) ? $index : null
        ]);
    }
}