BaseMapper.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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. namespace Sonata\AdminBundle\Mapper;
  11. use Sonata\AdminBundle\Admin\AdminInterface;
  12. use Sonata\AdminBundle\Builder\BuilderInterface;
  13. /**
  14. * Class BaseMapper
  15. * This class is used to simulate the Form API.
  16. *
  17. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  18. */
  19. abstract class BaseMapper
  20. {
  21. protected $admin;
  22. protected $builder;
  23. /**
  24. * @param BuilderInterface $builder
  25. * @param AdminInterface $admin
  26. */
  27. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  28. {
  29. $this->builder = $builder;
  30. $this->admin = $admin;
  31. }
  32. /**
  33. * @return AdminInterface
  34. */
  35. public function getAdmin()
  36. {
  37. return $this->admin;
  38. }
  39. /**
  40. * @param string $key
  41. *
  42. * @return mixed
  43. */
  44. abstract public function get($key);
  45. /**
  46. * @param string $key
  47. *
  48. * @return bool
  49. */
  50. abstract public function has($key);
  51. /**
  52. * @param string $key
  53. *
  54. * @return $this
  55. */
  56. abstract public function remove($key);
  57. /**
  58. * @param array $keys field names
  59. *
  60. * @return $this
  61. */
  62. abstract public function reorder(array $keys);
  63. }