wbraganca avatar wbraganca committed 5e8e739

modificado classe BuscaPorCepAction para buscar o endereco sem depender do alias da extensao

Comments (0)

Files changed (4)

  * @package   extensions
  * @author	  Wanderson Bragança <wanderson.wbc@gmail.com>
  * @link	  https://bitbucket.org/wbraganca/correios
- * @version   1.0.4
+ * @version   1.0.5
  */
 class BuscaPorCep extends CWidget
 {
 	 * Mapa de campos
 	 * @var array $fieldsMap
 	 */
-	private $fieldsMap = array();
+	private $fieldsMap = array(
+		'location'=>'',
+		'district'=>'',
+		'city'=>'',
+		'state'=>'',
+		'result'=>0,
+	);
 
 	/**
 	 * Inicializa o Widget
 	public function init()
 	{
 		parent::init();
-		$this->fieldsMap = Yii::app()->buscaPorCepApp->getFieldsMap();
 	}
 
 	public function run()

BuscaPorCepApp.php

  * </code>
  *
  * Para realizar a busca de um endereço de um determinado CEP use:
- * $endereco = Yii::app()->buscaPorCepApp->run('12345-678');
+ * $endereco = Yii::app()->buscaPorCep->run('12345-678');
+ * 
+ * Para mais informações acesse o link: https://bitbucket.org/wbraganca/correios/
  *
  * @category  Extensions
  * @package   extensions
  * @author	  Wanderson Bragança <wanderson.wbc@gmail.com>
  * @link	  https://bitbucket.org/wbraganca/correios
- * @version   1.0.4
+ * @version   1.0.5
  */
 class BuscaPorCepApp extends CApplicationComponent
 {
 	);
 
 	/**
-	 * Retorna array com mapa de campos
-	 * @return array
-	 */
-	public function getFieldsMap()
-	{
-		return $this->fieldsMap;
-	}
-
-	/**
 	 * Inicializa o componente
 	 */
 	public function init()
 Extensão para buscar endereço por CEP para o Yii Framework 
 ==========================================================
 
-Versão: 1.0.4
+Versão: 1.0.5
 -------------
 
 A busca é realizada diretamente no website dos correios.
 Em seguinda adione na view:
 
 	:::php
-		<?php echo CHtml::button($this->label, array("id"=>"btnBuscarCep")); ?>
+		<?php echo CHtml::button("Buscar endereço", array("id"=>"btnBuscarCep")); ?>
 
 		<?php $this->widget('ext.correios.BuscaPorCep', array(
 			'target'=>'#btnBuscarCep',
 			'model'=>$modelEndereco,
 			'attribute'=>'cep',
-			'url'=>'/site/buscaPorCep',
+			'url'=>'/site/buscaPorCep',  
 			'config'=>array(
 				'location'=>'logradouro',
 				'district'=>'bairro',

actions/BuscaPorCepAction.php

 <?php
+require_once(realpath(dirname(__FILE__).'/../BuscaPorCepApp.php'));
 /**
  * BuscaPorCepAction class file
  *
  * @package   extensions
  * @author	  Wanderson Bragança <wanderson.wbc@gmail.com>
  * @link	  https://bitbucket.org/wbraganca/correios
- * @version   1.0.4
+ * @version   1.0.5
  */
 class BuscaPorCepAction extends CAction
 {
 	{
 		if( isset($_GET['cep']) ){
 			$cep = $_GET['cep'];
-			echo CJSON::encode( Yii::app()->buscaPorCepApp->run($cep) );
+			$obj = new BuscaPorCepApp();
+			echo CJSON::encode( $obj->run($cep) );
 		}
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.