/**
  * @param string             $name
  * @param DataModelInterface $model
  *
  * @return null|MongoGateway
  * @throws \Exception
  */
 public function getGateway($name, DataModelInterface $model = null)
 {
     if ($model == null) {
         throw new \Exception(' Raw Gateway needs a DataModelInterface instance as the second parameter ');
     }
     $adapterConfig = $this->getConfig($model);
     $gwName = Arr::getDoubtField($adapterConfig, 'gateway', null);
     if ($gwName === null) {
         $gwName = Arr::getDoubtField($adapterConfig, 'driver', null);
     }
     if ($gwName === null) {
         throw new \Exception('Unknown gateway');
     }
     // create resultSet prototype
     $resultSetPrototype = new ResultSet();
     $resultSetPrototype->setArrayObjectPrototype($model);
     // create custom transport for the model
     $dbAdapter = $this->getServiceLocator()->get($model->_adapter);
     // use general gw class
     if ($gwName == 'Pdo') {
         throw new \Exception(' TODO: Needs to implement PDO Gateway create !! ');
     }
     $gw = Obj::create('\\ModelFramework\\GatewayService\\MongoGateway', ['table' => $model->getTableName(), 'adapter' => $dbAdapter, 'resultSetPrototype' => $resultSetPrototype]);
     return $gw;
 }
Ejemplo n.º 2
0
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $subject = $serviceLocator->get('Category\\Model\\Category');
     $resultSet = new ResultSet();
     $resultSet->setArrayObjectPrototype($subject);
     return $resultSet;
 }
Ejemplo n.º 3
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\BookTable' => function ($sm) {
         $tableGateway = $sm->get('BookTableGateway');
         $table = new BookTable($tableGateway);
         return $table;
     }, 'BookTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Book());
         return new TableGateway('books', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\GenreTable' => function ($sm) {
         $tableGateway = $sm->get('GenreTableGateway');
         $table = new GenreTable($tableGateway);
         return $table;
     }, 'GenreTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Genre());
         return new TableGateway('genres', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\AuthorTable' => function ($sm) {
         $tableGateway = $sm->get('AuthorTableGateway');
         $table = new AuthorTable($tableGateway);
         return $table;
     }, 'AuthorTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Author());
         return new TableGateway('authors', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 4
0
 public function getServiceConfig()
 {
     return array('initializers' => array(function ($instance, $sm) {
         if ($instance instanceof \Zend\Db\Adapter\AdapterAwareInterface) {
             $instance->setDbAdapter($sm->get('Zend\\Db\\Adapter\\Adapter'));
         }
     }), 'factories' => array('InvoiceTable' => function ($sm) {
         $tableGateway = $sm->get('InvoiceTableGateway');
         $table = new InvoiceTable($tableGateway);
         return $table;
     }, 'InvoiceTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Invoice());
         return new TableGateway('invoice', $dbAdapter, null, $resultSetPrototype);
     }, 'Invoice\\Model\\OderTable' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new OderTable($dbAdapter);
         return $table;
     }, 'Invoice\\Model\\OderdetailTable' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new OderdetailTable($dbAdapter);
         return $table;
     }));
 }
Ejemplo n.º 5
0
 /**
  * Get time zones
  *
  * @return array
  */
 public function getTimeZones()
 {
     // check data in a memory
     if (null !== self::$timeZones) {
         return self::$timeZones;
     }
     // generate a cache name
     $cacheName = CacheUtility::getCacheName(self::CACHE_TIME_ZONES);
     // check data in cache
     if (null === ($timeZones = $this->staticCacheInstance->getItem($cacheName))) {
         $select = $this->select();
         $select->from('application_time_zone')->columns(['id', 'name'])->order('name');
         $statement = $this->prepareStatementForSqlObject($select);
         $resultSet = new ResultSet();
         $resultSet->initialize($statement->execute());
         foreach ($resultSet as $timeZone) {
             $timeZones[$timeZone->id] = $timeZone->name;
         }
         // save data in cache
         $this->staticCacheInstance->setItem($cacheName, $timeZones);
         $this->staticCacheInstance->setTags($cacheName, [self::CACHE_TIME_ZONES_DATA_TAG]);
     }
     self::$timeZones = $timeZones;
     return $timeZones;
 }
