Esempio n. 1
0
 /**
  * Fabrica de Elementos
  * @param string $graphType
  * @param array $data
  * @return GraphicElement
  */
 public static function factory($graphType, $data)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull(self::_validateGraph($graphType), "Tipo de Gráfico não suportado");
     $class = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . 'elements' . self::NAMESPACE_SEPARATOR . self::$_graphAllowed[$graphType];
     self::$_graphEl = new $class($data);
     return self::$_graphEl;
 }
Esempio n. 2
0
 /**
  * Fábrica de Config.
  *
  * @param string $dsName
  * @throws IllegalArgumentException
  * @return Config
  * */
 public static function factory($dsName = NULL)
 {
     $data = self::$configs[$dsName];
     IllegalArgumentException::throwsExceptionIfParamIsNull(in_array($data['version'], self::$_acceptedLdapVersion), sprintf(self::CONFIG_UNSUPPORTED_VERSION, $data['version']));
     $namespace = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . 'Config';
     return new $namespace($data);
 }
Esempio n. 3
0
 /**
  * Cria flash message
  * @param string $message
  * @param string $type
  */
 public function setFlashMessage($message, $type = NULL)
 {
     if (empty($message)) {
         throw IllegalArgumentException::argumentCantBeNull('message');
     }
     $this->_session->set($this->_getType($type), $message);
 }
Esempio n. 4
0
 /**
  * (non-PHPdoc)
  * @see br\gov\sial\core\SIALAbstract::__call()
  */
 public function __call($name, array $arguments = array())
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull($this->hasMethod($name), "Método '<i>{$name}</i>' não existe");
     // @codeCoverageIgnoreStart
     $this->{$name}($arguments);
     return $this;
     // @codeCoverageIgnoreEnd
 }
Esempio n. 5
0
 /**
  * @param mixed $config
  * @param string $section
  * @throws IllegalArgumentException
  * */
 public function __construct($config, $section)
 {
     if (!$this->isSuported($config)) {
         throw IllegalArgumentException::invalidArgument($config);
     }
     $this->_section = $section;
     $this->load($config, $section);
 }
Esempio n. 6
0
 /**
  * Fábrica de Config
  *
  * @param string $dsName
  * @return Config
  * @throws IllegalArgumentException
  * */
 public static function factory($dsName = NULL)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull($dsName, self::CONFIG_MANDATORY_DATASOURCE);
     $data = self::$configs[$dsName];
     IllegalArgumentException::throwsExceptionIfParamIsNull($data['hostname'], self::CONFIG_MANDATORY_HOSTNAME);
     $namespace = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . 'Config';
     return new $namespace($data);
 }
 /**
  * @throws IllegalArgumentException
  */
 protected function isValidType()
 {
     $typesAccepted = array('info', 'success', 'warning', 'danger', 'striped');
     $types = (array) $this->_type;
     foreach ($types as $type) {
         IllegalArgumentException::throwsExceptionIfParamIsNull(in_array($type, $typesAccepted), self::T_ALERTABSTRACT_INVALID_TYPE);
     }
 }
Esempio n. 8
0
 /**
  * Column.
  *
  * @override
  * <ul>
  *     <li>self::column(Column $column);</li>
  *     <li>self::column(array(Column $column, ..., Column $column));</li>
  * </ul>
  *
  * @param Column[] $columns
  * @throws IllegalArgumentException
  * @return ClauseAbstract
  * */
 public function column($columns)
 {
     if (TRUE == is_array($columns)) {
         foreach ($columns as $column) {
             $this->column($column);
         }
         return;
     }
     IllegalArgumentException::throwsExceptionIfParamIsNull($columns instanceof Column, self::CLAUSE_MANDATORY_COLUMN);
     $this->_columns[] = $columns;
     return $this;
 }
Esempio n. 9
0
 /**
  * Importa um viewScript de outro módulo.
  * <p>
  *     Se o segundo param for informado define o sistema/modulo do viewScript
  * </p>
  * <p>
  *     Se o terceiro param for inforamdo define qual tipo de de viewScript sera importado (html, json, etc...)
  * </p>
  * <p>
  *     O viewScript devera em um dos subsistemas em application
  * </p>
  * <p>
  *     O quarto param define o contexto que o vScript ira trabalhar, caso seja informado
  * </p>
  *
  * @code
  * <?php
  *     Import::import('frmCadastro', 'sica/sistema');
  *
  *     // ou
  *
  *     Import::import('frmCadastro', 'sica/sistema', 'html');
  * ?>
  * @endcode
  *
  * @param string $vScript
  * @param string $module
  * @param string $type
  * @param Object $contexto
  * @throws IllegalArgumentException
  * */
 public function import($vScript, $module = NULL, $type = 'html', $vthis = NULL)
 {
     # basepath
     $basepath = debug_backtrace();
     preg_match('/(?<basepath>.*)\\/application\\/(?<module>.*)\\/mvcb/', $basepath[2]['file'], $pathInfo);
     # full application path
     $basepath = $pathInfo['basepath'] . DIRECTORY_SEPARATOR . 'application';
     # module
     $module = $module ?: $pathInfo['module'];
     # mount vScript fullpath
     $vScriptPath = $basepath . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . preg_replace('/:/', DIRECTORY_SEPARATOR, "mvcb:view:scripts:{$type}:") . ucfirst($vScript) . '.phtml';
     IllegalArgumentException::throwsExceptionIfParamIsNull(is_file($vScriptPath), self::MISSING_VSCRIPT);
     require_once $vScriptPath;
 }
Esempio n. 10
0
 /**
  * Fábrica de Config.
  *
  * @param string $dsName
  * @return br\gov\sial\core\persist\database\Config
  * @throws br\gov\sial\core\exception\IllegalArgumentException
  * */
 public static function factory($dsName = NULL)
 {
     # devido a interface, o php obriga q o paramentro seja identico
     # ao da superclasse, mas nesta classe este paramentro é obrigatorio,
     # o contrario da superclasse, assim, eh necessario manter manter a
     # compatibilidade de escrita e esta verificacao bizzara devido a exigencia
     # NOTA: Obrigado ao CTIS::Mario
     IllegalArgumentException::throwsExceptionIfParamIsNull($dsName, self::CONFIG_MANDATORY_PARAMETER);
     $message = sprintf(self::CONFIG_SECTION_UNDEFINED, $dsName);
     IllegalArgumentException::throwsExceptionIfParamIsNull(isset(self::$configs[$dsName]), $message);
     $data = self::$configs[$dsName];
     $message = sprintf(self::CONFIG_DB_UNSUPPORTED, $data['driver']);
     IllegalArgumentException::throwsExceptionIfParamIsNull(self::isSupported($data['driver']), $message);
     $namespace = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . $data['driver'] . self::NAMESPACE_SEPARATOR . 'Config';
     return new $namespace($data);
 }
Esempio n. 11
0
 /**
  * @inheritdoc
  * */
 public function add($elType, $config = NULL, $area = 'body')
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull('head' == $area || 'body' == $area, self::T_APPLICATION_INVALID_AREA);
     $decorator = $this->_decorator;
     # designa a criacao do elemento
     $setup = (object) $config;
     $element = $decorator->{$elType}($setup);
     # @todo remover este foreach e coloca-lo diretamente no decorator
     foreach ($setup as $idx => $val) {
         if ('data' == $idx) {
             continue;
         }
         if ('grid' == $elType || 'img' == $elType || 'textarea' == $elType || 'menuNavbar' == $elType || 'buttonbar' == $elType || 'radioGroup' == $elType || 'fieldset' == $elType) {
             continue;
         }
         if ('content' == $idx) {
             $decorator->setContent($element, $setup);
             continue;
         }
         $element->{$idx} = $val;
     }
     $this->_document->{$area}->add($element);
     return $this;
 }
Esempio n. 12
0
 /**
  * Retorna o slot informado.
  *
  * @param string $key
  * @return string
  * @throws IllegalArgumentException
  * */
 public function get($key)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull($this->has($key), sprintf(self::T_SLOT_STR_SLOT_UNAVAILABLE, $key));
     return $this->_slots[$key];
 }
