Commit 8541bcd9df82c927e0b39ab083b1967d1fb2a577
1 parent
a9b56c76
Exists in
master
Aplicado correções a modelos / datamapper modulos educacenso e transporte
Showing
3 changed files
with
37 additions
and
13 deletions
Show diff stats
ieducar/modules/Educacenso/Model/Aluno.php
@@ -45,6 +45,16 @@ require_once 'Educacenso/Model/CodigoReferencia.php'; | @@ -45,6 +45,16 @@ require_once 'Educacenso/Model/CodigoReferencia.php'; | ||
45 | */ | 45 | */ |
46 | class Educacenso_Model_Aluno extends Educacenso_Model_CodigoReferencia | 46 | class Educacenso_Model_Aluno extends Educacenso_Model_CodigoReferencia |
47 | { | 47 | { |
48 | + protected $_data = array( | ||
49 | + 'aluno' => NULL, | ||
50 | + 'alunoInep' => NULL, | ||
51 | + 'nomeInep' => NULL, | ||
52 | + 'fonte' => NULL, | ||
53 | + 'created_at' => NULL, | ||
54 | + 'updated_at' => NULL | ||
55 | + ); | ||
56 | + | ||
57 | + | ||
48 | public function getDefaultValidatorCollection() | 58 | public function getDefaultValidatorCollection() |
49 | { | 59 | { |
50 | $validators = array( | 60 | $validators = array( |
@@ -54,12 +64,4 @@ class Educacenso_Model_Aluno extends Educacenso_Model_CodigoReferencia | @@ -54,12 +64,4 @@ class Educacenso_Model_Aluno extends Educacenso_Model_CodigoReferencia | ||
54 | 64 | ||
55 | return array_merge($validators, parent::getDefaultValidatorCollection()); | 65 | return array_merge($validators, parent::getDefaultValidatorCollection()); |
56 | } | 66 | } |
57 | - | ||
58 | - public function __construct(array $options = array()) | ||
59 | - { | ||
60 | - $this->_data['aluno'] = NULL; | ||
61 | - $this->_data['alunoInep'] = NULL; | ||
62 | - | ||
63 | - parent::__construct($options); | ||
64 | - } | ||
65 | } | 67 | } |
66 | \ No newline at end of file | 68 | \ No newline at end of file |
ieducar/modules/Educacenso/Model/AlunoDataMapper.php
@@ -48,14 +48,27 @@ class Educacenso_Model_AlunoDataMapper extends Educacenso_Model_CodigoReferencia | @@ -48,14 +48,27 @@ class Educacenso_Model_AlunoDataMapper extends Educacenso_Model_CodigoReferencia | ||
48 | protected $_entityClass = 'Educacenso_Model_Aluno'; | 48 | protected $_entityClass = 'Educacenso_Model_Aluno'; |
49 | protected $_tableName = 'educacenso_cod_aluno'; | 49 | protected $_tableName = 'educacenso_cod_aluno'; |
50 | 50 | ||
51 | + protected $_attributeMap = array( | ||
52 | + 'aluno' => 'cod_aluno', | ||
53 | + 'alunoInep' => 'cod_aluno_inep', | ||
54 | + 'nomeInep' => 'nome_inep', | ||
55 | + 'fonte' => 'fonte', | ||
56 | + 'created_at' => 'created_at', | ||
57 | + 'updated_at' => 'updated_at' | ||
58 | + ); | ||
59 | + | ||
60 | + // aparentemente o campo alunoInep não deveria fazer parte da chave primaria, pois este pode | ||
61 | + // ser alterado no cadastro de aluno, #TODO criar migracao para remover PK de tal campo ? | ||
51 | protected $_primaryKey = array( | 62 | protected $_primaryKey = array( |
52 | - 'aluno', 'alunoInep' | 63 | + 'aluno' #, 'alunoInep' |
53 | ); | 64 | ); |
54 | 65 | ||
55 | - public function __construct(clsBanco $db = NULL) | 66 | + // fixup para find funcionar em tabelas cujo PK não se chama id |
67 | + protected function _getFindStatment($pkey) | ||
56 | { | 68 | { |
57 | - $this->_attributeMap['aluno'] = 'cod_aluno'; | ||
58 | - $this->_attributeMap['alunoInep'] = 'cod_aluno_inep'; | ||
59 | - parent::__construct($db); | 69 | + if (! is_array($pkey)) |
70 | + $pkey = array('cod_aluno' => $pkey); | ||
71 | + | ||
72 | + return parent::_getFindStatment($pkey); | ||
60 | } | 73 | } |
61 | } | 74 | } |
62 | \ No newline at end of file | 75 | \ No newline at end of file |
ieducar/modules/Transporte/Model/AlunoDataMapper.php
@@ -58,4 +58,13 @@ class Transporte_Model_AlunoDataMapper extends CoreExt_DataMapper | @@ -58,4 +58,13 @@ class Transporte_Model_AlunoDataMapper extends CoreExt_DataMapper | ||
58 | ); | 58 | ); |
59 | 59 | ||
60 | protected $_primaryKey = array('aluno'); | 60 | protected $_primaryKey = array('aluno'); |
61 | + | ||
62 | + // fixup para find funcionar em tabelas cujo PK não se chama id | ||
63 | + protected function _getFindStatment($pkey) | ||
64 | + { | ||
65 | + if (! is_array($pkey)) | ||
66 | + $pkey = array('aluno_id' => $pkey); | ||
67 | + | ||
68 | + return parent::_getFindStatment($pkey); | ||
69 | + } | ||
61 | } | 70 | } |
62 | \ No newline at end of file | 71 | \ No newline at end of file |