Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. ////////////////////////////// config-connections -------->
  2. 'orm_maxfoodapp' => array(
  3. 'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver',
  4. 'params' => array(
  5. 'host' => 'localhost',
  6. 'port' => '3306',
  7. 'user' => 'root',
  8. 'password' => 'root',
  9. 'dbname' => 'maxfood_application',
  10. 'driver' => 'pdo_mysql',
  11. 'driverOptions' => array(
  12. 1002 => "SET NAMES 'UTF8'"
  13. )
  14. )
  15. ),
  16. 'configuration' => array(
  17. ////////////////////////////// config-extra-configuration -------->
  18. 'orm_maxfoodapp' => array(
  19. 'metadata_cache' => 'array',
  20. 'query_cache' => 'array',
  21. 'result_cache' => 'array',
  22. 'hydration_cache' => 'array',
  23. 'driver' => 'orm_maxfoodapp',
  24. 'generate_proxies' => true,
  25. 'proxy_dir' => 'data/DoctrineORMModule4/Proxy',
  26. 'proxy_namespace' => 'DoctrineORMModule4Proxy',
  27. 'filters' => array()
  28. ),
  29. ),
  30. 'entitymanager' => array(
  31. ////////////////////////////// config-extra-entitymanager -------->
  32. 'orm_maxfoodapp' => array(
  33. 'connection' => 'orm_maxfoodapp',
  34. 'configuration' => 'orm_maxfoodapp'
  35. ),
  36. ),
  37. 'eventmanager' => array(
  38. ////////////////////////////// config-extra-eventmanager -------->
  39. 'orm_maxfoodapp' => array(),
  40. ),
  41. )
  42. )
  43.  
  44. protected $em;
  45. protected $username;
  46. protected $password;
  47.  
  48. protected $entity = "PanelEntityPersons";
  49.  
  50. public function __construct(EntityManager $em)
  51. {
  52. $this->em = $em;
  53. }
  54.  
  55. /**
  56. * @return mixed
  57. */
  58. public function getUsername()
  59. {
  60. return $this->username;
  61. }
  62.  
  63. /**
  64. * @param mixed $username
  65. */
  66. public function setUsername($username)
  67. {
  68. $this->username = $username;
  69. return $this;
  70. }
  71.  
  72. /**
  73. * @return mixed
  74. */
  75. public function getPassword()
  76. {
  77. return $this->password;
  78. }
  79.  
  80. /**
  81. * @param mixed $password
  82. */
  83. public function setPassword($password)
  84. {
  85. $this->password = $password;
  86. return $this;
  87. }
  88.  
  89.  
  90.  
  91. public function authenticate()
  92. {
  93. $repository = $this->em->getRepository($this->entity);
  94. $user = $repository->username($this->getUsername(),$this->getPassword());
  95.  
  96. if($user) {
  97. return new Result(Result::SUCCESS, array('user' => $user), array('OK'));
  98. } else {
  99. return new Result(Result::FAILURE_CREDENTIAL_INVALID, null, array());
  100. }
  101.  
  102. }
  103.  
  104. public function getServiceConfig() {
  105.  
  106. return array(
  107. 'factories' => array(
  108. 'PanelFormAccess' => function($sm) {
  109. return new FormAccess("access");
  110. },
  111.  
  112. /////////////////////////////////////////// Serviços ->
  113. 'PanelServicePersons' => function($em) {
  114. return new ServiceAddress($em->get('doctrine.entitymanager.orm_maxfoodapp'));
  115. },
  116. 'PanelAuthenticationAdapter' => function($service) {
  117. return new AuthAdapter($service->get('doctrine.entitymanager.orm_maxfoodapp'));
  118. },
  119. ),
  120. );
  121. }
  122.  
  123. public function getViewHelperConfig() {
  124. return array(
  125. 'factories' => array(
  126. 'flashMessage' => function($sm) {
  127.  
  128. $flashmessenger = $sm->getServiceLocator()
  129. ->get('ControllerPluginManager')
  130. ->get('flashmessenger');
  131.  
  132. $message = new AdminViewHelperFlashMessages( ) ;
  133. $message->setFlashMessenger( $flashmessenger );
  134.  
  135. return $message ;
  136. },
  137. ),
  138. );
  139. }
  140.  
  141. public function getConfig()
  142. {
  143. return include __DIR__ . '/config/module.config.php';
  144. }
  145.  
  146. public function getAutoloaderConfig()
  147. {
  148. return array(
  149. 'ZendLoaderStandardAutoloader' => array(
  150. 'namespaces' => array(
  151. __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
  152. ),
  153. ),
  154. );
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement