BaseMapper.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 BuilderInterface $builder
  24. * @param AdminInterface $admin
  25. */
  26. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  27. {
  28. $this->builder = $builder;
  29. $this->admin = $admin;
  30. }
  31. /**
  32. * @return AdminInterface
  33. */
  34. public function getAdmin()
  35. {
  36. return $this->admin;
  37. }
  38. /**
  39. * @param string $key
  40. *
  41. * @return mixed
  42. */
  43. abstract public function get($key);
  44. /**
  45. * @param string $key
  46. *
  47. * @return boolean
  48. */
  49. abstract public function has($key);
  50. /**
  51. * @param string $key
  52. *
  53. * @return $this
  54. */
  55. abstract public function remove($key);
  56. /**
  57. * @param array $keys field names
  58. *
  59. * @return $this
  60. */
  61. abstract public function reorder(array $keys);
  62. }