/** * getPointConverter * * Cache the point converter. * * @access protected * @param Session $session * @return ConverterInterface */ protected function getPointConverter(Session $session) { if ($this->point_converter === null) { $this->point_converter = $session->getClientUsingPooler('converter', 'point'); } return $this->point_converter; }
/** * getSubtypeConverter * * Since the arrays in PostgreSQL have the same subtype, it is useful to * cache it here to avoid summoning the ClientHolder all the time. * * @access protected * @param string $type * @param Session $session * @return ConverterInterface */ protected function getSubtypeConverter($type, Session $session) { if (!isset($this->converters[$type])) { $this->converters[$type] = $session->getClientUsingPooler('converter', $type)->getConverter(); } return $this->converters[$type]; }
/** * __construct * * Constructor * * @access public * @param ResultHandler $result * @param Session $session * @param Projection $projection */ public function __construct(ResultHandler $result, Session $session, Projection $projection) { parent::__construct($result); $this->projection = $projection; $this->session = $session; $this->hydration_plan = new HydrationPlan($projection, $session); $this->entity_converter = $this->session->getClientUsingPooler('converter', $this->projection->getFlexibleEntityClass())->getConverter(); }
/** * initialize * * @see ClientInterface */ public function initialize(Session $session) { $this->session = $session; if ($this->structure === null) { throw new ModelException(sprintf("Structure not set while initializing Model class '%s'.", get_class($this))); } if ($this->flexible_entity_class == null) { throw new ModelException(sprintf("Flexible entity not set while initializing Model class '%s'.", get_class($this))); } elseif (!(new \ReflectionClass($this->flexible_entity_class))->implementsInterface('\\PommProject\\ModelManager\\Model\\FlexibleEntity\\FlexibleEntityInterface')) { throw new ModelException(sprintf("Flexible entity must implement FlexibleEntityInterface.")); } $session->getPoolerForType('converter')->getConverterHolder()->registerConverter($this->flexible_entity_class, new PgEntity($this->flexible_entity_class, $this->getStructure()), [$this->getStructure()->getRelation(), $this->flexible_entity_class]); }
/** * postConfigure * * @see SessionBuilder */ protected function postConfigure(Session $session) { $session->registerClientPooler(new PreparedQueryPooler())->registerClientPooler(new QueryManagerPooler())->registerClientPooler(new ConverterPooler(clone $this->converter_holder))->registerClientPooler(new ObserverPooler())->registerClientPooler(new InspectorPooler())->registerClientPooler(new ListenerPooler()); return $this; }
protected function initializeSession(Session $session) { $session->registerClientPooler(new ObserverPooler()); }
protected function initializeSession(Session $session) { $session->registerClient(new StructureFixtureClient()); }
private function sendAsPostgresParameter($value, $type, Session $session) { $result = $session->getQueryManager()->query(sprintf("select \$*::%s as my_test", $type), [$value])->current(); return $result['my_test']; }
/** * Because newTestedInstance cannot be called in setUp or tearDown methods, * we must set up session manually in test methods. */ protected function setUpSession(Session $session) { $session->getPoolerForType('converter')->getConverterHolder()->registerConverter('ComplexNumber', $this->newTestedInstance('PommProject\\ModelManager\\Test\\Fixture\\ComplexNumber', new ComplexNumberStructure()), ['pomm_test.complex_number'])->registerConverter('ComplexFixture', $this->newTestedInstance('\\PommProject\\ModelManager\\Test\\Fixture\\ComplexFixture', new ComplexFixtureStructure()), ['complex_fixture']); return $session; }
protected function initializeSession(Session $session) { $session->registerClientPooler(new ConverterPooler(new ConverterHolder()))->registerClientPooler($this->newTestedInstance()); }
protected function getQueryManager(Session $session) { $query_manager = $this->newTestedInstance(); $session->registerClient($query_manager); return $query_manager; }
protected function initializeSession(Session $session) { $session->registerClient(new InspectorFixture()); }
protected function initializeSession(Session $session) { $session->registerClient(new SimpleFixtureModel()); }
protected function initializeSession(Session $session) { $session->registerClient(new MockListener('pika'))->registerClient(new MockListener('chu')); }
/** * toPg * * @see ConverterInterface */ public function toPg($data, $type, Session $session) { return $data !== null ? sprintf("%s %s", $type, $session->getConnection()->escapeLiteral($data)) : sprintf("NULL::%s", $type); }
protected function getWeirdFixtureModel(Session $session) { return $session->getModel('PommProject\\ModelManager\\Test\\Fixture\\WeirdFixtureModel'); }
/** * escapeByteString * * Escape a binary string to postgres. * * @access protected * @param mixed $string * @param Session $session * @return string */ protected function escapeByteString(Session $session, $string) { return preg_replace(["/\\\\/", '/"/'], ["\\", '""'], $session->getConnection()->escapeBytea($string)); }