Esempio n. 1
0
 /**
  * (@fake: public static)
  *
  * @override
  * @throws IllegalArgumentException
  * */
 public function __get($name)
 {
     $attr = "_{$name}";
     if (property_exists($this, $attr)) {
         return $this->{$attr};
     }
     parent::__get($name);
     // @codeCoverageIgnoreStart
 }
Esempio n. 2
0
 /**
  * acesso as referencias dos objetos ou à 'saf' ou à 'bootstrap'
  *
  * @example SIALApplication::__get
  * @code
  * <?php
  *  use \br\gov\sial\core\exception\IllegalArgumentException;
  *
  *  try {
  *      # formato geral: $app->__VAR_NAME__
  *
  *      ...
  *      # recupera referencia do objeto SIAL Appllication Form (SAF)
  *      $saf = $app->saf;
  *
  *      ...
  *      # recupera referencia do objeto Bootstrat
  *      $bootstrap = $app->bootstrap;
  *
  *  } catch (IllegalArgumentException $iexc) {
  *      # tratar illegal exception conforme necessidade
  *  }
  *
  *  # recupera referencia do objeto Bootstrap
  *  $bootstrap = $app->bootstrap;
  * ?>
  * @endcode
  *
  * @param string $name informa o nome da referência que se deseja obter (ou 'saf' ou 'bootstrap')
  * @throws \br\gov\sial\core\exception\IllegalArgumentException lançada sempre que '__VAR_NAME__' não tiver disponível
  * */
 public function __get($name)
 {
     # libera acesso somente leitura as objetos:
     switch ($name) {
         case 'saf':
             return $this->_isaf;
         case 'bootstrap':
             return $this->_bootstrap;
     }
     parent::__get($name);
 }
Esempio n. 3
0
 /**
  * carrega as constante do sistema/subsistema/modulo informado deve ser informado o namespace do
  * sistema/subsistema/modulo onde sera encontrado a pasta com as constantes e nao o local exatato da pasta de
  * constantes.
  *
  * @param string $namespace
  * @param boolean $isModule
  * */
 public function loadModuleConstant($namespace, $isModule = FALSE)
 {
     # motivo de nao colocar: end(explode(parent::NAMESPACE_SEPARATOR, $namespace));
     # eh que o php fica lancado 'Only variables should be passed by reference'
     $arr = explode(parent::NAMESPACE_SEPARATOR, $namespace);
     $file = end($arr);
     $namespace = parent::realpathFromNamespace($namespace) . DIRECTORY_SEPARATOR . 'constant' . DIRECTORY_SEPARATOR . "{$file}.php";
     if (TRUE == $isModule) {
         $namespace = implode(explode(DIRECTORY_SEPARATOR . $file, $namespace, 2));
     }
     $this->loadIfExists($namespace);
 }
Esempio n. 4
0
 /**
  * @code
  * <?php
  *
  * # chamada pelo contexto de objeto
  * $this->genId();
  *
  * # chamada pelo contexto da classe
  * ElementAbstract::genId();
  *
  * ?>
  * @endcode
  *
  * @param string[] $config
  * @return string
  */
 public function genId(\stdClass $config = NULL)
 {
     $ident = parent::safeToggle($config, 'id', NULL);
     if (!isset($config->id)) {
         $ident = 'rndID_' . self::$_seed++;
     }
     return $ident;
 }
Esempio n. 5
0
 /**
  * Registra o Annotation para o ValueObject.
  * @example BusinessAbstract::registerAnnotation
  * @code
  * <?php
  *     ...
  *     $valueObject = FoobarValueObject::factory();
  *     $business->registerAnnotation($valueObject->annotation());
  * ?>
  * @endcode
  * @param string $namespace
  * @return ModelAbstract
  */
 public function registerAnnotation($namespace)
 {
     $namespace = parent::erReplace(array('mvcb\\business' => 'valueObject', 'mvcb\\controller' => 'valueObject', 'mvcb\\model' => 'valueObject', 'Model$' => 'ValueObject', 'Business$' => 'ValueObject', 'Controller$' => 'ValueObject'), $namespace);
     $this->getModel()->registerAnnotation($namespace);
 }
Esempio n. 6
0
 /**
  * Cria e retorna um objeto data.
  *
  * @param string $date
  * @param DATE_PARAM $formatIn
  * @param DATE_PARAM $formatOut
  * @return br\gov\sial\core\lang\Date
  * */
 public static function factory($date = NULL, $formatIn = NULL, $formatOut = NULL)
 {
     $date = $date ?: date('Y-m-d H:i:s');
     $time = explode(' ', $date, 2);
     $date = current($time);
     $time = next($time);
     if (NULL == $formatIn) {
         if ('/' == $date[2]) {
             $formatIn = self::FORMAT_PT_BR;
         }
         if ('-' == $date[4]) {
             $formatIn = self::FORMAT_EN;
         }
     }
     $formatIn = parent::toggle($formatIn, self::$_defaultOutputType);
     self::$_defaultOutputType = parent::toggle($formatOut, self::$_defaultOutputType);
     return NULL == $date ? self::_factoryCreateCurrentDate() : self::_factoryCreateDate($date, $formatIn, $time);
 }
 /**
  * verifica a existencia do attr na anotacao, tambem, fica reponsavel por
  * verificar se o attr possui referencia para outro ValueObject, foreignKey.
  * caso o attr solicitado nao exista, também, na anotacao, uma exception
  * sera lancada.
  *
  * @param string $attr
  * @throws ValueObjectException
  * */
 public function __get($attr)
 {
     $value = NULL;
     $getter = $this->getter($attr);
     # prioriza o uso do getter
     if ($getter) {
         $value = $this->{$getter}();
     } else {
         $translatendAttr = self::attrTranslateName($attr);
         # note que se o attr nao existe, a superclasse lancara um
         # exception, tal qual ja eh feito
         if (!isset($this->{$translatendAttr})) {
             parent::__get($attr);
         }
         $value = $this->{$translatendAttr};
         # verifica se o attr em questao trata-se de uma chave-estrangeira
         $attrAnnon = $this->annotation()->load()->attrs;
         $foreignKey = isset($attrAnnon->{$attr}->foreignKey) ? $attrAnnon->{$attr}->foreignKey : NULL;
         if ($foreignKey) {
             # converte namespace de valueObject para o namespace capaz
             # de recuperar os dados da chave-estrangeira
             $namespace = explode('valueObject', $foreignKey->refer);
             $namespace[1] = str_replace('ValueObject', 'Business', $namespace[1]);
             $namespace[0] .= 'mvcb' . self::NAMESPACE_SEPARATOR;
             $namespace = implode('business', $namespace);
             $value = $namespace::factory()->find($value);
         }
     }
     return $value;
 }
Esempio n. 8
0
 /**
  * Intercepta chamada a método inexistente e redireciona para funcionalidades pre-definidas.
  *
  * @param string $name
  * @param string[] $arguments
  * @return ModelAbstract
  * */
 public function __call($name, array $arguments = array())
 {
     # registra ordenacao de pesquisa
     if ('orderByList' == $name) {
         $this->_registerOrderByList($arguments);
     } elseif ('orderBy' == substr($name, 0, 7)) {
         $this->_registerOrderBy(substr($name, 7), current($arguments));
     } else {
         parent::__call($name, $arguments);
     }
     return $this;
 }