Ejemplo n.º 6
0
 public function getServiceConfig()
 {
     return array('initializers' => array(function ($instance, $sm) {
         if ($instance instanceof \Zend\Db\Adapter\AdapterAwareInterface) {
             $instance->setDbAdapter($sm->get('Zend\\Db\\Adapter\\Adapter'));
         }
     }), 'factories' => array('ProductTable' => function ($sm) {
         $tableGateway = $sm->get('ProductTableGateway');
         $table = new ProductTable($tableGateway);
         return $table;
     }, 'ProductTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Product());
         return new TableGateway('product', $dbAdapter, null, $resultSetPrototype);
     }, 'NameTable' => function ($sm) {
         $tableGateway = $sm->get('NameTableGateway');
         $table = new NameTable($tableGateway);
         return $table;
     }, 'NameTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Name());
         return new TableGateway('name', $dbAdapter, null, $resultSetPrototype);
     }, 'DeclarationTable' => function ($sm) {
         $tableGateway = $sm->get('DeclarationTableGateway');
         $table = new DeclarationTable($tableGateway);
         return $table;
     }, 'DeclarationTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Declaration());
         return new TableGateway('declaration', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 7
0
 /**
  * Get menu
  *
  * @return array
  */
 public function getMenu()
 {
     // generate cache name
     $cacheName = CacheUtility::getCacheName(self::CACHE_ADMIN_MENU);
     // check data in cache
     if (null === ($menu = $this->staticCacheInstance->getItem($cacheName))) {
         $select = $this->select();
         $select->from(['a' => 'application_admin_menu'])->columns(['name', 'controller', 'action'])->join(['b' => 'application_admin_menu_category'], 'a.category = b.id', ['category' => 'name', 'category_icon' => 'icon'])->join(['c' => 'application_admin_menu_part'], 'a.part = c.id', ['part' => 'name', 'part_icon' => 'icon'])->join(['d' => 'application_module'], new Expression('c.module = d.id and d.status = ?', [self::MODULE_STATUS_ACTIVE]), ['part_module' => 'name'])->join(['i' => 'application_module'], new Expression('b.module = i.id and i.status = ?', [self::MODULE_STATUS_ACTIVE]), ['category_module' => 'name'])->order('order');
         $statement = $this->prepareStatementForSqlObject($select);
         $resultSet = new ResultSet();
         $resultSet->initialize($statement->execute());
         // process admin menu
         foreach ($resultSet as $menuItem) {
             if (!isset($menu[$menuItem['part']])) {
                 $menu[$menuItem['part']] = ['part' => $menuItem['part'], 'icon' => $menuItem['part_icon'], 'module' => $menuItem['part_module'], 'items' => [0 => ['name' => $menuItem['name'], 'controller' => $menuItem['controller'], 'action' => $menuItem['action'], 'category' => $menuItem['category'], 'category_icon' => $menuItem['category_icon'], 'category_module' => $menuItem['category_module']]]];
             } else {
                 $menu[$menuItem['part']]['items'][] = ['name' => $menuItem['name'], 'controller' => $menuItem['controller'], 'action' => $menuItem['action'], 'category' => $menuItem['category'], 'category_icon' => $menuItem['category_icon'], 'category_module' => $menuItem['category_module']];
             }
         }
         // save data in cache
         $this->staticCacheInstance->setItem($cacheName, $menu);
         $this->staticCacheInstance->setTags($cacheName, [self::CACHE_ADMIN_MENU_DATA_TAG]);
     }
     return $menu;
 }
Ejemplo n.º 8
0
 public function getServiceConfig()
 {
     return ['factories' => ['MailOptions' => 'Base\\Service\\Factory\\MailOptions', 'CommunityTable' => function (ServiceLocatorInterface $sm) {
         $tableGateway = $sm->get('CommunityTableGateway');
         $table = new CommunityTable($tableGateway);
         return $table;
     }, 'CommunityTableGateway' => function (ServiceLocatorInterface $sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Community());
         return new TableGateway('tbl_community', $dbAdapter, null, $resultSetPrototype);
     }, 'ReleaseOrderTable' => function (ServiceLocatorInterface $sm) {
         $tableGateway = $sm->get('ReleaseOrderTableGateway');
         $table = new ReleaseOrderTable($tableGateway);
         return $table;
     }, 'ReleaseOrderTableGateway' => function (ServiceLocatorInterface $sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new ReleaseOrder());
         return new TableGateway('tbl_release_order', $dbAdapter, null, $resultSetPrototype);
     }, 'YqClassTable' => function (ServiceLocatorInterface $sm) {
         $tableGateway = $sm->get('YqClassTableGateway');
         $table = new YqClassTable($tableGateway);
         return $table;
     }, 'YqClassTableGateway' => function (ServiceLocatorInterface $sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new YqClass());
         return new TableGateway('tbl_yq_class', $dbAdapter, null, $resultSetPrototype);
     }, 'redis-cli' => 'Base\\Service\\Factory\\RedisFactory'], 'invokables' => ['LongDai' => 'Base\\Service\\LongDaiService']];
 }
Ejemplo n.º 9
0
 public function getServiceConfig()
 {
     return array('factories' => array('Myworkapp\\Model\\TaskTable' => function ($sm) {
         $tableGateway = $sm->get('TaskTableGateway');
         $table = new TaskTable($tableGateway);
         return $table;
     }, 'TaskTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Task());
         return new TableGateway('tasks', $dbAdapter, null, $resultSetPrototype);
     }, 'Myworkapp\\Model\\TaskTypeTable' => function ($sm) {
         $tableGateway = $sm->get('TaskTypeTableGateway');
         $table = new TaskTypeTable($tableGateway);
         return $table;
     }, 'TaskTypeTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new TaskType());
         return new TableGateway('task_types', $dbAdapter, null, $resultSetPrototype);
     }, 'Myworkapp\\Model\\EmployeeTable' => function ($sm) {
         $tableGateway = $sm->get('EmployeeTableGateway');
         $table = new EmployeeTable($tableGateway);
         return $table;
     }, 'EmployeeTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Employee());
         return new TableGateway('employers', $dbAdapter, null, $resultSetPrototype);
     }));
 }
 public function createService(ServiceLocatorInterface $sm)
 {
     $dbAdapter = $sm->get('db-adapter');
     $resultSetPrototype = new ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new Country());
     return new TableGateway("pays", $dbAdapter, null, $resultSetPrototype);
 }
Ejemplo n.º 11
0
 public function fetchAll($paginate = true, $Flag = false, $user_id = '')
 {
     if ($paginate) {
         $select = new Select('messages');
         $select->columns(array('*', new Expression("from_user.user_name as from_user, to_user.user_name as to_user")));
         $select->join(array('from_user' => 'users'), 'from_user.id = messages.from_user_id', array(), 'left');
         $select->join(array('to_user' => 'users'), 'to_user.id = messages.to_user_id', array(), 'left');
         if ($Flag == "trash") {
             $select->where(array('deleteFlag' => '1'));
             $select->order('created_date ASC');
         } else {
             if ($Flag == "outbox") {
                 $select->where(array('from_user_id' => $user_id, 'deleteFlag' => '0'));
                 $select->order('created_date ASC');
             } else {
                 if ($Flag == "inbox") {
                     $select->where('to_user_id = ' . $user_id . ' AND deleteFlag = 0');
                     $select->order('created_date ASC');
                 }
             }
         }
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Messages());
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     return $this->tableGateway->select();
 }
