protected function execute(InputInterface $input, OutputInterface $output)
 {
     $module = ucfirst($input->getArgument('module'));
     $controller = $input->getArgument('controller');
     if (!empty($controller)) {
         $controller = ucfirst($controller);
     } else {
         $controller = $module;
     }
     $controller .= 'PageController';
     $filename = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR;
     $filename .= 'page_controller.php.twig';
     if (file_exists($filename)) {
         $string = new TString(file_get_contents($filename));
         $string->replace('{{ controller }}', $controller)->replace('{{ module }}', $module)->replace('{{ date }}', date('d/m/Y'));
     } else {
         throw new FileNotFoundException("{$filename} nao encontrado");
     }
     $fileController = $this->modulesPath . $module . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . $controller . '.php';
     if (file_exists($this->modulesPath . $module)) {
         Filesystem::getInstance()->touch($fileController);
         Filesystem::getInstance()->chmod($fileController, 0660);
         $file = new File($fileController);
         $fileObject = $file->openFile('w');
         $fileObject->fwrite($string->getValue());
         $output->writeln("<info>OK: {$fileController} criado com sucesso</info>");
     } else {
         $output->writeln("<error>FALHA: O módulo {$module} não existe ou não é gravável</error>");
     }
 }
Exemplo n.º 2
0
 protected function registerListeners()
 {
     $listeners = (require Filesystem::getInstance()->getPath('root') . '/config/listeners.php');
     $dispatcher = $this->getKernel()->getDispatcher();
     foreach ($listeners as $listener) {
         $dispatcher->addSubscriber($listener);
     }
 }
Exemplo n.º 3
0
function primeExceptionHandler(Exception $exc)
{
    $logger = new Logger('app_runtime');
    $logger->pushHandler(new RotatingFileHandler(Filesystem::getInstance()->getPath('log') . '/app.log'));
    $code = $exc->getCode();
    if ($code == 0) {
        $code = Logger::ALERT;
    }
    $logger->log($code, $exc->getMessage());
}
Exemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->moduleName = $this->createModuleName($input->getArgument('name'));
     $baseDir = $this->appRoot . 'Modules' . DIRECTORY_SEPARATOR . $this->moduleName . DIRECTORY_SEPARATOR;
     $fs = \Prime\FileSystem\Filesystem::getInstance();
     if (!$input->getOption('simple')) {
         $output->writeln('Vamos criar o módulo ' . $baseDir . ' completo');
         $fs->mkdir([$baseDir . 'Business', $baseDir . 'Controller', $baseDir . 'Model', $baseDir . 'View']);
     } else {
         $output->writeln('Vamos criar o módulo ' . $baseDir . ' simples');
         $fs->mkdir([$baseDir . 'Controller']);
     }
     $fs->chmod($baseDir, 0770, 00, TRUE);
     $output->writeln('<info>Módulo ' . $this->moduleName . ' criado com sucesso</info>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->isConnected();
     $entity = $input->getArgument('entity');
     $dataSource = new CreateDataSource($entity);
     $dirBase = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'DataSource';
     $filename = realpath($dirBase) . DIRECTORY_SEPARATOR . $dataSource->getClassName() . '.php';
     Filesystem::getInstance()->touch($filename);
     Filesystem::getInstance()->chmod($filename, 0660);
     $file = new File($filename);
     $fileObject = $file->openFile('w');
     $fileObject->fwrite($dataSource->getOutput());
     $output->writeln("<info>{$filename} criado com sucesso!!!</info>");
     $output->writeln('<comment>Cria sua classe de modelo de dados e estenda de ' . $dataSource->getClassName() . '</comment>');
 }
 /**
  * Cria a estrutura de diretórios utilizados na aplicação
  */
 private function createSkeleton()
 {
     $fileSystem = Filesystem::getInstance();
     $fileSystem->mkdir(['App/Modules', 'App/Console', 'App/DataSource', 'App/Templates', 'public/assets/css', 'public/assets/js', 'public/storage', 'App/Templates', 'data/log', 'data/cache', 'data/doc'], 2770);
     $fileSystem->mirror(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'config', $this->dirBase . DIRECTORY_SEPARATOR . 'config');
 }
Exemplo n.º 7
0
<?php

use Prime\FileSystem\Filesystem;
/*
 |-------------------------------------------------------------------------
 | Arquivo de Configuração filesystem
 |-------------------------------------------------------------------------
 |
 | Define os principais diretórios que serão utilizados pela aplicação, tais
 | como armazenamento de log, cache, arquivos diversos
 |
*/
Filesystem::addPaths(['root' => dirname(__DIR__), 'log' => dirname(__DIR__) . DS . 'data' . DS . 'log', 'templates' => dirname(__DIR__) . DS . 'App' . DS . 'Templates', 'cache' => dirname(__DIR__) . DS . 'data' . DS . 'cache', 'storage' => dirname(__DIR__) . DS . 'public' . DS . 'storage']);
Exemplo n.º 8
0
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
/*
 |-------------------------------------------------------------------------
 | Autoload
 |-------------------------------------------------------------------------
 |
 | Insere o arquivo de carregamento automático
 |
*/
require_once __DIR__ . '/vendor/autoload.php';
/*
 |-------------------------------------------------------------------------
 | Configuração do Sistema de Arquivos
 |-------------------------------------------------------------------------
 |
 | Insere o arquivo de configuração do sistema de arquivos para a aplicação
 |
*/
require_once __DIR__ . '/config/filesystem.php';
/*
 |-------------------------------------------------------------------------
 | Diretório dos templates da aplicação
 |-------------------------------------------------------------------------
 |
 | Define o path para o diretório aonde se encontram os templates
 |
*/
Template::addPath(Filesystem::getInstance()->getPath('templates'), 'templates');
Exemplo n.º 9
0
 /**
  * Carrega as configurações e faz a configuração inicial do uso do Twig
  * para a manipulação dos templates na aplicação
  */
 protected function template()
 {
     $config = (require Filesystem::getInstance()->getPath('root') . '/config/view.php');
     Template::setEnviroment($config);
     $filesystem = Filesystem::getInstance();
     Template::addPath($filesystem->getPath('templates'));
 }