示例#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;
 }
 /**
  * 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();
 }
示例#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]);
 }
 /**
  * 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;
 }
示例#6
0
 protected function initializeSession(Session $session)
 {
     $session->registerClientPooler(new ObserverPooler());
 }
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new StructureFixtureClient());
 }
示例#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'];
 }
示例#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;
 }
示例#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;
 }
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new InspectorFixture());
 }
示例#13
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new SimpleFixtureModel());
 }
示例#14
0
 protected function initializeSession(Session $session)
 {
     $session->registerClient(new MockListener('pika'))->registerClient(new MockListener('chu'));
 }
示例#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);
 }
示例#16
0
 protected function getWeirdFixtureModel(Session $session)
 {
     return $session->getModel('PommProject\\ModelManager\\Test\\Fixture\\WeirdFixtureModel');
 }
示例#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));
 }