Esempio n. 13
0
 /**
  * Registra lista de ordenadores da pesquisa.
  * @example Persist::orderBy
  * @code
  * <?php
  *     ...
  *     $persist->orderBy('nome', 'ASC');
  *     ...
  * ?>
  * @endcode
  * @param string $field
  * @param string $order (ASC | DESC)
  * */
 public function orderBy($field, $order = 'ASC')
 {
     # o nome da diretriz de ordenacao deve ser em maiusculo
     $order = ($order = trim($order)) ? strtoupper($order) : 'ASC';
     IllegalArgumentException::throwsExceptionIfParamIsNull(in_array($order, array('ASC', 'DESC')), self::PERSIST_INVALID_ORDERBY_ARG);
     $this->_orderByList[$field] = $order;
     return $this;
 }
Esempio n. 14
0
 /**
  * Intercepta a chamada aos métodos Query::and e Query::or
  *
  * @example database::Query::and
  * @example database::Query::or
  * <code>
  * <?php
  *     # vide Query::factory
  *     $query  = Query::factory($driver, $entity);
  *
  *     # aplica codicao where a pesquisa
  *     $query->where($conditional)
  *
  *     # aplica segunda condicao (AND) a pesquisa
  *           ->and($conditional)
  *
  *     # aplica terceira condicao (OR) a pesquisa
  *           ->or($conditional)
  *
  *     # obtem representacao textual da pesquisa
  *           ->render();
  * ?>
  * </code>
  *
  * @param string $method
  * @param mixed[] $arguments
  * @return Query
  * @throws IllegalArgumentException
  * */
 public function __call($method, $arguments)
 {
     $expression = current($arguments);
     $message = sprintf(self::QUERY_METHOD_UNAVAILABLE, __CLASS__, $method);
     IllegalArgumentException::throwsExceptionIfParamIsNull($expression instanceof RelationalAbstract, $message);
     $method = strtolower($method);
     switch ($method) {
         case 'and':
             $this->where($expression);
             break;
         case 'or':
             $this->where($expression, Where::T_OR_OPERATOR);
             break;
     }
     return $this;
 }
Esempio n. 15
0
 /**
  * carrega arquivo de constant
  *
  * @param string $fileContants
  * @throws IllegalArgumentException
  * */
 public function load($fileContants)
 {
     $message = "Arquivo de constante inexistente ({$fileContants})";
     IllegalArgumentException::throwsExceptionIfParamIsNull(is_file($fileContants), $message);
     // @codeCoverageIgnoreStart
     require_once $fileContants;
     // @codeCoverageIgnoreEnd
 }
Esempio n. 16
0
 private function isValidType($type)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull($type == 'tabs' || $type == 'lists' || $type == 'pills', self::T_NAVIGATIONABSTRACT_INVALID_TYPE);
 }
Esempio n. 17
0
 /**
  * Barra de botões de ações.
  *
  * @param stdClass $config
  * @return Div
  * @throws IllegalArgumentException
  * */
 public function buttonbar(\stdClass $config)
 {
     $elemnts = array('first' => array('label' => 'primeiro', 'name' => 'first', 'icon' => 'icon-fast-backward'), 'prev' => array('label' => 'anterior', 'name' => 'previous', 'icon' => 'icon-chevron-left'), 'next' => array('label' => 'próximo', 'name' => 'next', 'icon' => 'icon-chevron-right'), 'last' => array('label' => 'último', 'name' => 'last', 'icon' => 'icon-fast-forward'), 'save' => array('label' => 'salvar', 'name' => 'save', 'icon' => 'icon-download-alt'), 'edit' => array('label' => 'alterar', 'name' => 'edit', 'icon' => 'icon-pencil'), 'complete' => array('label' => 'concluir', 'name' => 'complete', 'icon' => 'icon-ok'), 'abort' => array('label' => 'anterior', 'name' => 'about', 'icon' => 'icon-remove'), 'cancel' => array('label' => 'cancelar', 'name' => 'cancel', 'icon' => 'icon-ban-circle'), 'delete' => array('label' => 'excluir', 'name' => 'delete', 'icon' => 'icon-trash'));
     $buttonbar = new Div();
     $buttonbar->addClass('form-actions');
     foreach ($config->elements as $elm) {
         IllegalArgumentException::throwsExceptionIfParamIsNull(isset($elemnts[$elm]), 'botão indisponível');
         $property = (object) $elemnts[$elm];
         $button = $this->button($property);
         $span = new Span();
         $span->addClass($property->icon);
         $button->add($span);
         $buttonbar->add($button);
     }
     return $buttonbar;
 }
