Created
November 21, 2010 17:42
-
-
Save thiagosf/708944 to your computer and use it in GitHub Desktop.
Arquivo de erro para facilitar na criação de arquivos de controle para CakePHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2><?php __('Missing Controller'); ?></h2> | |
<p class="error"> | |
<strong><?php __('Error'); ?>: </strong> | |
<?php echo sprintf(__('%s could not be found.', true), "<em>" . $controller . "</em>");?> | |
</p> | |
<p class="error"> | |
<strong><?php __('Error'); ?>: </strong> | |
<?php echo sprintf(__('Create the class %s below in file: %s', true), "<em>" . $controller . "</em>", APP_DIR . DS . "controllers" . DS . Inflector::underscore($controller) . ".php");?> | |
</p> | |
<pre> | |
<?php | |
class <?php echo $controller;?> extends AppController { | |
var $name = '<?php echo $controllerName;?>'; | |
} | |
?> | |
</pre> | |
<p class="notice"> | |
<strong><?php __('Notice'); ?>: </strong> | |
<?php echo sprintf(__('If you want to customize this error message, create %s', true), APP_DIR . DS . "views" . DS . "errors" . DS . "missing_controller.ctp");?> | |
</p> | |
<?php | |
// Criando arquivo autmaticamente | |
if (isset($_GET['auto'])) { | |
$valor = "<?php | |
class {$controller} extends AppController { | |
var \$name = '{$controllerName}'; | |
// é | |
function index () { | |
} | |
} | |
?>"; | |
$name = '..' . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'; | |
if (!is_file($name)) { | |
$fp = fopen($name, 'a'); | |
fwrite($fp, utf8_encode($valor)); | |
fclose($fp); | |
echo '<p><a href="">Arquivo criado com sucesso!</a></p>'; | |
} | |
} | |
else { | |
$name = '..' . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'; | |
if (!is_file($name)) { | |
echo '<p><a href="?auto=true">Criar aquivo</a></p>'; | |
} | |
} | |
// Fim da criação do arquivo | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment