Last active
December 24, 2015 01:29
-
-
Save Bolinha1/6723429 to your computer and use it in GitHub Desktop.
Index com as rotas
This file contains hidden or 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
| <?pphp | |
| require_once 'vendor/autoload.php'; | |
| require_once 'src/controllers/Site/ControllerApp.php'; | |
| require_once 'src/controllers/Painel/ControllerPainel.php'; | |
| use Silex\Application; | |
| use Site\ControllerApp; | |
| use Painel\ControllerPainel; | |
| $app = new Application(); | |
| $app->register(new Silex\Provider\ServiceControllerServiceProvider()); | |
| //registro o controller referente a navegação do site | |
| $app['controller'] = $app->share(function () use ($app){ | |
| return new ControllerApp; | |
| }); | |
| // fim registro controller | |
| // rotas referentes a navegação do site | |
| $app->get('/', "controller:index"); | |
| $app->get('/quem-somos', "controller:quemSomos"); | |
| $app->get('/nossos-trabalhos', "controller:nossosTrabalhos"); | |
| $app->get('/produtos', "controller:produtos"); | |
| $app->get('/contatos', "controller:contatos"); | |
| $app->post('/enviar', "controller:enviar"); | |
| // fim rotas navegação site. | |
| $app['debug'] = 'true'; | |
| $app->run(); |
This file contains hidden or 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
| <?php | |
| namespace Site; | |
| include __DIR__.'/../../library/view/Site/View/View.php'; | |
| include __DIR__.'/../../helper/enviarEmail.php'; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Site\View\View; | |
| class ControllerApp | |
| { | |
| private $view; | |
| public function __construct() | |
| { | |
| $this->view = new View; | |
| } | |
| public function index() | |
| { | |
| return $this->view->load('index'); | |
| } | |
| public function quemSomos() | |
| { | |
| return $this->view->load('quemSomos'); | |
| } | |
| public function produtos() | |
| { | |
| return $this->view->load('produtos'); | |
| } | |
| public function nossosTrabalhos() | |
| { | |
| return $this->view->load('trabalhos'); | |
| } | |
| public function contatos() | |
| { | |
| return $this->view->load('contato'); | |
| } | |
| public function enviar(Request $request) | |
| { | |
| $nome = $request->get('nome'); | |
| $email = $request->get('email'); | |
| $assunto = $request->get('assunto'); | |
| $mensagem = $request->get('mensagem'); | |
| $enviar = enviar($nome,$email,$assunto, $mensagem); | |
| return $enviar; | |
| } | |
| } |
This file contains hidden or 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
| <?php | |
| namespace Painel\View; | |
| use Symfony\Component\Templating\PhpEngine; | |
| use Symfony\Component\Templating\TemplateNameParser; | |
| use Symfony\Component\Templating\Loader\FilesystemLoader; | |
| class View | |
| { | |
| public function load($view, $content = array()) | |
| { | |
| $loader = new FilesystemLoader(__DIR__.'/../../../../view/site/%name%'); | |
| $templating = new PhpEngine(new TemplateNameParser(), $loader); | |
| return $templating->render("$view.php", $content); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment