protected function _isValid($value, $params)
 {
     $dao = Factory::DAO(getValueFromArray($params, Flag::DAO_NAME, ''));
     if (!is_null($dao)) {
         return true;
     }
     return false;
 }
Beispiel #2
0
 /**
  * 
  * @param array $params
  * @return mixed DAO se a Flag::DAO_NAME for setada ou null caso contrário
  */
 public function getDAO($params)
 {
     $daoname = getValueFromArray($params, Flag::DAO_NAME, "");
     if (empty($daoname)) {
         Factory::log()->fatal('É necessário informar o nome do DAO... use Flag::DAO_NAME no parameter!');
         return null;
     }
     return Factory::DAO($daoname);
 }
 public function testDAO()
 {
     $grupoDAO = Factory::DAO('grupo');
     $this->assertNull($grupoDAO);
     // $this->assertEquals($grupoDAO, Factory::DAO('GrupoDAO'));
     //$this->assertSame($grupoDAO, Factory::DAO('grupo'));
     $this->assertNull(Factory::DAO('invalid'));
     $this->assertNull(Factory::DAO('DAO'));
 }
function createDefaultUser()
{
    echo '<li>CreateDefaultUser</li>';
    $dao = Factory::DAO('usuario');
    /* @var $dao UsuarioDAO */
    $email = '*****@*****.**';
    $user = $dao->getByEmail($email);
    if (empty($user)) {
        assert($dao->novo('Administrator', $email, hashit('admin')));
        $dao = Factory::DAO('usuarioGrupo');
        /* @var $dao UsuarioGrupoDAO */
        assert($dao->novo($email, 'admin'));
    }
}
 public function showPage()
 {
     $dao = Factory::DAO('StaticPage');
     $page = $dao->getByNome($this->method);
     if (empty($page)) {
         redirect('/');
     }
     $this->pageTitle = $page['titulo'];
     $this->pagedata['nome'] = $page['nome'];
     $this->pagedata['titulo'] = $page['titulo'];
     $this->pagedata['conteudo'] = Factory::datatype('html')->toHumanFormat($page['conteudo']);
     if (empty($this->pageTitle)) {
         $this->pageTitle = $this->pagedata['titulo'];
     }
 }
Beispiel #6
0
 /**
  * Carrega um DAO único
  * 
  * @param string $dao Nome do DAO
  */
 protected function loadDAO($dao)
 {
     $dao = ucfirst(str_replace('DAO', '', $dao));
     if (!isset($this->daos[$dao])) {
         $this->daos[$dao] = Factory::DAO($dao, $this->getDatabase());
     }
     return $this->daos[$dao];
 }
Beispiel #7
0
 /**
  * Cria um objeto CRUD
  * @param string $urlbase URL base da página
  * @param string $daoname Nome do DAO Associado
  */
 public function __construct($urlbase, $daoname = '')
 {
     $this->urlbase = $urlbase;
     if (!endsWith($urlbase, '/')) {
         $this->urlbase .= '/';
     }
     if (empty($daoname)) {
         $daoname = str_replace('/', '', $urlbase);
     }
     $this->dao = Factory::DAO($daoname);
 }
 /**
  * 
  * @return \Application\Model\Dao\UsuariogrupoDAO
  */
 public function getUsuariogrupoDAO()
 {
     return Factory::DAO('usuarioGrupo', $this->getDatabase());
 }