protected function registerServices($servicesPath) { $services = (require $servicesPath . '.php'); foreach ($services as $name => &$service) { \Scoop\IoC\Service::register($name, $service); } return $this; }
/** * 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']); } }
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/'; } }
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]; }
/** * 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); }
/** * 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; }