Пример #1
0
 protected function registerServices($servicesPath)
 {
     $services = (require $servicesPath . '.php');
     foreach ($services as $name => &$service) {
         \Scoop\IoC\Service::register($name, $service);
     }
     return $this;
 }
Пример #2
0
 /**
  * Establece la configuración inicial de los atributos del Helper
  * @param array $components colección de componentes usados por la vista.
  */
 public function __construct($components)
 {
     $this->components = $components;
     $this->config = \Scoop\IoC\Service::getInstance('config');
     self::$assets = (array) $this->config->get('assets') + self::$assets;
     if (isset($_SESSION['errors-scoop'])) {
         $this->errors = $_SESSION['errors-scoop'];
         unset($_SESSION['errors-scoop']);
     }
 }
Пример #3
0
 public function __construct($statusCode, $message = null, \Exception $previous = null, array $headers = array(), $code = 0)
 {
     $config = \Scoop\IoC\Service::getInstance('config');
     parent::__construct($message, $code, $previous);
     $this->statusCode = $statusCode;
     $this->headers = $headers;
     $this->title = $config->get('exception.' . $statusCode);
     $this->path = $config->get('exception.path');
     if (!$this->title) {
         $this->title = 'Error ' . $statusCode . '!!!';
     }
     if (!$this->path) {
         $this->path = 'exceptions/';
     }
 }
Пример #4
0
 public static function get($conf = null)
 {
     $bundle = 'db.default';
     if (is_string($conf)) {
         $bundle = $conf;
     }
     $config = \Scoop\IoC\Service::getInstance('config')->get($bundle);
     if (is_array($conf)) {
         $config += $conf;
     }
     $key = implode('', $config);
     if (!isset(self::$instances[$key])) {
         self::$instances[$key] = new DBC($config['database'], $config['user'], $config['password'], $config['host'], $config['driver']);
     }
     return self::$instances[$key];
 }
Пример #5
0
 /**
  * Obtiene el servicio especificado por el usuario.
  * @param string $serviceName Nombre del servicio a obtener.
  * @return object Servicio a obtener.
  */
 protected function getService($serviceName)
 {
     return \Scoop\IoC\Service::getInstance($serviceName);
 }
Пример #6
0
 /**
  * Reglas de reemplazo para cada uno de los comandos de la plantilla.
  * EJ: @extends 'template' => \Scoop\View\Helper::extend('template').
  * @param string $line Linea que se encuentra analizando el parseador.
  * @return boolean Existio o no reemplazo dentro de la linea.
  */
 private static function replace(&$line)
 {
     $line = preg_replace(array('/@extends \'([\\w\\/-]+)\'/', '/@import \'([\\w\\/-]+)\'/', '/@if ([ \\w\\.\\&\\|\\$!=<>\\/\\+\\*\\-\\(\\)\\[\\]%\']+)/', '/@elseif ([ \\w\\.\\&\\|\\$!=<>\\/\\+\\*\\-\\(\\)\\[\\]%\']+)/', '/@foreach ([ \\w\\.\\&\\|\\$\\->:\\(\\)\\[\\]%\']+)/', '/@for ([ \\w\\.\\&\\|\\$;,\\(\\)!=<>\\+\\-\\(\\)\\[\\]%\']+)/', '/@while ([ \\w\\.\\&\\|\\$\\(\\)!=<>\\+\\-\\(\\)\\[\\]%\']+)/'), array(self::HERITAGE . '::extend(\'${1}\')', self::HERITAGE . '::import(\'${1}\')', 'if(${1}):', 'elseif(${1}):', 'foreach(${1}):', 'for(${1}):', 'while(${1}):'), $line, 1, $count);
     if ($count !== 0) {
         $line = \Scoop\IoC\Service::compileView($line);
         return true;
     }
     $line = str_replace(array(':if', ':foreach', ':for', ':while', '@else', '@sprout'), array('endif', 'endforeach', 'endfor', 'endwhile', 'else:', self::HERITAGE . '::sprout()'), $line, $count);
     if ($count !== 0) {
         return true;
     }
     $line = preg_replace('/\\{([\\w\\s\\.\\$\\[\\]\\(\\)\'\\"\\/\\+\\*\\-\\?:=!<>,#]+)\\}/', '<?php echo ${1} ?>', $line, -1, $count);
     if ($count !== 0) {
         $line = \Scoop\IoC\Service::compileView($line);
     }
     return false;
 }