Skip to content

Instantly share code, notes, and snippets.

@francisrod01
Last active December 19, 2015 18:48
Show Gist options
  • Save francisrod01/6001423 to your computer and use it in GitHub Desktop.
Save francisrod01/6001423 to your computer and use it in GitHub Desktop.
Primeiro o /Lib/LoadConfig/static.php depois o /Controller/UsersController.php
App::import('Lib', 'LoadConfigs', array('file' => 'static.php'));
class AppController extends Controller {
..
<?php
/**
* @todo Funções estáticas
*/
class LoadConfigs {
// Apos carregar a action responsavel
static function afterRender() {
$render = '/' . $this->folder_view . '/' . $this->params['controller'] . '/' . $this->params['action'];
return $this->render($render);
}
static function __cURL($url) {
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
if (!empty($output)) {
return $output;
}
else {
return NULL;
}
}
}
?>
<?php
App::uses('AppController', 'Controller');
/**
* Users Controller
*
* @property User $User
*/
class UsersController extends AppController {
/**
* index method
*
* @return void
*/
public function admin_index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
$this->LoadConfig->afterRender();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment