Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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];
 }
Exemplo n.º 3
0
 /**
  * __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();
 }
Exemplo n.º 4
0
 /**
  * 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]);
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
0
 protected function initializeSession(Session $session)
 {
     $session->registerClientPooler(new ObserverPooler());
 }
Exemplo n.º 7
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new StructureFixtureClient());
 }
Exemplo n.º 8
0
 private function sendAsPostgresParameter($value, $type, Session $session)
 {
     $result = $session->getQueryManager()->query(sprintf("select \$*::%s as my_test", $type), [$value])->current();
     return $result['my_test'];
 }
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 12
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new InspectorFixture());
 }
Exemplo n.º 13
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new SimpleFixtureModel());
 }
Exemplo n.º 14
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new MockListener('pika'))->registerClient(new MockListener('chu'));
 }
Exemplo n.º 15
0
 /**
  * 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);
 }
Exemplo n.º 16
0
 protected function getWeirdFixtureModel(Session $session)
 {
     return $session->getModel('PommProject\\ModelManager\\Test\\Fixture\\WeirdFixtureModel');
 }
Exemplo n.º 17
0
 /**
  * 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));
 }