Advertisement
fahmihilmansyah

Untitled

Apr 15th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2. namespace OpenbravoBundle\Manager;
  3.  
  4. /**
  5.  * Author: Muhammad Surya Ihsanuddin<surya.kejawen@gmail.com>
  6.  * Url: http://blog.khodam.org
  7.  */
  8.  
  9. use Doctrine\ORM\EntityManagerInterface;
  10. use Doctrine\ORM\Query\ResultSetMapping;
  11. use JMS\DiExtraBundle\Annotation\Service;
  12. use JMS\DiExtraBundle\Annotation\Inject;
  13. use JMS\DiExtraBundle\Annotation\InjectParams;
  14.  
  15. /**
  16.  * @Service("openbravo.manager.product_category")
  17.  */
  18. class ProductCategoryManager extends AbstractManager implements ManagerInterface
  19. {
  20.     /**
  21.      * @InjectParams({
  22.      *      "entityManager" = @Inject("doctrine.orm.openbravo_entity_manager")
  23.      * })
  24.      *
  25.      * @param EntityManagerInterface $entityManager
  26.      */
  27.     public function __construct(EntityManagerInterface $entityManager)
  28.     {
  29.         parent::__construct($entityManager);
  30.     }
  31.  
  32.     protected function getResultMapping()
  33.     {
  34.         $resultMapping = new ResultSetMapping();
  35.         $resultMapping->addScalarResult('value', 'code');
  36.         $resultMapping->addScalarResult('name', 'name');
  37.         $resultMapping->addScalarResult('description', 'description');
  38.  
  39.         return $resultMapping;
  40.     }
  41.  
  42.     protected function getSQL()
  43.     {
  44.         $sql = '
  45.           SELECT
  46.               value,
  47.               name,
  48.               description
  49.           FROM
  50.               m_product_category
  51.           WHERE
  52.               isactive = :active
  53.               AND
  54.               name IN (:name)
  55.           ';
  56.  
  57.         $this->parameters['active'] = 'Y';
  58.         $this->parameters['name'] = array(
  59.             'VINOTI FINISH GOODS ACCESSORIES',
  60.             'VINOTI FINISH GOODS ARTWORK',
  61.             'VINOTI FINISH GOODS OFFICE FURNITURE',
  62.             'VINOTI FINISH GOODS PARCEL',
  63.             'VINOTI FINISH GOODS RESIDENTIAL FURNITURE',
  64.             'Vinoti Service',
  65.         );
  66.  
  67.         return $sql;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement