BaseMapper.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. *
  10. */
  11. namespace Sonata\AdminBundle\Mapper;
  12. use Sonata\AdminBundle\Admin\AdminInterface;
  13. use Sonata\AdminBundle\Builder\BuilderInterface;
  14. /**
  15. * This class is used to simulate the Form API
  16. *
  17. */
  18. abstract class BaseMapper
  19. {
  20. protected $admin;
  21. protected $builder;
  22. /**
  23. * @param \Sonata\AdminBundle\Builder\BuilderInterface $builder
  24. * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  25. */
  26. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  27. {
  28. $this->builder = $builder;
  29. $this->admin = $admin;
  30. }
  31. /**
  32. * @return \Sonata\AdminBundle\Admin\AdminInterface
  33. */
  34. public function getAdmin()
  35. {
  36. return $this->admin;
  37. }
  38. /**
  39. * @param string $name
  40. *
  41. * @return mixed
  42. */
  43. public abstract function get($key);
  44. /**
  45. * @param string $key
  46. *
  47. * @return boolean
  48. */
  49. public abstract function has($key);
  50. /**
  51. * @param string $key
  52. *
  53. * @return \Sonata\AdminBundle\Mapper\BaseMapper
  54. */
  55. public abstract function remove($key);
  56. /**
  57. * @param array $keys field names
  58. *
  59. * @return \Sonata\AdminBundle\Mapper\BaseMapper
  60. */
  61. public abstract function reorder(array $keys);
  62. }