Esempio n. 18
0
 /**
  * Fábrica de config.
  *
  * @param string $dsName
  * @param string[] $data
  * @return PersistConfig
  * @throws IllegalArgumentException
  * */
 public static function factory($dsName = NULL, array $data = null)
 {
     $nsSep = self::NAMESPACE_SEPARATOR;
     $config = $data ?: self::$configs;
     $message = self::PERSISTCONFIG_INSTRUCTION_CREATE_CONFIG_OBJECT;
     IllegalArgumentException::throwsExceptionIfParamIsNull(!(NULL == $config), $message);
     $dsName = $dsName ?: $config['default'];
     $message = sprintf(self::PERSISTCONFIG_UNDEFINED_CONFIG_SECTION, $dsName);
     IllegalArgumentException::throwsExceptionIfParamIsNull(isset($config[$dsName]), $message);
     $nsep = self::NAMESPACE_SEPARATOR;
     $tmpNamespace = __NAMESPACE__ . $nsep . $config[$dsName]['adapter'] . $nsep . 'Config';
     return $tmpNamespace::factory($dsName);
 }
Esempio n. 19
0
 /**
  * Adiciona os elementos que irão compor o buttonBar
  *
  * @param stdClass $param
  * @return ButtonBar
  * @throws IllegalArgumentException
  * */
 private function _addElements(\stdClass $param = NULL)
 {
     foreach ($this->safeToggle($param, 'options', new \stdClass()) as $elm) {
         if (is_object($elm)) {
             $type = $elm->type;
             unset($elm->type);
         } else {
             $type = $elm;
         }
         IllegalArgumentException::throwsExceptionIfParamIsNull(isset($this->_elements[$type]), self::T_BUTTONBARABSTRACT_INVALID_BUTTON);
         $property = (object) $this->_elements[$type];
         if (is_object($elm)) {
             foreach ($elm as $prop => $value) {
                 $property->{$prop} = $value;
             }
         }
         switch ($property->element) {
             case 'button':
                 $button = new Button($property->label, $property->name);
                 break;
             case 'anchor':
                 $href = isset($property->href) ? $property->href : '#';
                 $button = new Anchor($property->label, $href);
                 break;
         }
         $button->id = $this->genId($property);
         $button->addClass(array('btn', 'btn-' . $property->name));
         if (isset($property->type)) {
             $button->attr('type', $property->type);
         }
         if (isset($property->icon)) {
             $span = new Span();
             $span->addClass($property->icon);
             $button->add($span);
         }
         if (isset($param->primary) && $param->primary == $property->name) {
             $button->addClass('btn-primary');
             if (isset($property->icon)) {
                 $span->addClass('icon-white');
             }
         }
         $this->_buttonBar->add($button)->add(new Text('&nbsp;'));
     }
     return $this;
 }
Esempio n. 20
0
 /**
  * Cria aplicação.
  *
  * @example ApplicationAbstract::factory
  * @code
  * <?php
  *     $decStyle = 'ICMBioGreen';
  *     $docType  = 'html';
  *
  *     # decorador do documento
  *     $decorator = DecoratorAbstract::factory($docType, $decStyle);
  *
  *     # criar aplicacao simples sem decorator
  *     $app = ApplicationAbstract::factory($docType, $decorator);
  * ?>
  * @endcode
  *
  * @param string $type
  * @param DecoratorAbstract $decorator
  * @return Application
  * @throws IllegalArgumentException
  * */
 public static function factory($type, $decorator = NULL)
 {
     $NSApplication = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . 'application' . self::NAMESPACE_SEPARATOR . 'Application' . strtoupper($type);
     IllegalArgumentException::throwsExceptionIfParamIsNull(Location::hasClassInNamespace($NSApplication), self::T_APPLICATION_INVLAID_APP);
     $application = new $NSApplication();
     $application->_decorator = $decorator;
     return $application;
 }
Esempio n. 21
0
 /**
  * @param stdClass $param
  * @param string $type
  * @throws IllegalArgumentException
  * */
 public static function factory(\stdClass $param, $type)
 {
     $namespace = __NAMESPACE__ . self::NAMESPACE_SEPARATOR . $type . self::NAMESPACE_SEPARATOR . 'ScreenForm';
     IllegalArgumentException::throwsExceptionIfParamIsNull(Location::hasClassInNamespace($namespace), self::T_SCREENFORMABSTRACT_COMPONENT_UNAVAILABLE);
     return $namespace::factory($param);
 }
Esempio n. 22
0
 /**
  * Fábrica de Business.
  * @example BusinessAbstract::getModel
  * @code
  * <?php
  *     ...
  *     //constroi um objeto business do modulo que invoca o método
  *     BusinessAbstract::factory();
  *
  *     //ou
  *
  *     BusinessAbstract::factory('\foobar\business\FooBusiness', 'libcorp');
  *     ...
  * ?>
  * @endcode
  * @param string | ControllerAbstract $namespace
  * @param string $persist
  * @return BusinessAbstract
  * @throws IllegalArgumentException
  * */
 public static function factory($namespace = NULL, $dsName = NULL)
 {
     $business = NULL;
     $type = gettype($namespace);
     if ('string' == $type) {
         $business = new $namespace();
     }
     if (NULL === $namespace) {
         $business = get_called_class();
     }
     if ('object' == $type && $namespace instanceof ControllerAbstract) {
         $business = self::_factoryByController($namespace);
     }
     IllegalArgumentException::throwsExceptionIfParamIsNull($business, self::INVALID_PARAMETER_FOR_BUSINESS);
     $business = new $business();
     if (NULL != $dsName) {
         $business->getModel($dsName);
     }
     return $business;
 }
Esempio n. 23
0
 /**
  * Dispara um evento.
  *
  * @param string $event
  * @param mixed $eventParameters = NULL
  * @throws IllegalArgumentException
  * */
 public function raise($event, $eventParameters = NULL)
 {
     $event = $this->eventNameStandardize($event);
     if (!$this->hasEvent($event)) {
         return;
     }
     IllegalArgumentException::throwsExceptionIfParamIsNull(!$this->isAutoEvent($event), sprintf(self::T_EVENT_ELEMENT_INVALID_EVENT, $event));
     $before = 'before' . $event;
     $after = 'after' . $event;
     # raise onbefore
     if ($this->hasEvent($before)) {
         $this->_raise($before, $eventParameters);
     }
     # dispara evento principal
     $this->_raise($event, $eventParameters);
     # raise onafter
     if ($this->hasEvent($after)) {
         $this->_raise($after, $eventParameters);
     }
 }
Esempio n. 24
0
 /**
  * @param string $name
  * @return stdClass
  * IllegalArgumentException
  * */
 public function get($name)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull($this->hasAttr($name), self::T_FKCONFIG_ATTR_NOT_AVAILABLE);
     return $this->_stack[$name];
 }
