BaseMapper.php 1.5 KB

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