Ejemplo n.º 12
0
 public function getServiceConfig()
 {
     return array('factories' => array('Forum\\Model\\ThreadList' => function ($sm) {
         $tableGateway = $sm->get('ThreadListGateway');
         $table = new ThreadList($tableGateway);
         return $table;
     }, 'ThreadListGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Thread());
         return new TableGateway('forum', $dbAdapter, null, $resultSetPrototype);
     }, 'Forum\\Model\\PostList' => function ($sm) {
         $tableGateway = $sm->get('PostListGateway');
         $table = new PostList($tableGateway);
         return $table;
     }, 'PostListGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Post());
         return new TableGateway('posts', $dbAdapter, null, $resultSetPrototype);
     }, 'Forum\\Model\\UserList' => function ($sm) {
         $tableGateway = $sm->get('UserListGateway');
         $table = new UserList($tableGateway);
         return $table;
     }, 'UserListGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new User());
         return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 13
0
 public function fetchAll($request, $paginated = false)
 {
     if ($paginated) {
         // create a new Select object for the table album
         $select = new Select('album');
         $select->order($request['sort'] . " " . $request['order']);
         // Search
         if ($request['search']) {
             $x = $request['search'] . '%';
             $where = new \Zend\Db\Sql\Where();
             $where->like('title', $x);
             $where->or->like('artist', $x);
             $select->where($where);
         }
         // New result set based on the Album entity
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Album());
         // New pagination adapter object
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     $resultSet = $this->tableGateway->select();
     return $resultSet;
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter');
     $resultSetPrototype = new ResultSet();
     $resultSetPrototype->setArrayObjectPrototype(new Product());
     return new TableGateway('table_product', $dbAdapter, null, $resultSetPrototype);
 }
Ejemplo n.º 15
0
 public function getServiceConfig()
 {
     return array('factories' => array('Api\\Model\\GroupsTable' => function ($sm) {
         $tableGateway = $sm->get('GroupsTableGateway');
         $table = new GroupsTable($tableGateway);
         return $table;
     }, 'GroupsTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Group());
         return new TableGateway('groups', $dbAdapter, null, $resultSetPrototype);
     }, 'Api\\Model\\UsersTable' => function ($sm) {
         $tableGateway = $sm->get('UsersTableGateway');
         $table = new UsersTable($tableGateway);
         return $table;
     }, 'UsersTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new User());
         return new TableGateway('users', $dbAdapter, null, $resultSetPrototype);
     }, 'Api\\Model\\UsersToGroupsTable' => function ($sm) {
         $tableGateway = $sm->get('UsersToGroupsTableGateway');
         $table = new UsersToGroupsTable($tableGateway);
         return $table;
     }, 'UsersToGroupsTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new UserToGroup());
         return new TableGateway('users_to_groups', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 16
0
 public function fetchAll($paginate = true, $filter = array(), $orderBy = array())
 {
     if ($paginate) {
         $select = new Select('service_language');
         $select->join('lookup_status', 'lookup_status.status_id = service_language.status_id', array('status'), 'left');
         /* Data filter code start here*/
         if (count($filter) > 0) {
             $filter['language_name'] != "" ? $select->where("service_language.language_name LIKE '%" . $filter['language_name'] . "%'") : "";
             $filter['status_id'] != "" ? $select->where("service_language.status_id = " . $filter['status_id']) : "";
         }
         /* Data filter code end here*/
         /* Data sorting code starts here */
         if (count($orderBy) > 0 && $orderBy['sort_field'] != '' && $orderBy['sort_order'] != '') {
             switch ($orderBy['sort_field']) {
                 case 'language':
                     $select->order('service_language.language_name ' . $orderBy['sort_order']);
                     break;
                 case 'status':
                     $select->order('lookup_status.status ' . $orderBy['sort_order']);
                     break;
             }
         }
         /* Data sorting code ends here */
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new ServiceLanguages());
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         $paginator = new Paginator($paginatorAdapter);
         return $paginator;
     }
     return $this->tableGateway->select();
 }
Ejemplo n.º 17
0
 public function getUsersAndAbove(bool $paginated, $name = '', $roles = [])
 {
     $select = new Select('account');
     $where = new Where();
     if ($roles) {
         $sub = $where->nest();
         for ($i = 0; $i < count($roles); $i++) {
             $sub->equalTo('role', $roles[$i]);
             if ($i < count($roles) - 1) {
                 $sub->or;
             }
         }
         $sub->unnest();
     } else {
         $where->greaterThan('role', '0');
         $where->lessThan('role', '32');
     }
     if ($name) {
         $where->like('name', '%' . $name . '%');
     }
     $select->where($where)->order('name ASC');
     if ($paginated) {
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Account());
         $paginatorAdapter = new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetPrototype);
         return new Paginator($paginatorAdapter);
     }
     return $this->tableGateway->select($select);
 }
