Example #1
0
 /**
  * Using the current application configurations, retrieves an instance of the specified
  * template engine.
  *
  * @access public
  * @return Breeze\View\Driver\DriverInterface  The template engine.
  * @throws UnexpectedValueException
  */
 public function getEngine()
 {
     $engine_class = __NAMESPACE__ . '\\Driver\\' . $this->_application->config('template_engine');
     if (strtolower(get_class((object) $this->_engine)) != strtolower($engine_class)) {
         if (class_exists($engine_class) && in_array(__NAMESPACE__ . '\\Driver\\DriverInterface', class_implements($engine_class))) {
             $this->_engine = new $engine_class($this->_application, $this->_application->config('template_directory'), $this->_application->config('template_options'));
         } else {
             throw new \UnexpectedValueException(sprintf(self::INVALID_TEMPLATE_ENGINE_ERROR, $engine_class));
         }
     } else {
         $this->_engine->config();
     }
     return $this->_engine;
 }
Example #2
0
 /**
  * Sets up the {@link Breeze\Errors\Errors::$_default_error} instance variable
  * for handling errors with no defined handler.
  *
  * @access public
  * @param  Breeze\Application $application  an instance of the base Breeze Framework class for passing into closures.
  * @return void
  */
 public function __construct(Application $application)
 {
     $this->_application = $application;
     $this->_default_error = function (Application $application, \Exception $exception) use($application) {
         $body = sprintf("<h1>%s</h1>", $exception->getMessage());
         if ($application->config('errors_backtrace')) {
             $body .= sprintf('<pre><code>%s</code></pre>', $exception->getTraceAsString());
         }
         if ($application->layoutExists()) {
             echo $application->fetchLayout($body);
         } else {
             echo "<!DOCTYPE html><html><head><title>An error occurred</title></head><body>{$body}</body></html>";
         }
     };
 }
Example #3
0
define('BREEZE_APPLICATION', realpath(dirname(__FILE__)));
// The admin form messages
const POST_ERROR_MESSAGE = 'Oh no, something went wrong:';
const POST_CREATED_MESSAGE = 'Your post was successfully created.';
const POST_UPDATED_MESSAGE = 'Your post was successfully updated.';
const POST_DELETED_MESSAGE = 'Your post was successfully deleted.';
// Uncomment to use an alternate template engine
// require_once 'Breeze/plugins/breeze.dwoo.php';
// require_once 'Breeze/plugins/breeze.smarty.php';
// Setup the breeze framework components
require_once 'Breeze/plugins/breeze.flashhash.php';
require_once 'Breeze/Application.php';
$breeze = new Application();
require_once 'helpers.php';
// Configure the breeze framework
$breeze->config('template_directory', BREEZE_APPLICATION . '/views/' . strtolower($breeze->config('template_engine')));
$breeze->config('errors_backtrace', false);
$breeze->error('404', function ($breeze) {
    $breeze->display('errors/404');
});
$breeze->error(function ($breeze) {
    $breeze->display('errors/500');
});
// Setup the Doctrine model components
require_once 'Doctrine/lib/Doctrine.php';
\spl_autoload_register(array('Doctrine', 'autoload'));
\spl_autoload_register(array('Doctrine_Core', 'modelsAutoload'));
$manager = \Doctrine_Manager::getInstance();
$manager->setAttribute(\Doctrine_Core::ATTR_VALIDATE, \Doctrine_Core::VALIDATE_ALL);
$manager->setAttribute(\Doctrine_Core::ATTR_EXPORT, \Doctrine_Core::EXPORT_ALL);
$manager->setAttribute(\Doctrine_Core::ATTR_MODEL_LOADING, \Doctrine_Core::MODEL_LOADING_CONSERVATIVE);