Esempio n. 25
0
 /**
  * Cria as classes necessarias caso nao existam
  * */
 public function createClassIfNotExists()
 {
     # bootstrap
     $bootstrap = $this->_config->get('app.mainnamespace') . self::NAMESPACE_SEPARATOR . 'library';
     $MVCBNamespace = $this->_config->get('app.mainnamespace') . self::NAMESPACE_SEPARATOR . 'library' . self::NAMESPACE_SEPARATOR . 'mvcb' . self::NAMESPACE_SEPARATOR;
     $view = $MVCBNamespace . 'view';
     $model = $MVCBNamespace . 'model';
     $business = $MVCBNamespace . 'business';
     $controller = $MVCBNamespace . 'controller';
     $viewName = ucfirst($this->_config->get('app.view.type'));
     IllegalArgumentException::throwsExceptionIfParamIsNull($viewName, 'O tipo de view não foi definido, informe o param app.view.type = HTML, por exemplo, no config.ini');
     CreateClassIfNotExists::create($bootstrap, 'Bootstrap', '\\br\\gov\\sial\\core\\BootstrapAbstract');
     CreateClassIfNotExists::create($view, $viewName, '\\br\\gov\\sial\\core\\mvcb\\view' . self::NAMESPACE_SEPARATOR . $viewName);
     CreateClassIfNotExists::create($model, 'ModelAbstract', '\\br\\gov\\sial\\core\\mvcb\\model\\ModelAbstract');
     CreateClassIfNotExists::create($business, 'BusinessAbstract', '\\br\\gov\\sial\\core\\mvcb\\business\\BusinessAbstract');
     CreateClassIfNotExists::create($controller, 'ControllerAbstract', '\\br\\gov\\sial\\core\\mvcb\\controller\\ControllerAbstract');
 }
 /**
  * @param Component
  * @return ElementContainerAbstract
  * @throws IllegalArgumentException
  * */
 public function add($component)
 {
     /*
      * esta lambaça toda eh devido a limitacao do php em reconhecer
      * param formais como method (Component[] $component)
      * */
     if (!is_array($component)) {
         $component = array($component);
     }
     foreach ($component as $cmp) {
         IllegalArgumentException::throwsExceptionIfParamIsNull($cmp instanceof Component, 'tipo não aceito');
         $this->_children[] = $cmp;
     }
     return $this;
 }
Esempio n. 27
0
 /**
  * avalia se o container informado sao validos
  * retorna o tipo do container, se o mesmo for valido, ou lanca um sialException
  *
  * @code
  * <?php
  *  # elemento para teste
  *  $arr = array ('foo', 'bar');
  *
  *  echo SialAbstract::isArrayOrObject($arr);
  *  // output: array
  *
  *  $obj = new stdClass();
  *  echo SialAbstract::isArrayOrObject($obj);
  *  // output: object
  *
  *  SialAbstract::isArrayOrObject($arr['foo']);
  *  // IllegalArgumentException
  * ?>
  * @endcode
  * @param mixed $container
  * @return boolean
  * @throws SIALException
  * */
 public static function isArrayOrObject($data)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull(is_array($data) || is_object($data), self::UNSUPPORTED_TYPE);
     return TRUE;
 }
Esempio n. 28
0
 /**
  * Converte a string informada em nome de permissão.
  *
  * @param string $roleName
  * @return string
  * @throws IllegalArgumentException
  * */
 public static function handleName($roleName)
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull(!empty($roleName), 'Nome da Role é inválida');
     $roleName = preg_replace('/[^a-zA-Z]/', '_', $roleName);
     return strtoupper($roleName);
 }
Esempio n. 29
0
 /**
  * Fábrica de Command.
  *
  * @param Language $language
  * @param Element $element
  * @return Command
  * @throws IllegalArgumentException
  * */
 public static function factory(Language $laguage, Element $element)
 {
     # formata nome da linguagem e do command para uso
     $language = strtolower($laguage->name());
     $command = ucfirst($element->type());
     # monta o namespace do commando alvo levando em consideracao a
     # linguagem inforamda
     $namespace = sprintf('br\\gov\\sial\\core\\mvcb\\view\\skeleton\\%s\\command\\%s', $language, $command);
     $message = sprintf(self::UNAVAILABLE_COMMAND, $language, $command);
     IllegalArgumentException::throwsExceptionIfParamIsNull(self::isAvailable($namespace), $message);
     return new $namespace($laguage, $element);
 }
Esempio n. 30
0
 /**
  * Construtor.
  *
  * @param string $name
  * @param integer[] $items
  * @throws IllegalArgumentException
  * */
 public function __construct($name, array $tems = array())
 {
     IllegalArgumentException::throwsExceptionIfParamIsNull(trim($name), 'O nome informado é inválido');
     $this->_name = (string) $name;
     $this->addItems($tems);
 }