Ejemplo n.º 18
0
 public function indexAction()
 {
     $session = new Container('admin');
     if ($session->offsetExists('email')) {
         //Prepare statistique information pour la vue Index ->des statistiques
         $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
         $sql1 = "select * from pro_product_bdma";
         $statement1 = $adapter->query($sql1);
         $results1 = $statement1->execute();
         $row1 = $results1->current();
         //tester si les variables rouX ont bien remplis
         if (!$row1) {
             //redirection vers l'index avec un message GET var
             $this->redirect()->toRoute('product', array('action' => 'index'), array('query' => array('status' => 'erreur_fetching_view_data')));
         } else {
             // 2 preparation des donnees  result sett , retourne un mass d'information
             if ($results1 instanceof ResultInterface && $results1->isQueryResult()) {
                 //instanciation  de la class result set pour l'enregistrement des information fournis par la BD
                 $resultSet = new ResultSet();
                 $resultSet->initialize($results1);
                 //  redirection vers la vue index avec les information des statistiques
                 return new ViewModel(array('data' => $resultSet));
             }
         }
     } else {
         $this->redirect()->toRoute('admin', array('action' => 'login'), array('query' => array('status' => 'u_login')));
     }
 }
Ejemplo n.º 19
0
 public function getServiceConfig()
 {
     return array('factories' => array('Usuario\\Model\\UsuarioTable' => function ($sm) {
         $tableGateway = $sm->get('UsuarioTableGateway');
         $table = new UsuarioTable($tableGateway);
         return $table;
     }, 'UsuarioTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Usuario());
         return new TableGateway('ta_usuario', $dbAdapter, null, $resultSetPrototype);
     }, 'Usuario\\Model\\Cliente' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new Cliente($dbAdapter);
         return $table;
     }, 'Usuario\\Model\\ComentariosTable' => function ($sm) {
         $tableGateway = $sm->get('ComentariosTableGateway');
         $table = new Model\ComentariosTable($tableGateway);
         return $table;
     }, 'ComentariosTableGateway' => function ($sm) {
         $dbAdapte = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Comentarios());
         return new TableGateway('ta_comentario', $dbAdapte, null, $resultSetPrototype);
     }, 'Usuario\\Model\\ClientesTable' => function ($sm) {
         $tableGateway = $sm->get('ClientesTableGateway');
         $table = new Model\ClientesTable($tableGateway);
         return $table;
     }, 'ClientesTableGateway' => function ($sm) {
         $dbAdapte = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Clientes());
         return new TableGateway('ta_cliente', $dbAdapte, null, $resultSetPrototype);
     }));
 }
 public function __construct($db)
 {
     $this->db = $db;
     $resultSet = new ResultSet();
     $resultSet->setArrayObjectPrototype(new ClienteEntity());
     $this->tableGateway = new TableGateway('Cliente', $db, null, $resultSet);
 }
