BaseMapper.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. * This class is used to simulate the Form API.
  15. */
  16. abstract class BaseMapper
  17. {
  18. protected $admin;
  19. protected $builder;
  20. /**
  21. * @param BuilderInterface $builder
  22. * @param AdminInterface $admin
  23. */
  24. public function __construct(BuilderInterface $builder, AdminInterface $admin)
  25. {
  26. $this->builder = $builder;
  27. $this->admin = $admin;
  28. }
  29. /**
  30. * @return AdminInterface
  31. */
  32. public function getAdmin()
  33. {
  34. return $this->admin;
  35. }
  36. /**
  37. * @param string $key
  38. *
  39. * @return mixed
  40. */
  41. abstract public function get($key);
  42. /**
  43. * @param string $key
  44. *
  45. * @return bool
  46. */
  47. abstract public function has($key);
  48. /**
  49. * @param string $key
  50. *
  51. * @return $this
  52. */
  53. abstract public function remove($key);
  54. /**
  55. * @param array $keys field names
  56. *
  57. * @return $this
  58. */
  59. abstract public function reorder(array $keys);
  60. }