Ejemplo n.º 21
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\CertificateTable' => function ($sm) {
         $tableGateway = $sm->get('CertificateTableGateway');
         $table = new CertificateTable($tableGateway);
         return $table;
     }, 'CertificateTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         return new TableGateway('certificates', $dbAdapter);
     }, 'Application\\Model\\DocumentTable' => function ($sm) {
         $tableGateway = $sm->get('DocumentTableGateway');
         $table = new DocumentTable($tableGateway);
         return $table;
     }, 'DocumentTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Document());
         return new TableGateway('documents', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\PriceHistoryTable' => function ($sm) {
         $tableGateway = $sm->get('PriceHistoryTableGateway');
         $table = new PriceHistoryTable($tableGateway);
         return $table;
     }, 'PriceHistoryTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new PriceHistory());
         return new TableGateway('price_history', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 22
0
 public function getServiceConfig()
 {
     return array('factories' => array('StitchPattern\\Model\\StitchPatternTable' => function ($sm) {
         $tableGateway = $sm->get('StitchPatternTableGateway');
         $table = new StitchPatternTable($tableGateway);
         return $table;
     }, 'StitchPatternTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new StitchPattern());
         return new TableGateway('stitchpattern', $dbAdapter, null, $resultSetPrototype);
     }, 'StitchPattern\\Model\\EmulatorBridge' => function ($sm) {
         $emulator = new EmulatorBridge();
         return $emulator;
     }, 'StitchPattern\\Model\\USBCableTable' => function ($sm) {
         $tableGateway = $sm->get('USBCableTableGateway');
         $table = new USBCableTable($tableGateway);
         return $table;
     }, 'USBCableTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new USBCable());
         return new TableGateway('usbcable', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 23
0
 protected function setUp()
 {
     $bootstrap = \Zend\Mvc\Application::init(include 'config/application.config.php');
     $categoryData = array('id_category' => 1, 'name' => 'Project Manager');
     $category = new Category();
     $category->exchangeArray($categoryData);
     $resultSetCategory = new ResultSet();
     $resultSetCategory->setArrayObjectPrototype(new Category());
     $resultSetCategory->initialize(array($category));
     $mockCategoryTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockCategoryTableGateway->expects($this->any())->method('select')->with()->will($this->returnValue($resultSetCategory));
     $categoryTable = new CategoryTable($mockCategoryTableGateway);
     $jobData = array('id_job' => 1, 'id_category' => 1, 'type' => 'typeTest', 'company' => 'companyTest', 'logo' => 'logoTest', 'url' => 'urlTest', 'position' => 'positionTest', 'location' => 'locaitonTest', 'description' => 'descriptionTest', 'how_to_play' => 'hotToPlayTest', 'is_public' => 1, 'is_activated' => 1, 'email' => 'emailTest', 'created_at' => '2012-01-01 00:00:00', 'updated_at' => '2012-01-01 00:00:00');
     $job = new Job();
     $job->exchangeArray($jobData);
     $resultSetJob = new ResultSet();
     $resultSetJob->setArrayObjectPrototype(new Job());
     $resultSetJob->initialize(array($job));
     $mockJobTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select'), array(), '', false);
     $mockJobTableGateway->expects($this->any())->method('select')->with(array('id_category' => 1))->will($this->returnValue($resultSetJob));
     $jobTable = new JobTable($mockJobTableGateway);
     $this->controller = new IndexController($categoryTable, $jobTable);
     $this->request = new Request();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = $bootstrap->getMvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setEventManager($bootstrap->getEventManager());
     $this->controller->setServiceLocator($bootstrap->getServiceManager());
 }
Ejemplo n.º 24
0
 /**
  * Expected to return \Zend\ServiceManager\Config object or array to
  * seed such an object.
  *
  * @return array|\Zend\ServiceManager\Config
  */
 public function getServiceConfig()
 {
     return ['factories' => ['ArticleTable' => function (ServiceLocatorInterface $sm) {
         $tableGateway = $sm->get('ArticleTableGateway');
         $table = new ArticleTable($tableGateway);
         return $table;
     }, 'ArticleTableGateway' => function (ServiceLocatorInterface $sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Article());
         return new TableGateway('tbl_article', $dbAdapter, null, $resultSetPrototype);
     }, 'UserTable' => function (ServiceLocatorInterface $sm) {
         $tableGateway = $sm->get('UserTableGateway');
         $table = new UserTable($tableGateway);
         return $table;
     }, 'UserTableGateway' => function (ServiceLocatorInterface $sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new User());
         return new TableGateway('tbl_user', $dbAdapter, null, $resultSetPrototype);
     }, 'Smarty' => function (ServiceLocatorInterface $sm) {
         $smarty = new MySmarty();
         $smarty->debugging = false;
         $smarty->caching = false;
         $smarty->cache_lifetime = 120;
         $smarty->setTemplateDir(__DIR__ . '/view/smarty/templates');
         $smarty->setConfigDir(__DIR__ . '/view/smarty/configs');
         $smarty->setCompileDir(__DIR__ . '/view/smarty/templates_c');
         $smarty->setCacheDir(__DIR__ . '/view/smarty/cache');
         return $smarty;
     }]];
 }
Ejemplo n.º 25
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\KategorieTable' => function ($sm) {
         $tableGateway = $sm->get('KategorieTableGateway');
         $table = new KategorieTable($tableGateway);
         return $table;
     }, 'KategorieTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Kategorie());
         return new TableGateway('kategorie', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\UserTable' => function ($sm) {
         $tableGateway = $sm->get('UserTableGateway');
         $table = new UserTable($tableGateway);
         return $table;
     }, 'UserTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new User());
         return new TableGateway('uzivatele', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\BannerTable' => function ($sm) {
         $tableGateway = $sm->get('BannerTableGateway');
         $table = new BannerTable($tableGateway);
         return $table;
     }, 'BannerTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Banner());
         return new TableGateway('banner', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 26
0
 public function getServiceConfig()
 {
     return array('factories' => array('User\\Model\\UserTable' => function ($sm) {
         $tableGateway = $sm->get('UserTableGateway');
         $table = new UserTable($tableGateway);
         return $table;
     }, 'UserTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new User());
         return new TableGateway('user', $dbAdapter, null, $resultSetPrototype);
     }, 'User\\Model\\CityTable' => function ($sm) {
         $tableGateway = $sm->get('CityTableGateway');
         $table = new CityTable($tableGateway);
         return $table;
     }, 'CityTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new City());
         return new TableGateway('city', $dbAdapter, null, $resultSetPrototype);
     }, 'User\\Model\\EducationTable' => function ($sm) {
         $tableGateway = $sm->get('EducationTableGateway');
         $table = new EducationTable($tableGateway);
         return $table;
     }, 'EducationTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Education());
         return new TableGateway('educations', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 27
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\StateTable' => function ($sm) {
         $tableGateway = $sm->get('StateTableGateway');
         $table = new StateTable($tableGateway);
         return $table;
     }, 'StateTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new State());
         return new TableGateway(DB_PREFIX . 'state', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\CityTable' => function ($sm) {
         $tableGateway = $sm->get('CityTableGateway');
         $table = new CityTable($tableGateway);
         return $table;
     }, 'CityTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new City());
         return new TableGateway(DB_PREFIX . 'city', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\PostMerchandiseTable' => function ($sm) {
         $tableGateway = $sm->get('PostMerchandiseTableGateway');
         $table = new PostMerchandiseTable($tableGateway);
         return $table;
     }, 'PostMerchandiseTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Post());
         return new TableGateway(DB_PREFIX . 'post_merchandise', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 28
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\PaymentTable' => function ($sm) {
         $tableGateway = $sm->get('PaymentTableGateway');
         $table = new PaymentTable($tableGateway);
         return $table;
     }, 'PaymentTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Payment());
         return new TableGateway('payments_history', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\HuntClubTable' => function ($sm) {
         $tableGateway = $sm->get('HuntClubTableGateway');
         $table = new HuntClubTable($tableGateway);
         return $table;
     }, 'HuntClubTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new HuntClub());
         return new TableGateway('hunt_clubs', $dbAdapter, null, $resultSetPrototype);
     }, 'Application\\Model\\HuntClubGameTable' => function ($sm) {
         $tableGateway = $sm->get('HuntClubGameTableGateway');
         $table = new HuntClubGameTable($tableGateway);
         return $table;
     }, 'HuntClubGameTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new HuntClubGame());
         return new TableGateway('hunt_club_game', $dbAdapter, null, $resultSetPrototype);
     }));
 }
Ejemplo n.º 29
0
 public function indexAction()
 {
     // instansiation d'une session d'admin (duré = 30 Jrs)
     $session = new Container('useradmin');
     // tester si une session 'email existe '
     if ($session->offsetExists('uid') && $session->offsetExists('ucomp') && $session->offsetGet('user') == 'user') {
         //Prepare statistique information pour la vue Index ->des statistiques
         $adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
         $cmpny = $session->offsetGet('ucomp');
         $sql1 = "select  `id`, `gender`,`company`, `name`, `firstname`, `email`, `lang`, `phone`, `gsm` from pro_user where company='" . $cmpny . "' and active=1";
         $statement1 = $adapter->query($sql1);
         $results1 = $statement1->execute();
         $row1 = $results1->current();
         //tester si les variables rouX ont bien remplis
         if (!$row1) {
             //redirection vers l'index avec un message GET var
             $this->redirect()->toRoute('useradmin', array('action' => 'index'), array('query' => array('status' => 'erreur_fetching_view_data')));
         } else {
             // 2 preparation des donnees  result sett , retourne un mass d'information
             if ($results1 instanceof ResultInterface && $results1->isQueryResult()) {
                 //instanciation  de la class result set pour l'enregistrement des information fournis par la BD
                 $resultSet = new ResultSet();
                 $resultSet->initialize($results1);
                 //  redirection vers la vue index avec les information des statistiques
                 return new ViewModel(array('data' => $resultSet));
             }
         }
     } else {
         //si la session n'existe pas ,, donc la redirection vers login page pour l'authentification avec un petit message
         $this->redirect()->toRoute('useradmin', array('action' => 'loginuser'), array('query' => array('status' => 'u_login')));
     }
 }
Ejemplo n.º 30
0
 public function getServiceConfig()
 {
     return array('factories' => array('Admin\\Model\\AdminTable' => function ($sm) {
         $tableGateway = $sm->get('AdminTableGateway');
         $table = new AdminTable($tableGateway);
         return $table;
     }, 'AdminTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Admin());
         return new TableGateway('admin', $dbAdapter, null, $resultSetPrototype);
     }, 'Admin\\Model\\PlayerTable' => function ($sm) {
         $tableGateway = $sm->get('PlayerTableGateway');
         $table = new PlayerTable($tableGateway);
         return $table;
     }, 'PlayerTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Player());
         return new TableGateway('player', $dbAdapter, null, $resultSetPrototype);
     }, 'Admin\\Model\\MyAuthStorage' => function ($sm) {
         return new \Admin\Model\MyAuthStorage('adminstore');
     }, 'AuthService' => function ($sm) {
         //My assumption, you've alredy set dbAdapter
         //and has users table with columns : user_name and pass_word
         //that password hashed with md5
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbTableAuthAdapter = new DbTableAuthAdapter($dbAdapter, 'admin', 'email', 'password', 'MD5(?)');
         $authService = new AuthenticationService();
         $authService->setAdapter($dbTableAuthAdapter);
         $authService->setStorage($sm->get('Admin\\Model\\MyAuthStorage'));
         return $authService;
     }));
 }